remove: tick in window
This commit is contained in:
@@ -9,7 +9,6 @@
|
|||||||
struct Window {
|
struct Window {
|
||||||
std::array<std::array<char, COL>, ROW> m_board = {};
|
std::array<std::array<char, COL>, ROW> m_board = {};
|
||||||
void update_display(Bird &bird, std::vector<Pipe> pipes);
|
void update_display(Bird &bird, std::vector<Pipe> pipes);
|
||||||
void tick(int fps);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+2
-7
@@ -3,21 +3,16 @@
|
|||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
|
||||||
void Window::tick(int fps) {
|
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(fps)); // 1000 / fps; 200ms = 5fps
|
|
||||||
}
|
|
||||||
|
|
||||||
void Window::update_display(Bird &bird, std::vector<Pipe> pipes) {
|
void Window::update_display(Bird &bird, std::vector<Pipe> pipes) {
|
||||||
for(std::array<char, COL> &row : m_board) { row.fill('.'); }
|
for(std::array<char, COL> &row : m_board) { row.fill('.'); }
|
||||||
|
|
||||||
m_board[bird.m_body.m_row][bird.m_body.m_col] = bird.m_body.m_symbol;
|
m_board[bird.m_body.m_row][bird.m_body.m_col] = bird.m_body.m_symbol;
|
||||||
for(int i = 0; i < pipes.size(); i++) {
|
for(int i = 0; i < pipes.size(); i++) {
|
||||||
for(int j = 0; j < pipes.front().m_size; j++) {
|
for(int j = 0; j < pipes.front().m_size; j++) {
|
||||||
if(pipes.at(i).m_nodes[j].m_symbol == '|') {
|
if(pipes.at(i).m_nodes[j].m_symbol != '|') continue;
|
||||||
m_board[pipes.at(i).m_nodes[j].m_row][pipes.at(i).m_nodes[j].m_col] = pipes.at(i).m_nodes[j].m_symbol;
|
m_board[pipes.at(i).m_nodes[j].m_row][pipes.at(i).m_nodes[j].m_col] = pipes.at(i).m_nodes[j].m_symbol;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
std::cout << "\033[H" << std::flush;
|
std::cout << "\033[H" << std::flush;
|
||||||
for(std::array<char, COL> &row : m_board) {
|
for(std::array<char, COL> &row : m_board) {
|
||||||
@@ -26,5 +21,5 @@ void Window::update_display(Bird &bird, std::vector<Pipe> pipes) {
|
|||||||
}
|
}
|
||||||
std::cout << "\r\n";
|
std::cout << "\r\n";
|
||||||
}
|
}
|
||||||
tick(200);
|
std::this_thread::sleep_for(std::chrono::milliseconds(200)); // 1000 / fps; 200ms = 5fps
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user