Hi, I’m sorta new to the whole Dark GDK. I’m having trouble with my game making the characters jump. I can move them left and right but making a smooth jump without stopping the game is becoming a problem. Any help or tips would be greatly appreciated.
enum mov {UP, DOWN, LEFT, RIGHT};
class Entity
{
public:
Entity(int id, int x, int y);
~Entity();
void initEntity(char* name);
void EntityMove(int direction);
void dropBomb();
int getPlayX() { return playX; }
int getPlayY() { return playY; }
private:
int pHealth;
int pMana;
int pEnergy;
int playX;
int playY;
int playID;
};
void Entity::EntityMove(int direction)
{
if(playX <= 0)
playX++;
if(playX >= MAP_WIDTH - 100)
playX--;
if(playY <= 0)
playY++;
if(playY >=MAP_HEIGHT - 125)
playY--;
//UP
if(direction == UP)
{
//NOT WHAT I WANT
/*playY--;
dbPlaySprite ( playID, 2, 1, 60 );
dbSprite ( playID, playX, playY, playID );*/
}
//DOWN
if(direction == DOWN)
{
playY++;
dbPlaySprite ( playID, 1, 1, 60 );
dbSprite ( playID, playX, playY, playID );
}
//LEFT
if(direction == LEFT)
{
playX--;
dbPlaySprite ( playID, 11, 20, 60 );
dbSprite ( playID, playX, playY, playID );
}
//RIGHT
if(direction == RIGHT)
{
playX++;
dbPlaySprite ( playID, 1, 10, 60 );
dbSprite ( playID, playX, playY, playID );
}
}
In MAIN, getting input from wireless controller
if(sP1->GetState().Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_UP)
p1.EntityMove(UP);
if(sP1->GetState().Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_DOWN)
p1.EntityMove(DOWN);
if(sP1->GetState().Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_LEFT)
p1.EntityMove(LEFT);
if(sP1->GetState().Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_RIGHT)
p1.EntityMove(RIGHT);