From 88428fded9b66e83acca25bd237f9e121c85b4cb Mon Sep 17 00:00:00 2001 From: Matt Low Date: Mon, 12 Nov 2018 11:18:26 +0400 Subject: [PATCH] Keep speed of ball when hitting sticky paddle --- core/src/com/me/brickbuster/entity/Ball.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/core/src/com/me/brickbuster/entity/Ball.java b/core/src/com/me/brickbuster/entity/Ball.java index 9a6952a..0b89a89 100644 --- a/core/src/com/me/brickbuster/entity/Ball.java +++ b/core/src/com/me/brickbuster/entity/Ball.java @@ -36,7 +36,7 @@ public class Ball extends Entity { @Override public void update(float dt) { - if (!getBrickBuster().isPlaying()) { + if (!getBrickBuster().isPlaying() || isStuck()) { return; } @@ -82,6 +82,9 @@ public class Ball extends Entity { if (nearest.dst(new_pos.x, new_pos.y) <= RADIUS) { paddleCollision(); + if (getBrickBuster().getPaddle().isSticky()) { + return; + } } } @@ -98,18 +101,17 @@ public class Ball extends Entity { public void launch() { if (getBrickBuster().getPaddle().isSticky()) { direction = paddleReflectAngle(); + isStuck = false; } else { float angle = MathUtils.random(MathUtils.PI/2) + MathUtils.PI/4; direction = new Vector2(MathUtils.cos(angle), MathUtils.sin(angle)); speed = DEFAULT_SPEED; } - isStuck = false; } public void paddleCollision() { Paddle paddle = getBrickBuster().getPaddle(); if (paddle.isSticky()) { - speed = 0; isStuck = true; setY(Paddle.PADDLE_Y + Paddle.PADDLE_HEIGHT + RADIUS); return;