
08-08-2011, 08:50 PM
|
|
Registered User
|
Join Date: Aug 2011
Posts: 83
|
|
simple movement help.
|
Hi forums. I am trying to make a simple movement system where i can move left and right. and that's it.
Ill show what i have but can some one please modify because it seems buggy and the movement is not as instant as the default one. Also, if someone could add the tile detection so he can't walk though walls that'd be great.
Please explain also, as I am trying to take not and learn.
//#CLIENTSIDE
function onCreated()
{
canmove = 1;
disabledefmovement;
}
function onKeyPressed(temp.code, temp.key, temp.scan)
{
if (canmove = 1)
{
if (keydown(3))
{
player.x +=0.3;
player.dir = 3;
setAni("walk", NULL);
setTimer(0.3);
} else if (keydown(1)){
player.x -=0.3;
player.dir = 1;
setAni("walk", NULL);
setTimer(0.3);
}
}
}
function onTimeOut()
{
setAni("idle", NULL);
} |
|
|
|