removing magic numbers

This commit is contained in:
DarthMooMancer
2025-11-02 21:46:24 -05:00
parent 02ff154b81
commit ab16f18137
5 changed files with 25 additions and 37 deletions
+4 -5
View File
@@ -8,15 +8,14 @@
int main () {
std::srand(std::time(0));
Window window;
const int MAX_LEN = (ROW * COL) + 3;
bool running = true;
Point* buffer[MAX_LEN] = {}; // 2 for head, 1 for fruit, rest for tail
buffer[0] = new Point { ROW / 2, COL / 2, '*' }; // Head
buffer[1] = new Point { buffer[0]->m_row, buffer[0]->m_col, '.' };
buffer[2] = new Point { (rand() % ROW), (rand() % COL), 'o' }; // Fruit
buffer[HEAD] = new Point { ROW / 2, COL / 2, '*' }; // Head
buffer[PREVIOUS_HEAD] = new Point { buffer[HEAD]->m_row, buffer[HEAD]->m_col, '.' };
buffer[FRUIT] = new Point { (rand() % ROW), (rand() % COL), 'o' }; // Fruit
std::thread input_thread([&] { get_input(buffer[0]->m_dir, running ); } );
std::thread input_thread([&] { get_input(buffer[HEAD]->m_dir, running ); } );
while (running) {
on_fruit_eaten(window.m_board, buffer);