From 152a2e0a8aa56dd36e79be8f9e2403f138c043e7 Mon Sep 17 00:00:00 2001 From: DarthMooMancer Date: Thu, 4 Sep 2025 19:23:54 -0400 Subject: [PATCH] feat: collision between bird and pipes --- src/input.cpp | 2 -- src/main.cpp | 8 ++++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/input.cpp b/src/input.cpp index 1afea6e..58250d1 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -1,5 +1,4 @@ #include -#include #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) { diff --git a/src/main.cpp b/src/main.cpp index 7b018f9..20e84f1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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) {