-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmapgenerator.java
49 lines (44 loc) · 1.16 KB
/
mapgenerator.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import java.awt.*;
public class mapgenerator {
public int map[][];
public int brickWidth;
public int brickHeight;
public mapgenerator (int row, int col)
{
map = new int[row][col];
for(int i = 0; i<map.length; i++)
{
for(int j =0; j<map[0].length; j++)
{
map[i][j] = 1;
}
}
brickWidth = 540/col;
brickHeight = 150/row;
}
public void draw(Graphics2D g)
{
for(int i = 0; i<map.length; i++)
{
for(int j =0; j<map[0].length; j++)
{
if(map[i][j] > 0)
{
g.setColor(Color.white);
g.fillRect(j * brickWidth + 80, i * brickHeight + 50, brickWidth, brickHeight);
// this is just to show separate brick, game can still run without it
g.setStroke(new BasicStroke(3));
g.setColor(Color.white);
g.drawRect(j * brickWidth + 80, i * brickHeight + 50, brickWidth, brickHeight);
g.setStroke(new BasicStroke(3));
g.setColor(Color.black);
g.drawRect(j * brickWidth + 80, i * brickHeight + 50, brickWidth, brickHeight);
}
}
}
}
public void setBrickValue(int value, int row, int col)
{
map[row][col] = value;
}
}