• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

About 8 direction movement sprites

C

Codec080

Guest
Hello, this is my first post here.

I am working on a zelda-like game and I need your help with my movement

I have a player object. I can make it move it 8 directions with no issues except the sprites. I want my player object to keep the sprite of the direction it is facing before it starts moving in diagonal. I have 4 animations for walking north, walking west, east and south. If I go up, THEN diagonally to up-left or up-right, I'd like my sprite to be the north one... but I want my sprite to be the east one if the player pressed right, THEN up instead of up first.

Any help would be appreciated, I'll post my code if you need it.

thanks
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
Yes, the released check may help... however I'd simply nest my "if" checks in such a way that only the sprite you want to use is used. For example:

Code:
if keyboard_check(vk_up)
{
sprite_index = up;
if keyboard_check(vk_right)
    {
    // Up right movement here
    }
else if keyboard_check(vk_left)
    {
    // Up left movement here
    }
else
    {
    // Up movement here
    }
}
else if keyboard_check(vk_left)
{
sprite_index = left;
// etc... for all movement
 
Top