Yes Ancient Lady and I back to get troubles with that!
First problems solved by Funnell7 but now I have another BIG problem:
My actual code:
// our main loop
do
rem LET'S KNOW WHAT KEY IS PRESSED
key_up=GetRawKeyState(38)
key_down=GetRawKeyState(40)
key_left=GetRawKeyState(37)
key_right=GetRawKeyState(39)
rem MOVING THE SPRITE IN XY
if key_up=1 ` Up arrow
mov_up = 1
SetSpritePosition ( spriteA, GetSpriteX ( spriteA ), GetSpriteY ( spriteA ) - 1)
else
mov_up = 0
endif
if key_down=1 ` Down
mov_down = 1
SetSpritePosition ( spriteA, GetSpriteX ( spriteA ), GetSpriteY ( spriteA ) + 1)
else
mov_down = 0
endif
if key_left=1`Left
mov_left = 1
SetSpritePosition ( spriteA, GetSpriteX ( spriteA ) - 1, GetSpriteY ( spriteA ) )
else
mov_left = 0
endif
if key_right=1`Right
mov_right = 1
SetSpritePosition ( spriteA, GetSpriteX ( spriteA ) + 1, GetSpriteY ( spriteA ) )
else
mov_right = 0
endif
rem ---------------------------------------------
IF mov_up = 1
if GetSpritePlaying(SpriteA) = 0
rem PlaySprite( iSpriteIndex, fFps, iLoop, iFromFrame, iToFrame )
PlaySprite ( spriteA, 10, 1, 13, 16 )
endif
ENDIF
IF mov_down = 1
if GetSpritePlaying(SpriteA) = 0
rem PlaySprite( iSpriteIndex, fFps, iLoop, iFromFrame, iToFrame )
PlaySprite ( spriteA, 10, 1, 1, 4 )
endif
ENDIF
IF mov_left = 1
if GetSpritePlaying(SpriteA) = 0
rem PlaySprite( iSpriteIndex, fFps, iLoop, iFromFrame, iToFrame )
PlaySprite ( spriteA, 10, 1, 5, 8 )
endif
ENDIF
IF mov_right = 1
if GetSpritePlaying(SpriteA) = 0
rem PlaySprite( iSpriteIndex, fFps, iLoop, iFromFrame, iToFrame )
PlaySprite ( spriteA, 10, 1, 9, 12 )
endif
ENDIF
rem ---------------------------------------------------
rem IF NOTHING MOVEMENT SO STOP ANIMATION
IF mov_up = 0 and mov_down = 0 and mov_left = 0 and mov_right = 0
StopSprite (spriteA)
ENDIF
// update the screen
Sync ( )
loop
So, you tell my code is continuing to reset.. yeah.. but I don't understand WHY!! and now I have this problem :
If you move the sprite in one direction and later you release the movement key so you obtain the right work.
BUT follow this example:
FIRST PROCEDURE (NOT WORKING GOOD)
1) you press up key and the sprite go up with up movements
2) while you pressing up key you press right too
3) you leave up key while you pressing right
4) while you pressing right you start to press down
5) you leave right key while you pressing down key
6) while you pressing down key you start to press left key
7) you leave down key while you pressing left key
8) while you pressing left key you start to press up key
IF you make this procedure you see that yes, the sprite moving in XY coords correctly but it cycling ONLY the UP MOVEMENT frames
But If you try to do the following you will get right result:
SECOND PROCEDURE (WORK GOOD)
1) you move up then stop (you can see the up frames and sprites going up)
2) you move right then stop (you can see the right frames and sprites going right)
3) you move down then stop (you can see the down frames and sprite going down)
4) you move left then stop (you can see the left frames and sprite going left)
Only in this way I obtain my frames right for the actual direction.
I tried ALL dudes to solve the first procedure
I know I am not a good programmer but DAMN! I can't to obtain that while I change direction so the new direction frames take the places of the old direction frames
Help :\
Ps: Attached the project folder, load collision2.cbp to start)