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