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

View File

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