Make sure paddle reaches screen edge
This commit is contained in:
parent
e8901d2ed4
commit
ac27cc5e90
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user