-
Notifications
You must be signed in to change notification settings - Fork 0
/
Floor.pde
64 lines (52 loc) · 1.62 KB
/
Floor.pde
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
//==============================================
// Class that contain a Floor of a Dungeon
//
// @author : Tony Chouteau
//
//==============================================
public class Floor {
private Room[][] rooms;
private PVector floorSize;
private PVector roomSize;
Floor(PVector floorSize, PVector roomSize) {
this.rooms = new Room[int(floorSize.y)][int(floorSize.x)];
this.floorSize = floorSize;
this.roomSize = roomSize;
this.initialized();
}
private void initialized() {
boolean[][] isEmptyTable = new boolean[int(this.floorSize.y)][int(this.floorSize.x)];
for (int i = 0; i < int(this.floorSize.y); i++) {
for (int j = 0; j < int(this.floorSize.x); j++) {
isEmptyTable[i][j] = Math.random() > 0.5;
}
}
for (int i = 0; i < int(this.floorSize.y); i++) {
for (int j = 0; j < int(this.floorSize.x); j++) {
this.makeRooms(j, i, isEmptyTable[i][j]);
}
}
}
private void makeRooms(int x, int y, boolean isEmpty) {
if (x >= 0 && x < floorSize.x && y >= 0 && y < floorSize.y) {
this.rooms[x][y] = new Room(this.roomSize, isEmpty);
}
}
public void display() {
for (Room[] rooms : this.rooms) { // z
for (Room room : rooms) { // x
room.display();
}
}
}
public void displayLineByLine() {
for (Room[] rooms : this.rooms) { // z
for (int i = 0; i < this.roomSize.y; i++) { // x room
for (Room room : rooms) { // x floor
room.displayLine(i);
}
println();
}
}
}
}