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 gxxaxx

For various reasons in my recent game there was a need to have the option of assigning more than one collision tile type.

0: neither A nor B collide with tile
1: both A and B collide with tile
2: A collides, B does not collide with tile
3: B collides, A does not collide with tile

I tried to find a way to handle this without poking in the collision-map.js

But, when I finally worked out a solution, it was simplest to just change a few lines of code in the collision-map.js file.

Was wondering if anyone found a more direct method that did not involve hacking the core code.

p.s. I would have liked to get specific feedback on the code changes, but without a members only area, I don't feel okay in exposing chunks of the core code to google search.

1 decade ago by quidmonkey

Check out .handleMovementTrace(res). res has the following properties:

var res = {
	collision: {x: false, y: false}, //true if collision along axis
	pos: {x: x, y: y}, //collision coordinates
	tile: {x: 0, y: 0} //collision tile coordinates
};

You could get the tile within handleMovementTrace(res) like this:

var tile = ig.game.collisionMap.getTile( res.pos.x, res.pos.y );
//or
var tile = ig.game.collisionMap.data[res.tile.y][res.tile.x];

You could then test the tile to see if it's a specific type and have your entity react to it.

1 decade ago by gxxaxx

This might work. If it does I could avoid junking around in core files.

Then, if necessary I would only need to extend the Entity class.

Hopefully much cleaner.

Thanks for the suggestion.
Page 1 of 1
« first « previous next › last »