cleanup & architectural changes

This commit is contained in:
2026-05-26 16:26:14 +03:00
parent 680ef59e67
commit d596438a94
6 changed files with 43 additions and 43 deletions
+11 -7
View File
@@ -9,34 +9,38 @@ using Tile = unsigned long long int;
int main() {
Field field(4);
char action;
bool canMove = true;
field.spawnTile(field.getEmptyTiles());
field.spawnTile(field.getEmptyTiles());
while (true) {
while (canMove) {
field.debug();
std::cin >> action;
switch (action)
{
switch (action) {
case 'w':
field.move(Direction::up);
canMove = field.move(Direction::up);
field.spawnTile(field.getEmptyTiles());
break;
case 's':
field.move(Direction::down);
canMove = field.move(Direction::down);
field.spawnTile(field.getEmptyTiles());
break;
case 'a':
field.move(Direction::left);
canMove = field.move(Direction::left);
field.spawnTile(field.getEmptyTiles());
break;
case 'd':
field.move(Direction::right);
canMove = field.move(Direction::right);
field.spawnTile(field.getEmptyTiles());
break;
default:
return 0;
}
field.updateScore();
}
if (!canMove) {
printf("Game Over! Score: %llu", field.getScore());
}
return 0;