Untitled

mail@pastecode.io avatar
unknown
plain_text
5 months ago
708 B
2
Indexable
#include "Field.h"
#include <cstring>

Field::Field() {
    clear();
}

void Field::clear() {
    std::memset(field, 0, sizeof(field));
}

void Field::updateField(int field[][10]) {
    std::memcpy(this->field, field, sizeof(this->field));
}

void Field::checkLines(int& score) {
    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++) {
                field[x][j] = field[i][j];
            }
            x--;
        } else {
            score += 100;
        }
    }
}

int Field::getField(int x, int y) {
    return field[x][y];
}
Leave a Comment