+ entity.addComponent(new PixiContainerComponent(container));
+
+ // PHYSICS
+
+ const bodyA = config.entityA.getComponent(BodyComponent).body;
+ const bodyB = config.entityB.getComponent(BodyComponent).body;
+ const damping = 0;
+ const length = 100 / Config.meterSize;
+ const stiffness = 0.001;
+
+ const body = Constraint.create({
+ bodyA,
+ bodyB,
+ damping,
+ length,
+ stiffness
+ });
+ entity.addComponent(new BodyComponent({ body }));
+
+ entity.addComponent(new CoupledEntitiesComponent({
+ coupledEntities: [config.entityA, config.entityB]
+ }));
+
+ entity.addComponent(new ElasticComponent());
+
+ if (engine) {
+ engine.addEntity(entity);
+ }
+
+ return entity;
+ },
+
+ /**
+ * Creates a controllable sumo entity and adds it to the engine. Can override
+ * position in the config object
+ *
+ * @function createControllableSumo
+ * @memberof SumoFactory
+ * @param {external:Serpentity} [engine] the serpentity engine to attach
+ * to. If not sent, it will not be attached.
+ * @param {object} [config] the config to override the entity, accepts
+ * the key `position` as an object with an x and y property.
+ * @return {external:Serpentity.Entity} the created entity
+ */
+ createControllableSumo(engine, config = {}) {
+
+ const entity = this.createSumo(null, config);
+
+ entity.addComponent(new ControlMapComponent(config.controlMap));
+
+ if (engine) {
+ engine.addEntity(entity);
+ }
+
+ return entity;
+ },
+
+ /**
+ * Creates a controllable sumo entity and adds it to the engine. Can override
+ * position in the config object. Has contrrol scheme defaults for
+ * player 1
+ *
+ * @function createPlayer1Sumo
+ * @memberof SumoFactory
+ * @param {external:Serpentity} [engine] the serpentity engine to attach
+ * to. If not sent, it will not be attached.
+ * @param {object} [config] the config to override the entity, accepts
+ * the key `position` as an object with an x and y property.
+ * @return {external:Serpentity.Entity} the created entity
+ */
+ createPlayer1Sumo(engine, config = {}) {
+
+ const playerConfig = Object.assign({
+ controlMap: {
+ map: [
+ {
+ source: {
+ type: 'keyboard',
+ index: 65 // a
+ },
+ target: {
+ component: ForceComponent,
+ property: 'x',
+ value: (value) => -Number(value)
+ }
+ },
+ {
+ source: {
+ type: 'keyboard',
+ index: 68 // d
+ },
+ target: {
+ component: ForceComponent,
+ property: 'x',
+ value: (value) => Number(value)
+ }
+ },
+ {
+ source: {
+ type: 'keyboard',
+ index: 87 // w
+ },
+ target: {
+ component: ForceComponent,
+ property: 'y',
+ value: (value) => -Number(value)
+ }
+ },
+ {
+ source: {
+ type: 'keyboard',
+ index: 83 // s
+ },
+ target: {
+ component: ForceComponent,
+ property: 'y',
+ value: (value) => Number(value)
+ }
+ },
+ {
+ source: {
+ type: 'keyboard',
+ index: 90 // Z
+ },
+ target: {
+ component: DashComponent,
+ property: 'dashing'
+ }
+ },
+ {
+ source: {
+ type: 'keyboard',
+ index: 88 // X
+ },
+ target: {
+ component: GrabComponent,
+ property: 'grabbing'
+ }
+ },
+ {
+ source: {
+ type: 'gamepad',
+ gamepadNumber: 0,
+ gamepadInputSource: 'axes',
+ index: 0 // left stick horizontal
+ },
+ target: {
+ component: ForceComponent,
+ property: 'x',
+ value: (value) => Number(value)
+ }
+ },
+ {
+ source: {
+ type: 'gamepad',
+ gamepadNumber: 0,
+ gamepadInputSource: 'axes',
+ index: 1 // left stick vertical
+ },
+ target: {
+ component: ForceComponent,
+ property: 'y',
+ value: (value) => Number(value)
+ }
+ },
+ {
+ source: {
+ type: 'gamepad',
+ gamepadNumber: 0,
+ gamepadInputSource: 'buttons',
+ index: 2 // left face button
+ },
+ target: {
+ component: DashComponent,
+ property: 'dashing',
+ value: (value) => value.value
+ }
+ },
+ {
+ source: {
+ type: 'gamepad',
+ gamepadNumber: 0,
+ gamepadInputSource: 'buttons',
+ index: 0 // bottom face button
+ },
+ target: {
+ component: GrabComponent,
+ property: 'grabbing',
+ value: (value) => value.value
+ }
+ }
+ ]
+ }
+ }, config);
+
+ const entity = this.createControllableSumo(null, playerConfig);
+
+ if (engine) {
+ engine.addEntity(entity);
+ }
+
+ return entity;
+ },
+
+ /**
+ * Creates a controllable sumo entity and adds it to the engine. Can override
+ * position in the config object. Has contrrol scheme defaults for
+ * player 2
+ *
+ * @function createPlayer2Sumo
+ * @memberof SumoFactory
+ * @param {external:Serpentity} [engine] the serpentity engine to attach
+ * to. If not sent, it will not be attached.
+ * @param {object} [config] the config to override the entity, accepts
+ * the key `position` as an object with an x and y property.
+ * @return {external:Serpentity.Entity} the created entity
+ */
+ createPlayer2Sumo(engine, config = {}) {
+
+ const playerConfig = Object.assign({
+ pixi: {
+ color: 0xeaacac
+ },
+ controlMap: {
+ map: [
+ {
+ source: {
+ type: 'keyboard',
+ index: 37 // left arrow
+ },
+ target: {
+ component: ForceComponent,
+ property: 'x',
+ value: (value) => -Number(value)
+ }
+ },
+ {
+ source: {
+ type: 'keyboard',
+ index: 39 // right arrow
+ },
+ target: {
+ component: ForceComponent,
+ property: 'x',
+ value: (value) => Number(value)
+ }
+ },
+ {
+ source: {
+ type: 'keyboard',
+ index: 38 // up arrow
+ },
+ target: {
+ component: ForceComponent,
+ property: 'y',
+ value: (value) => -Number(value)
+ }
+ },
+ {
+ source: {
+ type: 'keyboard',
+ index: 40 // down arrow
+ },
+ target: {
+ component: ForceComponent,
+ property: 'y',
+ value: (value) => Number(value)
+ }
+ },
+ {
+ source: {
+ type: 'keyboard',
+ index: 188 // ,
+ },
+ target: {
+ component: DashComponent,
+ property: 'dashing'
+ }
+ },
+ {
+ source: {
+ type: 'keyboard',
+ index: 190 // .
+ },
+ target: {
+ component: GrabComponent,
+ property: 'grabbing'
+ }
+ },
+ {
+ source: {
+ type: 'gamepad',
+ gamepadNumber: 1,
+ gamepadInputSource: 'axes',
+ index: 0 // left stick horizontal
+ },
+ target: {
+ component: ForceComponent,
+ property: 'x',
+ value: (value) => Number(value)
+ }
+ },
+ {
+ source: {
+ type: 'gamepad',
+ gamepadNumber: 1,
+ gamepadInputSource: 'axes',
+ index: 1 // left stick vertical
+ },
+ target: {
+ component: ForceComponent,
+ property: 'y',
+ value: (value) => Number(value)
+ }
+ },
+ {
+ source: {
+ type: 'gamepad',
+ gamepadNumber: 1,
+ gamepadInputSource: 'buttons',
+ index: 2 // left face button
+ },
+ target: {
+ component: DashComponent,
+ property: 'dashing',
+ value: (value) => value.value
+ }
+ },
+ {
+ source: {
+ type: 'gamepad',
+ gamepadNumber: 1,
+ gamepadInputSource: 'buttons',
+ index: 0 // bottom face button
+ },
+ target: {
+ component: GrabComponent,
+ property: 'grabbing',
+ value: (value) => value.value
+ }
+ }
+ ]
+ }
+ }, config);
+
+ const entity = this.createControllableSumo(null, playerConfig);
+
+ if (engine) {
+ engine.addEntity(entity);
+ }
+
+ return entity;
+ },
+
+ /**
+ * Creates a static harness entity
+ *
+ * @function createHarness
+ * @memberof SumoFactory
+ * @param {external:Serpentity} [engine] the serpentity engine to attach
+ * to. If not sent, it will not be attached.
+ * @param {object} [config] the config to override the entity, accepts
+ * the key `position` as an object with an x and y property.
+ * @return {external:Serpentity.Entity} the created entity
+ */
+ createHarness(engine, config = {}) {
+
+ const entity = new Entity();
+
+ // POSITION