Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

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:
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();
	}
});

});

1 decade ago by barthak

I fixed the issue above by checking against the collisionMap manually in the collideWith method.

Now I came across the following issue, which I hope is easily resolvable with the Collision of entities.

In the game the player can push the Block entities from the above example to another "tile" on the grid. However, if the target tile has another Block entity (or enemy) on it I want to prevent the block from being pushed to the target tile.

What is the best approach to handle a situation like that?

You can check the current game progress here, just start pushing the sad red blocks around and you can see (and hear) the issue.
Page 1 of 1
« first « previous next › last »