From 0019625770f7c1f4747fa8a28571992e3f8bcaca Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Wed, 21 Aug 2024 13:47:32 +0200 Subject: [PATCH] =?UTF-8?q?millorat=20el=20rebot=20dalt=20arreglada=20la?= =?UTF-8?q?=20repetici=C3=B3=20de=20la=20tecla=20space?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/ball.cpp | 8 +++++--- source/main.cpp | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/source/ball.cpp b/source/ball.cpp index 66372e8..61d9cdc 100644 --- a/source/ball.cpp +++ b/source/ball.cpp @@ -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; diff --git a/source/main.cpp b/source/main.cpp index b8ab0df..29e8bec 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -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) {