Untitled
unknown
plain_text
21 days ago
1.1 kB
2
Indexable
Never
#include "Field.h" #include "Tetromino.h" Field::Field() { clear(); } void Field::clear() { for (int i = 0; i < 23; i++) { for (int j = 0; j < 10; j++) { field[i][j] = 0; } } } void Field::checkLines(int& score) { int fieldTemp[23][10] = {0}; int x = 22; for (int i = 22; i >= 4; i--) { int count = 0; for (int j = 0; j < 10; j++) { if (field[i][j]) count++; } if (count < 10) { for (int j = 0; j < 10; j++) { fieldTemp[x][j] = field[i][j]; } x--; } else { score += 100; } } for (int i = 4; i < 23; i++) { for (int j = 0; j < 10; j++) { field[i][j] = fieldTemp[i][j]; } } } void Field::placeTetromino(Tetromino& tetromino) { for (int i = 0; i < 4; i++) { field[tetromino.b[i].y][tetromino.b[i].x] = tetromino.colorNum; } } bool Field::isGameOver() { for (int i = 0; i < 10; i++) { if (field[3][i] > 0) { return true; } } return false; }
Leave a Comment