feat: added bird, removed line in readme as it no longer applies
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
#include "elements.hpp"
|
||||
|
||||
Point::Point() {
|
||||
m_row = 0;
|
||||
m_col = 0;
|
||||
}
|
||||
|
||||
+4
-1
@@ -1,7 +1,7 @@
|
||||
#include <ncurses.h>
|
||||
#include "input.hpp"
|
||||
|
||||
void Input::get_input(bool &running) {
|
||||
void Input::get_input(bool &running, Bird &bird) {
|
||||
while(running) {
|
||||
initscr();
|
||||
cbreak();
|
||||
@@ -10,6 +10,9 @@ void Input::get_input(bool &running) {
|
||||
_getch = getch();
|
||||
|
||||
endwin();
|
||||
if(_getch == 32) {
|
||||
|
||||
}
|
||||
if(_getch == 113) {
|
||||
running = false;
|
||||
}
|
||||
|
||||
+4
-2
@@ -2,16 +2,18 @@
|
||||
#include <thread>
|
||||
#include "window.hpp"
|
||||
#include "input.hpp"
|
||||
#include "elements.hpp"
|
||||
|
||||
int main() {
|
||||
Window window;
|
||||
Input input;
|
||||
Bird bird;
|
||||
bool running = true;
|
||||
|
||||
std::thread input_thread(&Input::get_input, &input, std::ref(running));
|
||||
std::thread input_thread(&Input::get_input, &input, std::ref(running), std::ref(bird));
|
||||
|
||||
while (running) {
|
||||
window.update_display();
|
||||
window.update_display(bird);
|
||||
}
|
||||
|
||||
input_thread.join();
|
||||
|
||||
+3
-1
@@ -3,9 +3,11 @@
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
|
||||
void Window::update_display() {
|
||||
void Window::update_display(Bird &bird) {
|
||||
for(std::array<char, COL> &row : m_board) { row.fill('.'); }
|
||||
|
||||
m_board[bird.m_body.m_row][bird.m_body.m_col] = '*';
|
||||
|
||||
std::cout << "\033[H" << std::flush;
|
||||
for(std::array<char, COL> &row : m_board) {
|
||||
for(char &col : row) {
|
||||
|
||||
Reference in New Issue
Block a user