Speed up paddle

This commit is contained in:
Matt Low 2018-11-11 12:02:22 +04:00
parent 733f75830f
commit adadca7c50

View File

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