I was wondering since i started to use dark GDK i could not synchronize my sprited archer with its arrow. The archer just played its sprites while the arrow keeps going from left to right. Could anyone help me wherein when the archer will set the string of his bow free the arrow will then fly out from his bow? I will really appreciate it.
Here is my code:
#include "DarkGDK.h"
void DarkGDK ( void )
{
dbSyncOn ( );
dbSyncRate ( 60 );
dbSetDisplayMode(1024, 768, 32);
dbMaximizeWindow();
dbCreateAnimatedSprite(1, "archersprite.png", 2, 2, 1);
dbSprite (1, 70, 122, 1);
dbLoadImage ("arrow.png", 2);
bool bShot = false;
int iArrow = 0;
// our main loop
while ( LoopGDK ( ) )
{
dbPlaySprite(1, 1, 4, 180 );
if(bShot == false)
{
iArrow = dbSpriteX(1) + 35;
dbSprite (2, iArrow, dbSpriteY(1)+70, 2);
dbSetSpritePriority(2, 1);
bShot = true;
}
if(bShot)
{
iArrow += 8;
dbSprite(2, iArrow, dbSpriteY(2), 2);
if(iArrow > 800)
{
dbDeleteSprite(2);
bShot = false;
}
}
dbSync ( );
}
return;
}
Thanks in advance!