Hi, I'm new at programming & I hope someone can help me solve this problem. I'm going to try to make it as clear as possible.
I have a character and I have created two animated sprites of that character. One facing & walking right, and the other facing & walking left.
I have written some code so that when I hold down the rightkey() to make the sprite walk right, it does so with no problem. However, I when hold down the leftkey() to turn it around and make it walk left - I end up with two sprites on the screen. One of them standing still facing right, while the other is facing(& walking) left. Conversely when I try to turn the sprite around to walk right again - I end up with one sprite standing still facing left, while the other is facing (& walking) right.
I would like only the sprite that is currently walking to be on the screen, and I want the directional change to be instant.
I think some how I need to clear the sprite as I change direction. I have tried clearing the screen, hiding the sprite, deleting the sprite, flipping and mirroring the sprite. No luck.
I hope that was understandable. Any Suggestions would be appreciated.
GLOBAL BackGround AS WORD = 1
GLOBAL CharMove AS STRING
GLOBAL X AS INTEGER = 10
GLOBAL Y AS INTEGER = 75
SYNC ON
SYNC RATE 10
LOAD IMAGE "YellowBackground.bmp", BackGround
SET IMAGE COLORKEY 255, 255, 255
CREATE ANIMATED SPRITE 1, "delphineWR.png", 3, 1, 2
CREATE ANIMATED SPRITE 2, "delphineWL.png", 3, 1, 3
DO `Loop forever
PASTE IMAGE BackGround, 0, 0
IF leftkey()=1 then CharMove$ ="LEFT"
IF rightkey()=1 then CharMove$ ="RIGHT"
SELECT CharMove$ `Retrieve Character State
CASE "RIGHT": `If rightkey() is pressed
IF rightkey()=1
inc X
PLAY SPRITE 1, 1, 3, 170
sprite 1,X,Y,3
ENDIF
ENDCASE
CASE "LEFT": `If leftkey() is pressed
IF leftkey()=1
dec X
PLAY SPRITE 2, 1, 3, 170
sprite 2,X,Y,2
ENDIF
ENDCASE
ENDSELECT
SYNC
LOOP
Luke: "I don't believe it."
Yoda: "That is why you fail."