feat: added bird struct and movement, added pause feature, separated fps method to tick()
This commit is contained in:
@@ -1,15 +1,20 @@
|
||||
#ifndef ELEMENTS_HPP
|
||||
#define ELEMENTS_HPP
|
||||
|
||||
#include "globals.hpp"
|
||||
|
||||
struct Point {
|
||||
Point();
|
||||
Point() : m_row(0), m_col(0) {};
|
||||
Point(int row, int col) : m_row(row), m_col(col) {};
|
||||
int m_row;
|
||||
int m_col;
|
||||
};
|
||||
|
||||
struct Bird {
|
||||
Point m_body;
|
||||
Bird() : m_fly(false) {};
|
||||
Point m_body {(ROW/2), 2};
|
||||
bool m_fly;
|
||||
void move();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
#ifndef GLOBALS_HPP
|
||||
#define GLOBALS_HPP
|
||||
|
||||
constexpr int ROW = 10;
|
||||
constexpr int COL = 10;
|
||||
constexpr int ROW = 11;
|
||||
constexpr int COL = 20;
|
||||
|
||||
#endif
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@
|
||||
|
||||
struct Input {
|
||||
int _getch = 0;
|
||||
void get_input(bool &running, Bird &bird);
|
||||
void get_input(bool &running, bool &pause, Bird &bird);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
struct Window {
|
||||
std::array<std::array<char, COL>, ROW> m_board = {};
|
||||
void update_display(Bird &bird);
|
||||
void tick(int fps);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user