diff --git a/.gitignore b/.gitignore index 4548ab6..c5a7165 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /cong +/cong.exe diff --git a/cong.c b/cong.c index 95c51ad..98f55a4 100644 --- a/cong.c +++ b/cong.c @@ -37,6 +37,7 @@ int main(void) { float dt = 0.0f; char scoreText[2048]; char isPaused = 0; + char playerMoveDown = 1; initPlayer(&player); initBall(&ball); @@ -67,6 +68,11 @@ int main(void) { if (ball.transform.position.y + ball.transform.size.y >= HEIGHT || ball.transform.position.y <= 0) { ballVel.y = -ballVel.y; + if (playerMoveDown) + playerMoveDown = 0; + else + playerMoveDown = 1; + } if (ball.transform.position.x + ball.transform.size.x >= wall.transform.position.x && ballVel.x > 0) { @@ -88,9 +94,9 @@ int main(void) { } // Player movement - if (IsKeyDown(KEY_W) && player.transform.position.y > 0) { + if (!playerMoveDown && player.transform.position.y > 0) { player.transform.position.y -= playerSpeed * dt; - } else if (IsKeyDown(KEY_S) && player.transform.position.y + player.transform.size.y < HEIGHT) { + } else if (playerMoveDown && player.transform.position.y + player.transform.size.y < HEIGHT) { player.transform.position.y += playerSpeed * dt; } }