P
PlazmaNitro
Guest
I am attempting to use 8 different sprites for 4 different directions (WASD). I have idling sprites for each direction, as well as walking animation sprites. This is for a top down 2.5 d view, like Link to the Past on the SNES.
When the game is launched, the sprite assumes the "Down" idling position (facing the screen), which is great.
Pushing W, A, S, or D will initiate movement and the correct walking animation for the respective directions. My issue is that upon releasing all movement keys, the sprite will again assume the "Down" idling position again, regardless of the position it was facing when moving.
How do I get it to use the right position for stopping rightwards motion, left for leftwards, etc.?
Here is the code currently in use (yes playerdirection is defined in the creation event, it says playerdirection = 1 or 2 or 3 or 4:
//Sprite Control
if (keyboard_check(ord('A'))) { sprite_index = Spr_Left } {image_speed = 0.25;} {playerdirection = 1;}
if (keyboard_check(ord('W'))) { sprite_index = Spr_Up } {image_speed = 0.25;} {playerdirection = 2;}
if (keyboard_check(ord('D'))) { sprite_index = Spr_Right } {image_speed = 0.25;} {playerdirection = 3;}
if (keyboard_check(ord('S'))) { sprite_index = Spr_Down } {image_speed = 0.25;} {playerdirection = 4;}
if !(keyboard_check(ord('A'))) and !(keyboard_check(ord('W'))) and !(keyboard_check(ord('D'))) and !(keyboard_check(ord('S'))) and (playerdirection = 1) {sprite_index = Spr_Resting_Left}
if !(keyboard_check(ord('A'))) and !(keyboard_check(ord('W'))) and !(keyboard_check(ord('D'))) and !(keyboard_check(ord('S'))) and (playerdirection = 2) {sprite_index = Spr_Resting_Up}
if !(keyboard_check(ord('A'))) and !(keyboard_check(ord('W'))) and !(keyboard_check(ord('D'))) and !(keyboard_check(ord('S'))) and (playerdirection = 3) {sprite_index = Spr_Resting_Right}
if !(keyboard_check(ord('A'))) and !(keyboard_check(ord('W'))) and !(keyboard_check(ord('D'))) and !(keyboard_check(ord('S'))) and (playerdirection = 4) {sprite_index = Spr_Resting_Down}
When the game is launched, the sprite assumes the "Down" idling position (facing the screen), which is great.
Pushing W, A, S, or D will initiate movement and the correct walking animation for the respective directions. My issue is that upon releasing all movement keys, the sprite will again assume the "Down" idling position again, regardless of the position it was facing when moving.
How do I get it to use the right position for stopping rightwards motion, left for leftwards, etc.?
Here is the code currently in use (yes playerdirection is defined in the creation event, it says playerdirection = 1 or 2 or 3 or 4:
//Sprite Control
if (keyboard_check(ord('A'))) { sprite_index = Spr_Left } {image_speed = 0.25;} {playerdirection = 1;}
if (keyboard_check(ord('W'))) { sprite_index = Spr_Up } {image_speed = 0.25;} {playerdirection = 2;}
if (keyboard_check(ord('D'))) { sprite_index = Spr_Right } {image_speed = 0.25;} {playerdirection = 3;}
if (keyboard_check(ord('S'))) { sprite_index = Spr_Down } {image_speed = 0.25;} {playerdirection = 4;}
if !(keyboard_check(ord('A'))) and !(keyboard_check(ord('W'))) and !(keyboard_check(ord('D'))) and !(keyboard_check(ord('S'))) and (playerdirection = 1) {sprite_index = Spr_Resting_Left}
if !(keyboard_check(ord('A'))) and !(keyboard_check(ord('W'))) and !(keyboard_check(ord('D'))) and !(keyboard_check(ord('S'))) and (playerdirection = 2) {sprite_index = Spr_Resting_Up}
if !(keyboard_check(ord('A'))) and !(keyboard_check(ord('W'))) and !(keyboard_check(ord('D'))) and !(keyboard_check(ord('S'))) and (playerdirection = 3) {sprite_index = Spr_Resting_Right}
if !(keyboard_check(ord('A'))) and !(keyboard_check(ord('W'))) and !(keyboard_check(ord('D'))) and !(keyboard_check(ord('S'))) and (playerdirection = 4) {sprite_index = Spr_Resting_Down}