Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

2D All the way! / Change of Direction Help, I Keep Moonwalking

The Rusty Programmer
Years of Service
User Offline
Joined: 10th May 2010
Posted: 11th May 2010 04:27
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...

Oh and here is the image i'm using, i dont know how to post it so i'll add it as an attachment


Login to view attachments
Years of Service
User Offline
Joined: 5th Aug 2010
Location: Manchester, UK
Posted: 10th Aug 2010 09:46
hey there
I had this problem, and it was given to me, that I need to check the sprite number durring direction change, then if its a number thats not needed, set it to another one,

its in DBPro, so I hope there is something similar in GDK.

Years of Service
User Offline
Joined: 28th Jan 2004
Posted: 10th Aug 2010 22:54
Not done a lot in DarkGDK really, just messed about doing a few speed test comparisons with DB. But looking at your code would it not be better to simply mirror the sprite rather than rotating? Also, don't put in your sprite code when you press a key just set a variable for direction and if it is walking. Then have some separate lines that position the sprite down and animate it according to those variables.
Years of Service
User Offline
Joined: 11th Aug 2010
Location: LU
Posted: 18th Oct 2010 17:23
I don't use movesprite and would suggest this.[#include "DarkGDK.h"

void DarkGDK ( void )
dbSyncOn ( );
dbSyncRate ( 60 );
dbDisableEscapeKey ( );
dbSetImageColorKey ( 255, 0, 255 );


while ( LoopGDK ( ) )

if (dbRightKey())
dbRotateSprite(1,90); dbSprite(1,dbSpriteX(1),dbSpriteY(1)+3,dbSpriteImage(1)):

if (dbSpriteFrame(1) > 7 && dbSpriteFrame(1) < 10)

if (dbLeftKey())
dbSprite(1,dbSpriteX(1),dbSpriteY(1)-3,dbSpriteImage(1)): dbRotateSprite(1,0);

if (dbSpriteFrame(1) > 4 && dbSpriteFrame(1) < 7)

if ( dbEscapeKey ( ) )

dbSync ( );



DBPro Master
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 19th Oct 2010 09:26
If playsprite in DGDK works the same as it does in DB then it will finish it's current animation sequence before moving on to the next. When you switch directions, set the sprite's frame to the beginning of that animation sequence.

"Any sufficiently advanced technology is indistinguishable from magic" ~ Arthur C. Clarke

Login to post a reply

Server time is: 2022-12-02 20:05:43
Your offset time is: 2022-12-02 20:05:43