Skip to content
Snippets Groups Projects
Commit 3542c050 authored by Robert Goldmann's avatar Robert Goldmann
Browse files

implemented no collision ball

parent 1b9e5287
No related branches found
No related tags found
No related merge requests found
......@@ -3,7 +3,6 @@ package de.bricked.game.board;
import java.util.ArrayList;
import de.bricked.game.balls.Ball;
import de.bricked.game.balls.BallType;
import de.bricked.game.bricks.Brick;
import de.bricked.game.bricks.BrickType;
import de.bricked.game.levels.Level;
......@@ -157,8 +156,9 @@ public class Board
{
points = 0;
if(ball.getType().equals(BallType.EXPLOSIVE))
switch(ball.getType())
{
case EXPLOSIVE:
Brick currentBrick = bricks.get(row).get(col);
if(currentBrick.getPowerUp() != null)
{
......@@ -166,9 +166,17 @@ public class Board
}
bricks.get(row).set(col, new Brick(BrickType.TNT));
}
destroyBrick(row, col, false);
break;
case NO_COLLISION:
destroyBrick(row, col, true);
break;
default:
destroyBrick(row, col, false);
break;
}
return points;
}
......@@ -206,7 +214,6 @@ public class Board
LevelController.redrawBrick(col, row, bricks.get(row).get(col), false);
}
}
private void explodeBrick(int row, int col)
......
......@@ -607,7 +607,7 @@ public class LevelController
{
anchorPaneGame.getChildren().remove(stackPaneBall);
game.setBall(new Ball(BallType.EXPLOSIVE));
game.setBall(new Ball(BallType.NO_COLLISION));
// create circle for ball
final Circle circle = new Circle(game.getBall().getBallRadius(), Color.web(game.getBall().getType().getColor()));
......@@ -656,10 +656,13 @@ public class LevelController
HitLocation hitLocation = game.collides(ballPosition, brickPosition, stackPaneBrick.getWidth(), stackPaneBrick.getHeight(), false);
if(hitLocation != null)
{
if(!game.getBall().getType().equals(BallType.NO_COLLISION))
{
game.getBall().setDirection(game.reflectBall(hitLocation, game.getBall().getDirection()));
correctBallPosition(hitLocation, ballPosition, brickPosition, stackPaneBrick.getWidth(), stackPaneBrick.getHeight());
}
game.setPoints(game.getPoints() + game.getBoard().hitBrick(i, k, game.getBall()));
labelPoints.setText(String.valueOf(game.getPoints()));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment