engine: input added

This commit is contained in:
DarthMooMancer
2025-09-08 14:38:02 -04:00
parent 54bc1d7290
commit 63344fb83b
8 changed files with 50 additions and 5 deletions
+4 -3
View File
@@ -6,12 +6,13 @@ include_directories(include)
set(SOURCES
src/main.cpp
src/input.cpp
)
add_executable(2048 ${SOURCES})
# find_package(Curses REQUIRED)
# include_directories(${CURSES_INCLUDE_DIR})
# target_link_libraries(2048 ${CURSES_LIBRARIES})
find_package(Curses REQUIRED)
include_directories(${CURSES_INCLUDE_DIR})
target_link_libraries(2048 ${CURSES_LIBRARIES})
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
-1
View File
@@ -1 +0,0 @@
compile_commands.json
+7
View File
@@ -0,0 +1,7 @@
#ifndef GLOBALS_HPP
#define GLOBALS_HPP
constexpr int ROW = 10;
constexpr int COL = 10;
#endif
+9
View File
@@ -0,0 +1,9 @@
#ifndef INPUT_HPP
#define INPUT_HPP
struct Input {
int _getch;
void get_input(bool &running);
};
#endif
+6
View File
@@ -0,0 +1,6 @@
#ifndef WINDOW_HPP
#define WINDOW_HPP
// Add code here
#endif
+15
View File
@@ -0,0 +1,15 @@
#include "input.hpp"
#include <ncurses.h>
void Input::get_input(bool &running) {
while (running) {
initscr();
cbreak();
noecho();
_getch = getch();
endwin();
if(_getch == 113) running = false;
}
}
+8
View File
@@ -1,6 +1,14 @@
#include <iostream>
#include <thread>
#include "input.hpp"
int main() {
Input input;
bool running = true;
std::thread input_thread(&Input::get_input, &input, std::ref(running));
while (running) {
std::cout << "Hello World" << std::endl;
}
input_thread.join();
return 0;
}
View File