9 years ago by zergote
My game has the following problems of collisions in chrome 49.
Entities ACTIVE COLLISION overlap with Entities FIXEDS COLLISIONS .
Fixeds entities when an active entity cluttering the flap .
The Player entity is an entity PASSIVE COLLISION transcends the barriers which are entities FIXEDS COLLISIONS.
PlayCTF
ig.module( 'game.entities.wall' ) .requires('impact.entity') .defines(function() { EntityWall = ig.Entity.extend({ size: { x: 32, y: 32 }, name: "Wall", collides: ig.Entity.COLLIDES.FIXED, type: ig.Entity.TYPE.B, checkAgainst: ig.Entity.TYPE.BOTH, animSheet: new ig.AnimationSheet('media/tileset.png', 32, 32), zIndex: 1, init: function(x, y, settings) { this.parent(x, y, settings); this.addAnim('idle', 1, [9]); } }) } )
Entities ACTIVE COLLISION overlap with Entities FIXEDS COLLISIONS .
Fixeds entities when an active entity cluttering the flap .
The Player entity is an entity PASSIVE COLLISION transcends the barriers which are entities FIXEDS COLLISIONS.
PlayCTF
ig.module( 'game.entities.wall' ) .requires('impact.entity') .defines(function() { EntityWall = ig.Entity.extend({ size: { x: 32, y: 32 }, name: "Wall", collides: ig.Entity.COLLIDES.FIXED, type: ig.Entity.TYPE.B, checkAgainst: ig.Entity.TYPE.BOTH, animSheet: new ig.AnimationSheet('media/tileset.png', 32, 32), zIndex: 1, init: function(x, y, settings) { this.parent(x, y, settings); this.addAnim('idle', 1, [9]); } }) } )
BOXMOVABLE: ACTIVE ENTITY
ig.module( 'game.entities.boxmovable' ) .requires( 'impact.entity' ) .defines(function() { EntityBoxmovable = ig.Entity.extend({ size: { x: 32, y: 32 }, name: "Boxmovable", friction: { x: 999, y: 999 }, collides: ig.Entity.COLLIDES.ACTIVE, type: ig.Entity.TYPE.B, checkAgainst: ig.Entity.TYPE.B, animSheet: new ig.AnimationSheet('media/tileset.png', 32, 32), zIndex: 1, init: function(x, y, settings) { this.parent(x, y, settings); this.addAnim('idle', 1, [4]) } }) })
PLAYER: PASSIVE ENTITY
ig.module('game.entities.player1') .requires( 'impact.entity' ) .defines(function() { EntityPlayer1 = ig.Entity.extend({ collides: ig.Entity.COLLIDES.PASSIVE, type: ig.Entity.TYPE.A, checkAgainst: ig.Entity.TYPE.NONE, health: 3, maxHealth: 3, size: { x: 25, y: 25 }, offset: { x: 8, y: 8 }, maxVel: { x: 900, y: 900 }, name: "Player1", velocity: 300, zIndex: 9, lastpressed: 'up', flag: false, idleposition: 0, cooling: 1, projectiles: 5, maxProjectiles: 5, animSheet: new ig.AnimationSheet('media/Player_a.png', 32, 32), init: function(x, y, settings) { this.parent(x, y, settings); // Add the animations this.addAnim('idle', 1, [0]); this.addAnim('down', 1, [1]); this.addAnim('left', 1, [3]); this.addAnim('right', 1, [2]); this.addAnim('up', 1, [0]); }, restoreHealth: function() { this.health = 3; }, update: function() { //player movement if (ig.input.state('up')) { this.vel.y = -this.velocity; this.currentAnim = this.anims.up; this.lastpressed = 'up'; this.idleposition = 0; this.addAnim('idle', 1, [this.idleposition]); } else if (ig.input.state('down')) { this.vel.y = this.velocity; this.currentAnim = this.anims.down; this.lastpressed = 'down'; this.idleposition = 1; this.addAnim('idle', 1, [this.idleposition]); } else if (ig.input.state('left')) { this.vel.x = -this.velocity; this.currentAnim = this.anims.left; this.lastpressed = 'left'; this.idleposition = 3; this.addAnim('idle', 1, [this.idleposition]); } else if (ig.input.state('right')) { this.vel.x = this.velocity; this.currentAnim = this.anims.right; this.lastpressed = 'right'; this.idleposition = 2; this.addAnim('idle', 1, [this.idleposition]); } else { this.vel.y = 0; this.vel.x = 0; this.currentAnim = this.anims.idle; } if (ig.input.pressed('attack')) { if (this.cooling > 0 && this.projectiles > 0) { ig.game.spawnEntity('EntityProjectile1', this.pos.x + 13, this.pos.y + 13, { direction: this.lastpressed }); this.cooling--; this.substractProjectile(); } } if (this.flag == true) { this.addAnim('idle', 1, [this.idleposition + 4]); this.addAnim('down', 1, [this.idleposition + 4]); this.addAnim('left', 1, [this.idleposition + 4]); this.addAnim('right', 1, [this.idleposition + 4]); this.addAnim('up', 1, [this.idleposition + 4]); } else { this.addAnim('idle', 1, [this.idleposition]); this.addAnim('down', 1, [this.idleposition]); this.addAnim('left', 1, [this.idleposition]); this.addAnim('right', 1, [this.idleposition]); this.addAnim('up', 1, [this.idleposition]); } this.parent(); } }); });