Added paddle boundary
This commit is contained in:
parent
74b96990c5
commit
ace35e1a2c
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user