-
Notifications
You must be signed in to change notification settings - Fork 0
/
serial_view.cpp
57 lines (55 loc) · 1.36 KB
/
serial_view.cpp
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
#include "serial_view.h"
void SerialView::update(const Grid *grid, float progress)
{
if (progress != 1.0)
{
return;
}
_serial.println("-----------------");
for (int i = 0; i < ROWS; i++)
{
int rowLen = Grid::rowLength(i);
_serial.print("i=");
_serial.print(i);
_serial.print("\t.");
int empties = (COLS - rowLen);
for (int k = 0; k < empties; k++)
{
_serial.print(".");
}
for (int j = 0; j < rowLen; j++)
{
if (grid->kill[i][j])
{
_serial.print("-");
}
else if (grid->spawn[i][j])
{
_serial.print("+");
}
else if (grid->cells[i][j])
{
_serial.print("O");
}
else
{
_serial.print(" ");
}
_serial.print(".");
}
for (int k = 0; k < empties; k++)
{
_serial.print(".");
}
_serial.println("");
}
_serial.println("-----------------");
_serial.print("Resets: ");
_serial.print(grid->resets());
_serial.print("\tEOL: ");
_serial.print(grid->eolCount());
_serial.print("\tERA: ");
_serial.print(grid->era());
_serial.println("");
_serial.println("-----------------");
}