00:00
00:00

As: Rpg Movement

1,584 Views | 4 Replies
New Topic Respond to this Topic

As: Rpg Movement 2007-04-20 16:09:55


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!


BBS Signature

Response to As: Rpg Movement 2007-04-20 16:18:57


Pretty unreadable tutorial, the code itself is also very basic. If you want to help, help with something you can help with. As obvious as the sentance is, you can't help with AS, so don't.


BBS Signature

Response to As: Rpg Movement 2007-04-20 16:21:54


Yeah whats the point of posting an inefficient version that has gay limitations (eg rectangular walls) when others are more efficient and do not have the limitations?

Response to As: Rpg Movement 2007-04-20 16:25:01


er.... i havn't seen a tutorial on AS: main that allows curved walls....

and any walls they do have are made by using 4 movieclips per wall!!!


BBS Signature

Response to As: Rpg Movement 2007-06-09 23:20:23


At 4/20/07 04:25 PM, Hoeloe wrote: er.... i havn't seen a tutorial on AS: main that allows curved walls....

and any walls they do have are made by using 4 movieclips per wall!!!

Anyone that hasn't heard of a shapeflag shouldn't be writing tutorials.