i found code for arcade style (arrow keys) movement and i think it was from an old version
i had to rework some of the code i found and i got some help from the help file, but it still giving me a "(" error and ive checked all the counting of ( and {
i hope its not some dumb fix so I don't feel stupid but if anyone could help me out would be great
btw its in the function on_key_press(int keycode) in the global script
if (keycode==372) { // up arrow
character[EGO].WalkStraight(player.x, player.y-200);
while ((IsKeyPressed(372)>0) && (character[EGO].WalkStraight)) Wait(1);
StopMoving(EGO);
}
if (keycode==375) { // left arrow
character[EGO].WalkStraight(player.x, player.x-200, player.y);
while ((IsKeyPressed(375)>0) && (character[EGO].WalkStraight)) Wait(1);
StopMoving(EGO);
}
if (keycode==377) { // right arrow
character[EGO].WalkStraight(player.x, player.x+200, player.y);
while ((IsKeyPressed(377)>0) && (character[EGO].WalkStraight)) Wait(1);
StopMoving(EGO);
}
if (keycode==380) { // down arrow
character[EGO].WalkStraight(player.x, player.x, player.y+200);
while ((IsKeyPressed(380)>0) && (character[EGO].WalkStraight)) Wait(1);
StopMoving(EGO);
}
thanks alot guys/gals in advance :)
The problem is that you're using Character.WalkStraight as if it was a boolean. Instead of:
while ((IsKeyPressed(375)>0) && (character[EGO].WalkStraight)) Wait(1);
You should be using:
while ((IsKeyPressed(375)>0) && (character[EGO].Moving)) Wait(1);
Let me know if it works. I think there might be dodgy stuff going on in other parts of the code too. In my opinion some of it should be moved from IsKeyPressed to repeatedly_execute. Could you possibly link to the code you found, it would make it easier to see how you came up with this?
this is what i have now and it still giving me an error '(' expected, and i have no idea what is wrong... someone please help :)
if (keycode==372) { // up arrow
character[EGO].WalkStraight(player.x, player.y-200);
while ((IsKeyPressed(375)>0) && (character[EGO].Moving)) Wait(1);
character[EGO].StopMoving;
}
if (keycode==375) { // left arrow
character[EGO].WalkStraight(player.x, player.x-200, player.y);
while ((IsKeyPressed(375)>0) && (character[EGO].Moving)) Wait(1);
character[EGO].StopMoving;
}
if (keycode==377) { // right arrow
character[EGO].WalkStraight(player.x, player.x+200, player.y);
while ((IsKeyPressed(375)>0) && (character[EGO].Moving)) Wait(1);
character[EGO].StopMoving;
}
if (keycode==380) { // down arrow
character[EGO].WalkStraight(player.x, player.x, player.y+200);
while ((IsKeyPressed(375)>0) && (character[EGO].Moving)) Wait(1);
character[EGO].StopMoving;
}
Character.StopMoving() is a function, so you need the parenthesis when you call it (even though there are no paramaters).
if (keycode==372) { // up arrow
character[EGO].WalkStraight(player.x, player.y-200);
while ((IsKeyPressed(375)>0) && (character[EGO].Moving)) Wait(1);
character[EGO].StopMoving();
}
if (keycode==375) { // left arrow
character[EGO].WalkStraight(player.x, player.x-200, player.y);
while ((IsKeyPressed(375)>0) && (character[EGO].Moving)) Wait(1);
character[EGO].StopMoving();
}
if (keycode==377) { // right arrow
character[EGO].WalkStraight(player.x, player.x+200, player.y);
while ((IsKeyPressed(375)>0) && (character[EGO].Moving)) Wait(1);
character[EGO].StopMoving();
}
if (keycode==380) { // down arrow
character[EGO].WalkStraight(player.x, player.x, player.y+200);
while ((IsKeyPressed(375)>0) && (character[EGO].Moving)) Wait(1);
character[EGO].StopMoving();
}
that helped but now only walking left works.... any idea why???
if (keycode==372) { // up arrow
character[EGO].WalkStraight(player.x, player.y-200,eNoBlock);
while ((IsKeyPressed(375)>0) && (character[EGO].Moving)) Wait(1);
character[EGO].StopMoving();
}
if (keycode==375) { // left arrow
character[EGO].WalkStraight(player.x-200, player.y,eNoBlock);
while ((IsKeyPressed(375)>0) && (character[EGO].Moving)) Wait(1);
character[EGO].StopMoving();
}
if (keycode==377) { // right arrow
character[EGO].WalkStraight(player.x+200, player.y,eNoBlock);
while ((IsKeyPressed(375)>0) && (character[EGO].Moving)) Wait(1);
character[EGO].StopMoving();
}
if (keycode==380) { // down arrow
character[EGO].WalkStraight(player.x, player.y+200,eNoBlock);
while ((IsKeyPressed(375)>0) && (character[EGO].Moving)) Wait(1);
character[EGO].StopMoving();
}
I can't test the code right now, but it looks like the error is in your while loop. You have each of them set as
while ((IsKeyPressed(375)>0) && (character[EGO].Moving)) Wait(1);
Where as you need to have the correct ASCII code for each loop (e.g, the up arrow should be)
while ((IsKeyPressed(372)>0) && (character[EGO].Moving)) Wait(1);