-
Notifications
You must be signed in to change notification settings - Fork 0
/
Grid.java
43 lines (33 loc) · 1017 Bytes
/
Grid.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
import java.awt.Color;
import java.awt.Graphics;
public class Grid extends GameObject {
private Spot[][] gridArray;
private int spotSize;
public Grid(int offX, int offY, int amountX, int amountY, int boxSize) {
super(amountX, offY, amountX*boxSize, amountY*boxSize);
gridArray = new Spot[amountY][amountX];
for(int row=0;row<amountY;row++) {
for(int col=0;col<amountX;col++) {
gridArray[row][col]=new Spot(offX+(col*boxSize), offY+(row*boxSize), boxSize);
}
}
spotSize=boxSize;
}
public void draw(Graphics pen) {
for(Spot[] row : gridArray) {
for(Spot col : row) {
col.draw(pen);
}
}
}
public Spot[][] getGrid() {
return gridArray;
}
public void update() {
for(Spot[] row : gridArray) {
for(Spot col : row) {
col.update();
}
}
}
}