This commit is contained in:
DarthMooMancer
2025-08-21 09:17:37 -04:00
parent a128048a8f
commit 5e887e3688
12 changed files with 134 additions and 133 deletions
+18 -14
View File
@@ -4,31 +4,35 @@
#include <thread>
Window::Window() {
for(std::array<char, COL> &row : m_board) {
row.fill('.');
}
for(std::array<char, COL> &row : m_board) {
row.fill('.');
}
m_score = 0;
}
void Window::draw_score() {
std::cout << "Score: " << m_score << std::endl;
}
void Window::draw_window() {
for(std::array<char, COL> &row : m_board) {
for(char &col : row) {
std::cout << col << " ";
for(std::array<char, COL> &row : m_board) {
for(char &col : row) {
std::cout << col << " ";
}
std::cout << "\r\n";
}
std::cout << "\r\n";
}
std::cout << std::flush;
std::cout << std::flush;
}
void Window::clear_window() {
std::cout<<"\033[H" << std::flush;
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)));
std::this_thread::sleep_for(std::chrono::milliseconds((int) (1000 / frames_per_second)));
}
void Window::update_loop(int fps) {
clear_window();
draw_window();
tick(fps);
clear_window();
draw_window();
tick(fps);
}