From ace35e1a2c9192ab94cc12922d4cd71fc7169134 Mon Sep 17 00:00:00 2001 From: BlueNutterfly Date: Sun, 11 Nov 2018 11:47:21 +0400 Subject: [PATCH] Added paddle boundary --- core/src/com/me/brickbuster/entity/Paddle.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/core/src/com/me/brickbuster/entity/Paddle.java b/core/src/com/me/brickbuster/entity/Paddle.java index 0451f59..c0c386f 100644 --- a/core/src/com/me/brickbuster/entity/Paddle.java +++ b/core/src/com/me/brickbuster/entity/Paddle.java @@ -28,12 +28,18 @@ public class Paddle extends Entity { public void update(float dt) { Ball ball = getBrickBuster().getBall(); if (Gdx.input.isKeyPressed(Input.Keys.LEFT)) { + if (getX() - 5 - PADDLE_WIDTH/2 < 0) { + return; + } setX(getX() - 5); if (!getBrickBuster().isPlaying()) { ball.setX(ball.getX() - 5); } } if (Gdx.input.isKeyPressed(Input.Keys.RIGHT)) { + if (getX() + 5 + PADDLE_WIDTH/2 > BrickBuster.WIDTH) { + return; + } setX(getX() + 5); if (!getBrickBuster().isPlaying()) { ball.setX(ball.getX() + 5);