This commit is contained in:
DarthMooMancer
2025-09-03 09:00:00 -04:00
commit c93413ad78
11 changed files with 120 additions and 0 deletions
View File
+17
View File
@@ -0,0 +1,17 @@
#include <ncurses.h>
#include "input.hpp"
void Input::get_input(bool &running) {
while(running) {
initscr();
cbreak();
noecho();
_getch = getch();
endwin();
if(_getch == 113) {
running = false;
}
}
}
+20
View File
@@ -0,0 +1,20 @@
#include <iostream>
#include <thread>
#include "window.hpp"
#include "input.hpp"
int main() {
Window window;
Input input;
bool running = true;
std::thread input_thread(&Input::get_input, &input, std::ref(running));
while (running) {
window.update_display();
}
input_thread.join();
return 0;
}
+17
View File
@@ -0,0 +1,17 @@
#include "window.hpp"
#include <iostream>
#include <chrono>
#include <thread>
void Window::update_display() {
for(std::array<char, COL> &row : m_board) { row.fill('.'); }
std::cout << "\033[H" << std::flush;
for(std::array<char, COL> &row : m_board) {
for(char &col : row) {
std::cout << col << " ";
}
std::cout << "\r\n";
}
std::this_thread::sleep_for(std::chrono::milliseconds(200)); // 1000 / fps; 200ms = 5fps
}