|
Post by differentialgiraffe on Jul 10, 2024 9:32:56 GMT
There is a bug in my game that if you stop walking or landed on the ground, it won't display the standing sprite. Can you fix this?
|
|
mas
Endorian Forest
Posts: 60
|
Post by mas on Jul 10, 2024 12:34:40 GMT
In this case, I'll assume you have a standing (facing left) and a standing (facing right) sprite. I would use a temporary variable to track each of the conditions. If at the end of them all, the variable isn't set, then I would swap the left or right standing sprite for the player and exit.
In my current game, I have to do something similar as I have set 8 sprites for up, down, left, right and the diagonal combinations. I have to check each key in turn and record which keys are pressed together; and try to ignore opposing keypresses.
I'll repurpose a little of this:
EVENT PLAYER
;; key codes for checking ; 0 = no key ; 1 = left ; 2 = right ;; not a key, but will check airborne to ; 4 = airborne detected
LET OPT = 0 ; temp variable 0 = unset IF KEY RIGHT ADD 2 TO OPT ENDIF IF KEY LEFT ADD 1 TO OPT ENDIF
IF AIRBORNE <> 0 ADD 4 TO OPT ENDIF
IF OPT = 1 ; left key only LET IMAGE = 3 ; left image ENDIF IF OPT = 2 ; right key only LET IMAGE = 2 ; right image ENDIF IF OPT = 3 ; left and right keys LET OPT = 0 ; left and right pressed together goes nowhere ENDIF IF OPT = 4 ; airborne LET IMAGE = 0 ; airborne image ENDIF IF OPT <> 0 ; we are moving, we'll animate the image - only do it here or it advances too many frames ANIMATE SLOW ELSE ;; in this case, we are not moving or falling or rolling around etc. LET IMAGE = {your standing image, possibly checking direction to face the correct way} ENDIF
Hope that helps or gives you an idea of how you might approach it.
|
|