Relative movement help

Started by Glenjamin, Sat 04/04/2015 00:05:31

Previous topic - Next topic

Glenjamin

I'm trying to make a game where if you use the "move" verb on the player, he'll sidestep to the right or left. I cant use "player.walk" because it uses coordinates of the room, not coordinates relative to the character. How can I do this?

monkey0506

If you need coordinates relative to the player, why not just use the player's coordinates?

Code: ags
player.Walk(player.x + 5, player.y); // sidestep to the right by 5 px
player.Walk(player.x - 5, player.y); // sidestep to the left by 5 px
player.Walk(player.x, player.y + 5); // step toward the bottom of the screen by 5 px
player.Walk(player.x, player.y - 5); // step toward the top of the screen by 5 px

Glenjamin

Clever, I didn't think of that. Thank you!

SMF spam blocked by CleanTalk