feat: fruits, globals, input, snake, point, window

This commit is contained in:
DarthMooMancer
2025-05-09 21:30:19 -04:00
parent 636ebae6a3
commit cdcffc40ea
13 changed files with 231 additions and 57 deletions
+34
View File
@@ -0,0 +1,34 @@
#include "window.hpp"
#include <iostream>
#include <chrono>
#include <thread>
Window::Window() {
for(std::array<char, COL> &row : m_board) {
row.fill('.');
}
}
void Window::draw_window() {
for(std::array<char, COL> &row : m_board) {
for(char &col : row) {
std::cout << col << " ";
}
std::cout << "\r\n";
}
std::cout << std::flush;
}
void Window::clear_window() {
std::cout<<"\033[H" << std::flush;
}
void Window::tick(double frames_per_second) {
std::this_thread::sleep_for(std::chrono::milliseconds((int) (1000 / frames_per_second)));
}
void Window::update_loop(int fps) {
clear_window();
tick(fps);
draw_window();
}