BreakOut 5 - reset direction
This commit is contained in:
parent
5a5d661719
commit
2a27f74846
@ -49,8 +49,9 @@ public class Ball implements IBall {
|
|||||||
*/
|
*/
|
||||||
public Ball() {
|
public Ball() {
|
||||||
this.position = new Position(0, 0);
|
this.position = new Position(0, 0);
|
||||||
this.direction = new Vector2D(Constants.BALL_SPEED, Constants.BALL_SPEED);
|
|
||||||
this.direction.rescale();
|
// reset direction
|
||||||
|
resetDirection();
|
||||||
|
|
||||||
// reset position to bottom-center
|
// reset position to bottom-center
|
||||||
resetPosition();
|
resetPosition();
|
||||||
@ -97,8 +98,7 @@ public class Ball implements IBall {
|
|||||||
Random random = new Random();
|
Random random = new Random();
|
||||||
|
|
||||||
// random hue without blue colors to prevent ghosting
|
// random hue without blue colors to prevent ghosting
|
||||||
// 65 <~ 170/255
|
float hue = (random.nextInt(200)+50) / 360f;
|
||||||
float hue = (random.nextInt(65)) / 100f;
|
|
||||||
|
|
||||||
// saturation between 0.5 and 0.7
|
// saturation between 0.5 and 0.7
|
||||||
float saturation = (random.nextInt(2000) + 5000) / 10000f;
|
float saturation = (random.nextInt(2000) + 5000) / 10000f;
|
||||||
@ -396,4 +396,12 @@ public class Ball implements IBall {
|
|||||||
position.setY(Constants.SCREEN_HEIGHT - Constants.BALL_DIAMETER - Constants.PADDLE_HEIGHT);
|
position.setY(Constants.SCREEN_HEIGHT - Constants.BALL_DIAMETER - Constants.PADDLE_HEIGHT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* resets balls direction
|
||||||
|
*/
|
||||||
|
public void resetDirection() {
|
||||||
|
direction = new Vector2D(Constants.BALL_SPEED, Constants.BALL_SPEED);
|
||||||
|
direction.rescale();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -296,6 +296,7 @@ public class Level extends Thread implements ILevel {
|
|||||||
if(lifeCounter > 0) {
|
if(lifeCounter > 0) {
|
||||||
resetPaddles();
|
resetPaddles();
|
||||||
getBall().resetPosition();
|
getBall().resetPosition();
|
||||||
|
getBall().resetDirection();
|
||||||
getBall().setLost(false);
|
getBall().setLost(false);
|
||||||
stopBall();
|
stopBall();
|
||||||
// level failed
|
// level failed
|
||||||
|
Loading…
x
Reference in New Issue
Block a user