wip
This commit is contained in:
+3
-3
@@ -4,12 +4,12 @@
|
||||
#include "point.hpp"
|
||||
|
||||
struct Fruit {
|
||||
Fruit();
|
||||
int unsigned m_row;
|
||||
int unsigned m_col;
|
||||
|
||||
Point m_point;
|
||||
Fruit();
|
||||
|
||||
void create_point();
|
||||
void reset(std::array<std::array<char, COL>, ROW> &arr, int row, int col, int &score);
|
||||
void reset(std::array<std::array<char, COL>, ROW> &arr, int row, int col, int &score, int &count);
|
||||
};
|
||||
#endif // FRUIT_HPP
|
||||
|
||||
@@ -5,5 +5,6 @@
|
||||
|
||||
constexpr uint16_t ROW = 10;
|
||||
constexpr uint16_t COL = 10;
|
||||
constexpr uint16_t FPS = 5;
|
||||
|
||||
#endif // GLOBALS_HPP
|
||||
|
||||
+3
-2
@@ -2,8 +2,9 @@
|
||||
#define INPUT_HPP
|
||||
|
||||
struct Input {
|
||||
char m_current_key = ' ';
|
||||
void get_input();
|
||||
char m_current_key = ' ';
|
||||
char m_old_key = ' ';
|
||||
void get_input();
|
||||
};
|
||||
|
||||
#endif // INPUT_HPP
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ struct Point {
|
||||
|
||||
std::string to_string() const;
|
||||
void clear(std::array<std::array<char, COL>, ROW> &arr) const;
|
||||
std::pair<int, int> get_new_point(int direction, int row, int col);
|
||||
void get_new_point(int direction);
|
||||
};
|
||||
|
||||
#endif // POINT_HPP
|
||||
|
||||
+6
-7
@@ -5,14 +5,13 @@
|
||||
#include "point.hpp"
|
||||
|
||||
struct Snake {
|
||||
Snake(int default_direction);
|
||||
void create_tail(int row, int col);
|
||||
std::pair<int, int> get_new_point(int tail_index, int direction, int row, int col);
|
||||
void update_tails_count();
|
||||
|
||||
std::vector<Point> m_tails;
|
||||
Snake(int default_direction, int row, int col);
|
||||
Point m_head;
|
||||
std::vector<Point> m_tails;
|
||||
int m_direction; // 1: Down, 2: Up, 3: Left, 4: Right
|
||||
int m_tails_count;
|
||||
|
||||
void create_tail(int row, int col); // Adds a new tail to m_tails at { row, col }
|
||||
void get_new_tail_point(int tail_index, int direction);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -5,9 +5,11 @@
|
||||
|
||||
struct Window {
|
||||
std::array<std::array<char, COL>, ROW> m_board;
|
||||
int m_score;
|
||||
// Initializes board with . for each value
|
||||
Window();
|
||||
|
||||
void draw_score();
|
||||
void draw_window();
|
||||
void clear_window();
|
||||
void tick(double frames_per_second);
|
||||
|
||||
Reference in New Issue
Block a user