Sorry my last post was a little rushed, thus inaccurate.
The following is a better example of how to use the second move method.
int coordX = dbSpriteX(spriteID);
int coordY = dbSpriteY(spriteID);
int speedX;
// To move left and right
if (dbRightKey())
speedX = 4;
else if (dbLeftKey())
speedX = -4;
else
speed = 0;
coordX += speedX;
dbSprite(spriteID, coordX, coordY, imageID);
and if you wish to implement a jump feature just add two more variables.
int coordX = dbSpriteX(spriteID);
int coordY = dbSpriteY(spriteID);
int speedX;
int speedY;
int gravity = 2;
// to move left and right;
if (dbRightKey())
speedX = 4;
else if (dbLeftKey())
speedX = -4;
else
speedX = 0;
// To jump with space bar
if (dbSpaceKey())
speedY = -4;
else
speedY = 0;
coordX += speedX;
speedY += gravity;
coordY += speedY;
dbSprite(spriteID, coordX, coordY, imageID);
Haikus are easy; But sometimes they don’t make sense; Pteredactyl pie