From ac27cc5e90475b911ab50eac78f7138c5cb07463 Mon Sep 17 00:00:00 2001 From: BlueNutterfly Date: Mon, 12 Nov 2018 11:07:04 +0400 Subject: [PATCH] Make sure paddle reaches screen edge --- core/src/com/me/brickbuster/entity/Paddle.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/src/com/me/brickbuster/entity/Paddle.java b/core/src/com/me/brickbuster/entity/Paddle.java index 2516a3b..0c451af 100644 --- a/core/src/com/me/brickbuster/entity/Paddle.java +++ b/core/src/com/me/brickbuster/entity/Paddle.java @@ -36,6 +36,7 @@ public class Paddle extends Entity { Ball ball = getBrickBuster().getBall(); if (Gdx.input.isKeyPressed(Input.Keys.LEFT)) { if (getX() - width/2 - PADDLE_SPEED * dt < 0) { + setX(width/2); return; } setX(getX() - PADDLE_SPEED * dt); @@ -45,6 +46,7 @@ public class Paddle extends Entity { } if (Gdx.input.isKeyPressed(Input.Keys.RIGHT)) { if (getX() + width/2 + PADDLE_SPEED * dt > BrickBuster.WIDTH) { + setX(BrickBuster.WIDTH - width/2); return; } setX(getX() + PADDLE_SPEED * dt);