I'm just trying to make a simple sprite move from Right to Left while playing an animation but I keep encountering to problems.
First, lets say my sprite is moving right and I reverse direction my sprite moves left fine but keeps facing right. Eventually it faces left and walks fine but the delay looks really weird and makes the sprite look like its moonwalking.
Secondly, I can't seem to get dbPlaySprite() to play the entire animation on command instead it just plays one frame. I got around this by calling dbPlaySprite() again outside of the "dbKey() if check" but calling the function twice seems redundant.
so if anyone could help that would be great, here is my code...
#include "DarkGDK.h"
void DarkGDK ( void )
{
dbSyncOn ( );
dbSyncRate ( 60 );
dbDisableEscapeKey ( );
dbSetImageColorKey ( 255, 0, 255 );
dbCreateAnimatedSprite(1,"player.bmp",3,4,1);
dbSprite(1,100,100,1);
dbSizeSprite(1,50,50);
while ( LoopGDK ( ) )
{
if (dbRightKey())
{
dbPlaySprite(1,7,9,60);
dbRotateSprite(1,90);
dbMoveSprite(1,3);
dbRotateSprite(1,0);
}
if (dbSpriteFrame(1) > 7 && dbSpriteFrame(1) < 10)
dbPlaySprite(1,7,9,60);
if (dbLeftKey())
{
dbPlaySprite(1,4,6,60);
dbRotateSprite(1,270);
dbMoveSprite(1,3);
dbRotateSprite(1,0);
}
if (dbSpriteFrame(1) > 4 && dbSpriteFrame(1) < 7)
dbPlaySprite(1,4,6,60);
if ( dbEscapeKey ( ) )
break;
dbSync ( );
}
return;
}
Oh and here is the image i'm using, i dont know how to post it so i'll add it as an attachment