Okay guys I still have a tiny problem, and I posted the whole code so you can run it. The sprite rotates every 100 milliseconds however, sometimes it waits longer than 100 millisecs to rotate (i.e. 200 millis). What seems to be the problem?
The last if statements in the while loop is what does the calculation.
// Dark GDK - The Game Creators - www.thegamecreators.com
// the wizard has created a very simple project that uses Dark GDK
// it contains the basic code for a GDK application
// whenever using Dark GDK you must ensure you include the header file
#include "DarkGDK.h"
#include <stdlib.h>
#include <math.h>
#include <time.h>
void wait ( int seconds );
void setSpriteDragPoint(int Sprite1ID, int Sprite2ID, int Sprite1Angle1);
void setSpriteSpinPoint(int Sprite1ID, int Sprite1Angle1, int SpinDir);
// the main entry point for the application is this function
void DarkGDK ( void )
{
// turn on sync rate and set maximum rate to 60 fps
dbSyncOn ( );
dbSyncRate ( 60 );
dbLoadImage("fig.png", 1);
dbLoadImage("dot.png", 2);
dbLoadImage("ground.png", 3);
dbSprite(1, 100, 50, 1);
dbSetSpritePriority (1, 1);
dbSprite(2, dbSpriteX(1), dbSpriteY(1), 2);
dbSetSpritePriority (2, 2);
dbSprite(3, 0, 240, 3);
dbStretchSprite (3, 107, 100) ;
//dbSprite(3, 100, 200, 1);
//dbSprite(4, 200, 200, 1);
float angle1 = 0;
int time1 = 1000, time2;
// our main loop
while ( LoopGDK ( ) )
{
time2 = clock();
x = dbSpriteX(1);
y = dbSpriteY(1);
dbText(200, 75, itoa(time2%100, text, 10));
dbText(200, 150, itoa(time2, text, 10));
dbSprite(1, x, y = y + 1, 1);
//collision with ground
if(dbSpriteY(1) + dbSpriteWidth(1) == dbSpriteY(3))
{
dbSprite(1, x, y = y - 1, 1);
}
// input
if(dbRightKey() == 1)
{
dbSprite(1, x+=1, y, 1);
}
//////////////////////////////////////////
if(time2 % 100 == 0)
dbRotateSprite(1, angle1+=90);
//////////////////////////////////////////
// update the screen
dbSync ( );
}
// return back to windows
return;
}