
08-08-2011, 09:26 PM
|
|
Registered User
|
Join Date: Aug 2011
Posts: 83
|
|
|
OK. So here is an update of the script. the colliding of walls does still not work. Im using onwall2 because i am using the "era" tile template. (not actually using those tiles, just the tile setup where they are) and also, there is a delay on the movement. you have to hold the key for a second for the movement to actually work.
//#CLIENTSIDE
function onCreated()
{
movePlayer();
this.canmove = 1;
disabledefmovement();
}
function onKeyPressed(temp.code, temp.key, temp.scan)
{
if (this.canmove == 1)
{
if (keydown(3))
{
player.x +=0.3;
player.dir = 3;
setAni("walk", NULL);
setTimer(0.5);
} else if (keydown(1)){
player.x -=0.3;
player.dir = 1;
setAni("walk", NULL);
setTimer(0.5);
}
}
}
function onTimeOut()
{
setAni("idle", NULL);
}
function movePlayer(){
temp.new_x = player.x +0.3;
temp.new_y = player.y;
if (!onwall2(temp.new_x, temp.new_y)) {
player.x = temp.new_x;
player.y = temp.new_y;
}
} |
|
|
|