Compare commits
No commits in common. "353afe1cee8d0d5dd72d12c786b55d856125a6d4" and "711a5548ef7cfddfbe1844f2e4308c7bc1bac7c0" have entirely different histories.
353afe1cee
...
711a5548ef
@ -30,9 +30,9 @@ public class BrickBuster extends ApplicationAdapter {
|
|||||||
paddle = new Paddle(this);
|
paddle = new Paddle(this);
|
||||||
bricks = new ArrayList<Brick>();
|
bricks = new ArrayList<Brick>();
|
||||||
for (int col = 0; col < 13; col++) {
|
for (int col = 0; col < 13; col++) {
|
||||||
for (int row = 0; row < 7; row++) {
|
for (int row = 0; row < 10; row++) {
|
||||||
int x = 15 + (col * (Brick.BLOCK_WIDTH + 10));
|
int x = 15 + (col * (Brick.BLOCK_WIDTH + 10));
|
||||||
int y = 15 + Brick.BLOCK_HEIGHT + (row * (Brick.BLOCK_HEIGHT + 10));
|
int y = 15 + Brick.BLOCK_HEIGHT + (row * (Brick.BLOCK_HEIGHT + 5));
|
||||||
bricks.add(new Brick(this, x, HEIGHT - y));
|
bricks.add(new Brick(this, x, HEIGHT - y));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ public class Ball extends Entity {
|
|||||||
public static final Color BALL_COLOR = Color.CHARTREUSE;
|
public static final Color BALL_COLOR = Color.CHARTREUSE;
|
||||||
|
|
||||||
public Vector2 direction;
|
public Vector2 direction;
|
||||||
public float speed = 300;
|
public float speed;
|
||||||
|
|
||||||
public Ball(BrickBuster brickBuster) {
|
public Ball(BrickBuster brickBuster) {
|
||||||
super(brickBuster,BrickBuster.WIDTH/2, Paddle.PADDLE_Y + Paddle.PADDLE_HEIGHT + RADIUS);
|
super(brickBuster,BrickBuster.WIDTH/2, Paddle.PADDLE_Y + Paddle.PADDLE_HEIGHT + RADIUS);
|
||||||
@ -36,7 +36,7 @@ public class Ball extends Entity {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2 new_pos = getPos().cpy().add(direction.cpy().scl(speed * dt));
|
Vector2 new_pos = getPos().cpy().add(direction.cpy().scl(speed));
|
||||||
|
|
||||||
boolean brick_collision = false;
|
boolean brick_collision = false;
|
||||||
Iterator<Brick> brickIterator = getBrickBuster().getBricks().iterator();
|
Iterator<Brick> brickIterator = getBrickBuster().getBricks().iterator();
|
||||||
@ -52,7 +52,7 @@ public class Ball extends Entity {
|
|||||||
if (nearest.dst(new_pos.x, new_pos.y) <= RADIUS) {
|
if (nearest.dst(new_pos.x, new_pos.y) <= RADIUS) {
|
||||||
brickIterator.remove();
|
brickIterator.remove();
|
||||||
if (getBrickBuster().getBricks().size() <= 39) {
|
if (getBrickBuster().getBricks().size() <= 39) {
|
||||||
speed = 450;
|
speed = 8;
|
||||||
}
|
}
|
||||||
Utils.reflect(direction, segment.nor());
|
Utils.reflect(direction, segment.nor());
|
||||||
brick_collision = true;
|
brick_collision = true;
|
||||||
@ -80,12 +80,13 @@ public class Ball extends Entity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getPos().add(direction.cpy().scl(speed * dt));
|
getPos().add(direction.cpy().scl(speed));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void launch() {
|
public void launch() {
|
||||||
float angle = MathUtils.random(MathUtils.PI/2) + MathUtils.PI/4;
|
float angle = MathUtils.random(MathUtils.PI/2) + MathUtils.PI/4;
|
||||||
direction = new Vector2(MathUtils.cos(angle), MathUtils.sin(angle));
|
direction = new Vector2(MathUtils.cos(angle), MathUtils.sin(angle));
|
||||||
|
speed = 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void paddleCollision() {
|
public void paddleCollision() {
|
||||||
|
Loading…
Reference in New Issue
Block a user