I have been working on a Dark GDK project in which I make a sprite face the cursor or mouse's location. I picked up on some code and implemented it into my application but it seems to not be working correction. Here is a preview, http://gyazo.com/bf57df49071e3a684a7e03b8f0cf4527, as you can see, the sprite is not facing the right place where the cursor is and it does not move correctly. I believe this is because Dark GDK doesn't know where the center of my object is. Can anyone help me understand what I am doing wrong? I changed the values of the rotation and rotated the sprite but that didn't help at all.
// 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"
// 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("hero.png", 1);
dbSprite(1,100,100,1);
dbOffsetSprite(1,21,29);
// our main loop
while ( LoopGDK ( ) )
{
dbRotateSprite(1, 30);
float dx = dbMouseX() - dbSpriteX(1);
float dy = dbMouseY() - dbSpriteY(1);
dbRotateSprite(1,dbAtanFull(dy,dx));
if(dbEscapeKey() == 1)
{
break;
}
dbSync ( );
}
dbDeleteImage(1);
dbDeleteSprite(1);
// return back to windows
return;
}