Demo: añadida aleatoriedad a los rebotes del sprite
This commit is contained in:
BIN
data/sound.wav
BIN
data/sound.wav
Binary file not shown.
26
main.cpp
26
main.cpp
@@ -123,12 +123,34 @@ int main(int argc, char *argv[])
|
||||
// Actualiza el sprite
|
||||
if (sprite->getPosX() + sprite->getWidth() > options->gameWidth or sprite->getPosX() < 0)
|
||||
{
|
||||
sprite->setVelX(sprite->getVelX() * -1);
|
||||
sprite->undoMoveX();
|
||||
int spr_direction = 1;
|
||||
int spr_force = 1;
|
||||
if (sprite->getVelX() > 0)
|
||||
{
|
||||
spr_direction = -1;
|
||||
}
|
||||
if (SDL_GetTicks() % 2 == 0)
|
||||
{
|
||||
spr_force = 2;
|
||||
}
|
||||
sprite->setVelX(spr_force * spr_direction);
|
||||
JA_PlaySound(sound);
|
||||
}
|
||||
if (sprite->getPosY() + sprite->getHeight() > options->gameHeight or sprite->getPosY() < 0)
|
||||
{
|
||||
sprite->setVelY(sprite->getVelY() * -1);
|
||||
sprite->undoMoveY();
|
||||
int spr_direction = 1;
|
||||
int spr_force = 1;
|
||||
if (sprite->getVelY() > 0)
|
||||
{
|
||||
spr_direction = -1;
|
||||
}
|
||||
if (SDL_GetTicks() % 2 == 0)
|
||||
{
|
||||
spr_force = 2;
|
||||
}
|
||||
sprite->setVelY(spr_force * spr_direction);
|
||||
JA_PlaySound(sound);
|
||||
}
|
||||
sprite->update();
|
||||
|
||||
Reference in New Issue
Block a user