feat: collision between bird and pipes
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
#include <ncurses.h>
|
||||
#include <iostream>
|
||||
#include "input.hpp"
|
||||
|
||||
void Input::get_input(bool &running, bool &pause, Bird &bird) {
|
||||
@@ -9,7 +8,6 @@ void Input::get_input(bool &running, bool &pause, Bird &bird) {
|
||||
noecho();
|
||||
|
||||
_getch = getch();
|
||||
std::cout << _getch << std::endl;
|
||||
|
||||
endwin();
|
||||
if(_getch == 32) {
|
||||
|
||||
@@ -40,6 +40,14 @@ int main() {
|
||||
if(pipes.front().m_nodes->m_col < 3) {
|
||||
_delete_pipe(pipes);
|
||||
}
|
||||
for(int i = 0; i < pipes.front().m_size; i++) {
|
||||
if(pipes.front().m_nodes[i].m_col == bird.m_body.m_col) {
|
||||
if(pipes.front().m_nodes[i].m_row == bird.m_body.m_row) {
|
||||
running = false;
|
||||
std::cout << "You died!" << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
window.update_display(bird, pipes);
|
||||
frames++;
|
||||
if(frames > 4) {
|
||||
|
||||
Reference in New Issue
Block a user