AS MAIN PWNZ YOUR ARSE
Ok, this will probably have been done many times before, but i managed to develop my own script which is much simpler than most peoples, it will only allow 4 way movement though ¬-¬
start by making a movie clip which is a circle, give it the instance name: player
now, put this script on player:
//Script developed my Hoeloe
onClipEvent(load){
spd = 8;
//sets the player's speed
dir = 0;
//sets a variable called dir to 0
}
onClipEvent(enterFrame){
if(Key.isDown(Key.DOWN)){
this._y += spd;
//player moves down by spd
dir = 0;
//dir is 0;
}else if(Key.isDown(Key.LEFT)){
this._x -= spd;
//player moves left by spd
dir = 1;
//dir is 1
}else if(Key.isDown(Key.UP)){
this._y -= spd;
//player moves up by spd
dir = 2;
//dir is 2
}else if(Key.isDown(Key.RIGHT)){
this._x += spd;
//player moves right by spd
dir = 3;
//dir is 3
}
}
now for the walls. These MUST be rectangular or square or they wont work properly. Each wall must be a seperate rectange, and each should have this script:
//Script developed by Hoeloe
onClipEvent(enterFrame){
if(this.hitTest(_root.player)){
//if the wall is touching player
if(_root.player.dir == 0){
//if the player is facing down
_root.player._y += _root.player.spd
//player moves up by spd
}if(_root.player.dir == 1){
//if the player is facing left
_root.player._x += _root.player.spd
//player moves right by spd
}if(_root.player.dir == 2){
//if the player is facing up
_root.player._y -= _root.player.spd
//player moves down by spd
}if(_root.player.dir == 3){
//if the player is facing right
_root.player._x -= _root.player.spd
//player moves left by spd
}
}
}
Well, Thats all folks!
hope it's helpful!