This commit is contained in:
DarthMooMancer
2025-08-21 09:17:37 -04:00
parent a128048a8f
commit 5e887e3688
12 changed files with 134 additions and 133 deletions
+3 -3
View File
@@ -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
+1
View File
@@ -5,5 +5,6 @@
constexpr uint16_t ROW = 10;
constexpr uint16_t COL = 10;
constexpr uint16_t FPS = 5;
#endif // GLOBALS_HPP
+3 -2
View File
@@ -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
View File
@@ -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
View File
@@ -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
+2
View File
@@ -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);