millorat el rebot dalt

arreglada la repetició de la tecla space
This commit is contained in:
2024-08-21 13:47:32 +02:00
parent e5fb176ef6
commit 0019625770
2 changed files with 6 additions and 4 deletions

View File

@@ -67,7 +67,7 @@ void Ball::update()
{ {
y = 0; y = 0;
vy = -vy; vy = -vy;
vy = -vy * loss; //vy = -vy * loss;
} }
// Comprueba las colisiones con la parte inferior // Comprueba las colisiones con la parte inferior
@@ -90,7 +90,6 @@ void Ball::update()
{ {
vx = 0.0f; vx = 0.0f;
stopped = true; stopped = true;
// exit(0);
} }
} }
@@ -109,7 +108,10 @@ void Ball::render()
// Modifica la velocidad // Modifica la velocidad
void Ball::modVel(float vx, float vy) void Ball::modVel(float vx, float vy)
{ {
this->vx = this->vx + vx; if (stopped)
{
this->vx = this->vx + vx;
}
this->vy = this->vy + vy; this->vy = this->vy + vy;
onFloor = false; onFloor = false;
stopped = false; stopped = false;

View File

@@ -152,7 +152,7 @@ void checkEvents()
break; break;
} }
if (event->type == SDL_KEYDOWN) if (event->type == SDL_KEYDOWN && event->key.repeat == 0)
{ {
if (event->key.keysym.sym == SDLK_SPACE) if (event->key.keysym.sym == SDLK_SPACE)
{ {