This commit is contained in:
DarthMooMancer
2025-08-22 12:13:43 -04:00
parent 5e887e3688
commit bb1040fff5
3 changed files with 37 additions and 19 deletions
+5 -11
View File
@@ -18,6 +18,11 @@ int main (int argc, char *argv[]) {
std::thread input_thread(&Input::get_input, &input);
bool running = true;
int count = 0;
/* NOTE
* if 3 or 4 then "-"
* if 1 or 2 then "|"
* if "corner" then "~"
*/
while (running) {
switch (input.m_current_key) {
case 's':
@@ -38,17 +43,6 @@ int main (int argc, char *argv[]) {
}
fruit.reset(window.m_board, snake.m_head.m_row, snake.m_head.m_col, window.m_score, count);
if (window.m_score % 2 == 0 && count > 0) {
if (snake.m_direction == 1) {
int r = snake.m_head.m_row;
if (r + 1 > ROW - 1) {
r = snake.m_head.m_row;
}
snake.create_tail(snake.m_head.m_row + r + 1, snake.m_head.m_col);
++r;
}
count--;
}
/* TODO
* update tail positions
+1 -1
View File
@@ -17,7 +17,7 @@ void Snake::create_tail(int row, int col) {
m_tails.push_back(Point {row, col});
}
void Snake::get_new_tail_point(int tail_index, int direction) {
void Snake::get_new_head_point(int tail_index, int direction) {
if (direction == 1) {
if (m_tails.at(tail_index).m_row >= ROW - 1) m_tails.at(tail_index).m_row = 0;
else ++m_tails.at(tail_index).m_row;