@@ -38,9 +38,11 @@ void GameController::placePattern(int startX, int startY, const Pattern& pattern
38
38
grid.setCellState (startX + (patternWidth - 1 - x), startY + (patternHeight - 1 - y), pattern[y][x]);
39
39
if (pattern[y][x]) {
40
40
grid.getCell (startX + (patternWidth - 1 - x), startY + (patternHeight - 1 - y)).setColor (Vector3d (0 .5f , 0 .9f , 0 .5f ));
41
+ gameOfLife.SetCellColor (startX + (patternWidth - 1 - x), startY + (patternHeight - 1 - y), Vector3d (0 .5f , 0 .9f , 0 .5f ));
41
42
}
42
43
else {
43
44
grid.getCell (startX + (patternWidth - 1 - x), startY + (patternHeight - 1 - y)).setColor (Vector3d (0 .1f , 0 .1f , 0 .1f ));
45
+ gameOfLife.SetCellColor (startX + (patternWidth - 1 - x), startY + (patternHeight - 1 - y), Vector3d (0 .1f , 0 .1f , 0 .1f ));
44
46
}
45
47
46
48
}
@@ -62,10 +64,12 @@ void GameController::randomizeGrid(float density) {
62
64
if (dis (gen) < density) {
63
65
grid.setCellState (x, y, true );
64
66
grid.getCell (x, y).setColor (Vector3d (0 .0f , 0 .6f , 0 .0f ));
67
+ gameOfLife.SetCellColor (x, y, Vector3d (0 .0f , 0 .6f , 0 .0f ));
65
68
}
66
69
else {
67
70
grid.setCellState (x, y, false );
68
71
grid.getCell (x, y).setColor (Vector3d (0 .0f , 0 .0f , 0 .0f ));
72
+ gameOfLife.SetCellColor (x, y, Vector3d (0 .0f , 0 .0f , 0 .0f ));
69
73
}
70
74
// float r = static_cast<float>(rand()) / RAND_MAX;
71
75
// float g = static_cast<float>(rand()) / RAND_MAX;
@@ -81,6 +85,7 @@ void GameController::clearGrid() {
81
85
for (int x = 0 ; x < grid.getWidth (); ++x) {
82
86
grid.setCellState (x, y, false ); // Óñòàíàâëèâàåì êàæäóþ êëåòêó â ìåðòâîå ñîñòîÿíèå
83
87
grid.getCell (x, y).setColor (Vector3d (0 .0f , 0 .0f , 0 .0f ));
88
+ gameOfLife.SetCellColor (x, y, Vector3d (0 .0f , 0 .0f , 0 .0f ));
84
89
}
85
90
}
86
91
}
@@ -112,6 +117,7 @@ void GameController::previousGeneration() {
112
117
if (isRunning) return ;
113
118
gameOfLife.previousGeneration ();
114
119
}
120
+
115
121
bool GameController::isSimulationRunning () const {
116
122
return isRunning;
117
123
}
@@ -121,10 +127,12 @@ void GameController::toggleCellState(int x, int y) {
121
127
bool currentState = grid.getCellState (x, y);
122
128
grid.setCellState (x, y, !currentState);
123
129
if (!currentState) {
124
- grid.getCell (x, y).setColor (Vector3d (0 .1f , 0 .4f , 0 .1f ));
130
+ // grid.getCell(x, y).setColor(Vector3d(0.1f, 0.4f, 0.1f));
131
+ gameOfLife.SetCellColor (x, y, Vector3d (0 .1f , 0 .4f , 0 .1f ));
125
132
}
126
133
else {
127
- grid.getCell (x, y).setColor (Vector3d (0 .0f , 0 .0f , 0 .0f ));
134
+ // grid.getCell(x, y).setColor(Vector3d(0.0f, 0.0f, 0.0f));
135
+ gameOfLife.SetCellColor (x, y, Vector3d (0 .0f , 0 .0f , 0 .0f ));
128
136
}
129
137
130
138
}
@@ -183,9 +191,11 @@ void GameController::setCurrentPattern(int patternNumber) {
183
191
break ;
184
192
}
185
193
}
194
+
186
195
void GameController::setCurrentPatternRotator (int patternRotator) {
187
196
currentPatternRotator = patternRotator;
188
197
}
198
+
189
199
void GameController::PlacePattern (int startX, int startY) {
190
200
if (isRunning) return ;
191
201
@@ -265,4 +275,6 @@ Pattern GameController::rotateOrFlip(const Pattern& pattern, Rotation rotation)
265
275
}
266
276
267
277
return result;
268
- }
278
+ }
279
+
280
+
0 commit comments