1 decade ago by barthak
I've been working on a clone of an old MSX game I used to play: "Mopiranger".
I have the basics working, but I'm not sure about one issue, you can check a version here: http://labs.dalines.org/mopi/
The red blocks can be pushed for one tile (32x32) however if you push them against the Collision layer they are pushed over it. How do I prevent them from being pushed any further?
This is the code for the block:
I have the basics working, but I'm not sure about one issue, you can check a version here: http://labs.dalines.org/mopi/
The red blocks can be pushed for one tile (32x32) however if you push them against the Collision layer they are pushed over it. How do I prevent them from being pushed any further?
This is the code for the block:
ig.module( 'game.entities.block' ) .requires( 'impact.entity' ) .defines(function(){ EntityBlock = ig.Entity.extend({ size: {x: 32, y:32}, collides: ig.Entity.COLLIDES.FIXED, type: ig.Entity.TYPE.B, checkAgainst: ig.Entity.TYPE.BOTH, animSheet: new ig.AnimationSheet( 'media/block.png', 32, 32 ), init: function( x, y, settings ) { this.parent( x, y, settings ); // Add the animations this.addAnim( 'idle', 1, [0] ); }, collideWith : function ( other, axis ) { if(other instanceof EntityPlayer) { if(other.pos[axis] < this.pos[axis]) { this.pos[axis] += 32; } else if(other.pos[axis] > this.pos[axis]) { this.pos[axis] -= 32; } } else if(other instanceof EntityBigrazzon) { other._startTimer = new ig.Timer(1); // Pause the Razzon movement for a second. this.kill(); } }, update: function() { this.parent(); } }); });