Youre only 'moving' it while it doesn't exist.
if(dbSpriteExist(SpriteNumber) == 0)//this check if it doesn't exist.
{
dbSprite(SpriteNumber, LocationX, LocationY, SpriteNumber);
}
else
{
if(dbKeyState(KeyD) == 0 && (dbKeyState(KeyA) == 0))
{
//and so on...
And this is extreme solution xD
class Character
{
public:
int LocationX;
int LocationY;
float Velocity;
int MaxVelocity;
int SpriteOrientation;
int SpriteNumber;
void Control();
};
void Character::Control()
{
if(!dbSpriteExist(SpriteNumber))
{
dbSprite(SpriteNumber, LocationX, LocationY, SpriteNumber);
}
if(dbKeyState(KeyD) == 0 && (dbKeyState(KeyA) == 0))
{
Velocity = 0;
}
if(dbKeyState(KeyD) == 1 && (dbKeyState(KeyA) == 1))
{
Velocity = 0;
}
if(dbKeyState(KeyA) == 1)
{
if(SpriteOrientation != 1)
{
dbMirrorSprite (2);
SpriteOrientation = 1;
}
LocationX = LocationX - 3 * Velocity;
if(Velocity < MaxVelocity)
{
Velocity = Velocity + .3;
}
}
if(dbKeyState(KeyD) == 1)
{
if(SpriteOrientation != 2)
{
dbMirrorSprite (2);
SpriteOrientation = 2;
}
LocationX = LocationX + 3 * Velocity;
if(Velocity < MaxVelocity)
{
Velocity = Velocity + .3;
}
}
dbSprite(SpriteNumber, LocationX, LocationY, SpriteNumber);
dbSync ( );
}
Theory-When you know everything,but nothing works.
Practice-When everything works,but you don't know why.
Programming merges these two-Nothing works,and you don't know why.