Merge remote-tracking branch 'origin/master'

This commit is contained in:
BlueNutterfly 2018-11-11 13:13:05 +04:00
commit 66bd930e2e

View File

@ -12,6 +12,7 @@ public class Paddle extends Entity {
public static final int PADDLE_WIDTH = 100;
public static final int PADDLE_HEIGHT = 16;
public static final int PADDLE_Y = 25;
public static final int PADDLE_SPEED = 10;
public Paddle(BrickBuster brickBuster) {
super(brickBuster, BrickBuster.WIDTH/2, PADDLE_Y);
@ -29,21 +30,21 @@ 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) {
if (getX() - PADDLE_SPEED - PADDLE_WIDTH/2 < 0) {
return;
}
setX(getX() - 5);
setX(getX() - PADDLE_SPEED);
if (!getBrickBuster().isPlaying()) {
ball.setX(ball.getX() - 5);
ball.setX(ball.getX() - PADDLE_SPEED);
}
}
if (Gdx.input.isKeyPressed(Input.Keys.RIGHT)) {
if (getX() + 5 + PADDLE_WIDTH/2 > BrickBuster.WIDTH) {
if (getX() + PADDLE_SPEED + PADDLE_WIDTH/2 > BrickBuster.WIDTH) {
return;
}
setX(getX() + 5);
setX(getX() + PADDLE_SPEED);
if (!getBrickBuster().isPlaying()) {
ball.setX(ball.getX() + 5);
ball.setX(ball.getX() + PADDLE_SPEED);
}
}
}