feat: (snake.cpp snake.hpp) adding tail movement (broken)

This commit is contained in:
DarthMooMancer
2025-08-26 20:21:01 -04:00
parent 1bb5ecad33
commit b2c90565bc
7 changed files with 131 additions and 41 deletions
+25 -5
View File
@@ -1,17 +1,37 @@
#include "input.hpp"
#include <ncurses.h>
void Input::get_input() {
while(true) {
void Input::get_input(int &d, bool &r) {
bool running = true;
while(running) {
initscr();
cbreak();
noecho();
m_old_key = m_current_key;
m_current_key = getch();
endwin();
if (m_current_key == 'q') {
break;
switch (m_current_key) {
case 'D':
case 'a':
d = -1;
break;
case 'C':
case 'd':
d = 1;
break;
case 'B':
case 's':
d = 2;
break;
case 'A':
case 'w':
d = -2;
break;
case 'q':
r = false;
running = false;
break;
}
}
}