Skip to content
Snippets Groups Projects
Commit b82fb7f3 authored by abhatta5's avatar abhatta5
Browse files

Change graphics and remove few static values

parent 80adfca5
No related branches found
No related tags found
1 merge request!1Game graphics
......@@ -27,8 +27,8 @@ class GameMapBuilder {
}
}
brickWidth = 540/col;
brickHeight = 150/row;
brickWidth = 50;
brickHeight = 20;
}
// this draws the bricks
......@@ -36,12 +36,11 @@ class GameMapBuilder {
for (int i = 0; i < map.length; i++) {
for (int j=0; j< map[0].length;j++) {
if(map[i][j] > 0) {
g.setColor(new Color(0XFF8787)); // brick color
g.fillRect(j*brickWidth + 80, i*brickHeight + 50, brickWidth, brickHeight);
g.setColor(new Color(0X0BB5FB)); // brick color
g.fillRect(j*brickWidth, i*brickHeight, brickWidth, brickHeight);
g.setStroke(new BasicStroke(4));
g.setColor(Color.BLACK);
g.drawRect(j*brickWidth + 80, i*brickHeight + 50, brickWidth, brickHeight);
g.drawRect(j*brickWidth, i*brickHeight, brickWidth, brickHeight);
}
}
......
......@@ -11,7 +11,9 @@ public class GamePanel extends JPanel implements KeyListener, ActionListener {
private boolean play = true;
private int score = 0;
private int totalBricks = 21;
private int totalBricks;
private int rows = 10;
private int columns = 14;
private Timer timer;
private int delay = 8;
......@@ -27,8 +29,9 @@ public class GamePanel extends JPanel implements KeyListener, ActionListener {
public GamePanel() {
this.ballPosition = new Vector(120, 350);
this.ballDirection = new Vector(-1, -2);
this.totalBricks = rows * columns;
map = new GameMapBuilder(4, 8);
map = new GameMapBuilder(rows, columns);
addKeyListener(this);
setFocusable(true);
setFocusTraversalKeysEnabled(false);
......@@ -93,8 +96,8 @@ public class GamePanel extends JPanel implements KeyListener, ActionListener {
for (int i = 0; i < map.map.length; i++) { // Ball - Brick interaction
for (int j = 0; j < map.map[0].length; j++) { // map.map[0].length is the number of columns
if (map.map[i][j] > 0) {
int brickX = j * map.brickWidth + 80;
int brickY = i * map.brickHeight + 50;
int brickX = j * map.brickWidth;
int brickY = i * map.brickHeight;
int brickWidth = map.brickWidth;
int brickHeight = map.brickHeight;
......@@ -168,8 +171,8 @@ public class GamePanel extends JPanel implements KeyListener, ActionListener {
ballDirection.x = -1;
ballDirection.y = -2;
score = 0;
totalBricks = 21;
map = new GameMapBuilder(7, 8);
totalBricks = rows * columns;;
map = new GameMapBuilder(rows, columns);
repaint();
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment