-
Notifications
You must be signed in to change notification settings - Fork 0
/
Packet.pde
49 lines (39 loc) · 972 Bytes
/
Packet.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
class Packet {
private String packet;
private int width;
private int height;
Packet(int version, int width, int height) {
this.packet = "";
this.width = width;
this.height = height;
packet += version + "\n";
packet += width + "\n";
packet += height + "\n";
}
void addPoofer(boolean active) {
for (int i = 0; i < this.width; ++i) {
packet += active ? "1" : "0";
}
packet += "\n";
}
void addGridData(boolean[][] gridData) {
for (int i = 0; i < this.height; ++i) {
String rowData = "";
for (int j = 0; j < this.width; ++j) {
rowData += gridData[j][i] == true ? 1 : 0;
}
packet+=rowData + "\n";
}
}
void emptyGrid() {
this.addGridData(new boolean[this.width][this.height]);
}
void fullGrid() {
for (int i = 0; i < this.height; ++i) {
packet+="1111111111\n";
}
}
String getData() {
return this.packet;
}
}