PDA

View Full Version : Help with collision (and other things)


jayjay42
06-19-2008, 10:28 PM
Hey guys, im relatively new to actionscript but I catch on fairly quickly... and atm I am trying to do a sort of maze game, but don't really know the collision command.

I have seen lots of tutorials on it but none have really helped me much, so I have two questions for anyone out there who can help:

1. I can get the actionscript so that if you click the arrow keys the 'block' of mine will move in the correct direction, but how do i make it so it 'slides' rather then jumps? So if I click the left arrow key it will keep sliding to the left until it hits something, which will make it stop?

2. How would I make it so my 'block' when it collides with a 'wall' it will stop moving in the direction it is going?

If anyone can answer my questions it will be greatly appreciated! Thanks for listening!!!

JayJay42

Tivoilos
06-21-2008, 03:01 PM
Here is how I start out with this type of thing

//Map Array for Map 1
myMap1 = [[1, 1, 1, 1, 1, 1],
[ 1, 0, 0, 0, 1, 1],
[ 1, 1, 0, 0, 0, 1]
[ 1, 3, 1, 1, 1, 1]];
//Setting the number of currently used maps
game={tileW:30, tileH:30, currentMap:1}

//Allowing us to know what map we are on
buildMap(_root["myMap" + game.currentMap])

//the tile types
game.Doors = function (newmap, newcharx, newchary)
{
this.newmap = newmap;
this.newcharx = newcharx;
this.newchary = newchary;
};

game.Doors.prototype.walkable = true;
game.Doors.prototype.frame = 3;
game.Doors.prototype.door = true;
game.Tile2 = function () { };
game.Tile2.prototype = new game.Doors(2, 1, 4);
game.Tile3 = function () { };
game.Tile3.prototype = new game.Doors(1, 6, 4);

that should help a little bit