shorthand names without being to short for clarity
This commit is contained in:
+15
-15
@@ -7,35 +7,35 @@
|
||||
|
||||
int main () {
|
||||
std::srand(std::time(0));
|
||||
Window window;
|
||||
Window win;
|
||||
bool running = true;
|
||||
Point* buffer[MAX_LEN] = {}; // 2 for head, 1 for fruit, rest for tail
|
||||
Vector2i* buf[MAX_LEN] = {}; // 2 for head, 1 for fruit, rest for tail
|
||||
|
||||
buffer[HEAD] = new Point { COL / 2, ROW / 2, '*' };
|
||||
buffer[PREVIOUS_HEAD] = new Point { buffer[HEAD]->x, buffer[HEAD]->y, '.' };
|
||||
buffer[FRUIT] = new Point { (rand() % COL), (rand() % ROW), 'o' };
|
||||
buf[HEAD] = new Vector2i { COL / 2, ROW / 2, '*' };
|
||||
buf[PREVIOUS_HEAD] = new Vector2i { buf[HEAD]->x, buf[HEAD]->y, '.' };
|
||||
buf[FRUIT] = new Vector2i { (rand() % COL), (rand() % ROW), 'o' };
|
||||
|
||||
std::thread input_thread([&] { get_input(buffer[HEAD]->m_dir, running ); } );
|
||||
std::thread input_thread([&] { get_input(buf[HEAD]->m_dir, running ); } );
|
||||
|
||||
while (running) {
|
||||
on_fruit_eaten(window.m_board, buffer);
|
||||
determine_index_zero_pos(buffer);
|
||||
move_tail_indicies(buffer);
|
||||
on_fruit_eaten(win.board, buf);
|
||||
determine_index_zero_pos(buf);
|
||||
move_tail_indicies(buf);
|
||||
|
||||
if(buffer[MAX_LEN - 1] != nullptr) {
|
||||
if(buf[MAX_LEN - 1] != nullptr) {
|
||||
std::cout << "You filled the whole board and won! Score: " << get_score() << std::endl;
|
||||
running = false;
|
||||
} if(segment_overlap(buffer)) {
|
||||
} if(segment_overlap(buf)) {
|
||||
std::cout << "You collided with yourself and died! Score: " << get_score() << std::endl;
|
||||
running = false;
|
||||
}
|
||||
|
||||
window.clear_display();
|
||||
window.update_display(buffer);
|
||||
window.draw_display(200);
|
||||
win.clear_display();
|
||||
win.update_display(buf);
|
||||
win.draw_display(200);
|
||||
}
|
||||
|
||||
input_thread.join();
|
||||
for(auto& p : buffer) delete p;
|
||||
for(auto& p : buf) delete p;
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user