1 decade ago by Joncom
I want to modify the way in which a player moves over one-way tiles (you know, the collision tiles in Weltmeister with arrows on them).
Currently I use the following function to see if my player is allowed to move immediately left/right/up/down:
The above works great, but it doesn't tell me if I can move because I'm passing through a regular walkable tile, or a special one-way tile. I'd very much like to know when I'm passing or about to pass through a one way tile.
Thanks.
Currently I use the following function to see if my player is allowed to move immediately left/right/up/down:
var canMove = function(player) // returns true if no collision will occur // in the direction the player faces { var vx = 0; var vy = 0; switch(player.facing) { case 'left': vx = -1; break; case 'right': vx = 1; break; case 'up': vy = -1; break; case 'down': vy = 1; break; } // check map collisions var res = ig.game.collisionMap.trace( player.pos.x, player.pos.y, vx, vy, player.size.x, player.size.y ); if(res.collision.x || res.collision.y) return false; return true; // no collisions };
The above works great, but it doesn't tell me if I can move because I'm passing through a regular walkable tile, or a special one-way tile. I'd very much like to know when I'm passing or about to pass through a one way tile.
Thanks.