So, with this code, I have no problem, the "tank" rotates perfectly as I press left and right buttons.
#include "DarkGDK.h"
void PointSprite ( int spriteID, int x, int y )
{
float ANGLE;
int DX = x - dbSpriteX( spriteID );
int DY = y - dbSpriteY( spriteID );
int DIST = (DX * DX) + (DY * DY);
if( DIST > 0 )
{
ANGLE = dbAtanFull ( x - dbSpriteX( spriteID ), dbSpriteY( spriteID ) - y );
dbRotateSprite( spriteID , ANGLE );
}
}
void DarkGDK ( void )
{
dbSyncOn ( );
dbSyncRate ( 60 );
dbDisableEscapeKey ( );
dbRandomize ( dbTimer ( ) );
/////////////////////////////
dbLoadImage("tank.bmp",1);
dbLoadImage("background.bmp",2);
dbLoadImage("turret.bmp",3);
dbLoadImage("wall.bmp",4);
dbLoadImage("tankshot.bmp",5);
/////////////////////////////
dbSprite(1,320,240,1);//tank
dbOffsetSprite(1,20,32.5);//allows for even turning
int tankangle=0;
dbSprite(3,100,100,4);
while ( LoopGDK ( ) )
{
dbSprite(2,dbSpriteX(1),dbSpriteY(1),3);//turret
dbOffsetSprite(2,5,30);
PointSprite(2,dbMouseX(),dbMouseY());//turret aiming
dbPasteImage(2,0,0);
dbRotateSprite(1,tankangle);
if(dbRightKey()==1)
tankangle+=3;
if(dbLeftKey()==1)
tankangle-=3;
if(dbUpKey()==1)
dbMoveSprite(1,2);
if(dbDownKey()==1)
dbMoveSprite(1,-2);
if(dbMouseClick()==1 && dbSpriteExist(4)==0)
{
dbSprite(4,dbSpriteX(2),dbSpriteY(2),5);
PointSprite(4,dbMouseX(),dbMouseY());
}
if(dbSpriteExist(4)==1)
{
dbMoveSprite(4,6);
}
if ( dbEscapeKey ( ) )
break;
dbSync ( );
}
return;
}
But when I add this to the end:
if(dbSpriteCollision(3,4)==1)
{
dbDeleteSprite(4);
}
The tank no longer rotates.
I really can't find the problem, perhaps it is blindingly obvious...
OH, and the PointSprite function isn't mine..I've forgotten who I copied it from
herp derp