Hello I'm new to this. I am using the DarkGDK to attempt to make a zelda clone. I have a code to make a sprite move but whenever i switch directions a sprite is left behind. Can anyone provide another to move my sprite or tell me what is causing the problem. Sorry if this isn't the right spot for this.
My code is:
if (dbUpKey ())
{
dbSetSpriteImage ( currentImage, WALKUP );
dbSprite ( WALKUP , iPlayerX , iPlayerY , WALKUP );
dbPlaySprite ( WALKUP, 1, 10, 100 );
iPlayerY -= 2;
Up = 1, Down = 0, Left = 0, Right = 0;
currentImage = WALKUP;
}
if (dbDownKey ())
{
dbSetSpriteImage ( currentImage, WALKDOWN ) ;
dbSprite ( WALKDOWN , iPlayerX , iPlayerY , WALKDOWN );
dbPlaySprite ( WALKDOWN, 1, 10, 100 );
iPlayerY += 2;
Up = 0, Down = 1, Left = 0, Right = 0;
currentImage = WALKDOWN;
}
if (dbKeyState ( 203 ) )
{
if (dbSpriteMirrored (WALKSIDE))
dbMirrorSprite ( WALKSIDE );
dbSetSpriteImage ( currentImage, WALKSIDE ) ;
dbSprite ( WALKSIDE , iPlayerX , iPlayerY , WALKSIDE );
dbPlaySprite ( WALKSIDE, 1, 10, 100 );
iPlayerX -= 2;
Up = 0, Down = 0, Left = 1, Right = 0;
currentImage = WALKSIDE;
}
if (dbKeyState ( 205 ) )
{
if (!dbSpriteMirrored (WALKSIDE))
dbMirrorSprite ( WALKSIDE );
dbSetSpriteImage ( currentImage, WALKSIDE ) ;
dbSprite ( WALKSIDE , iPlayerX , iPlayerY , WALKSIDE );
dbPlaySprite ( WALKSIDE, 1, 10, 100 );
iPlayerX += 2;
Up = 0, Down = 0, Left = 0, Right = 1;
currentImage = WALKSIDE;
}
Here is the picture in game: