feat: fruits, globals, input, snake, point, window
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
#ifndef FRUIT_HPP
|
||||
#define FRUIT_HPP
|
||||
|
||||
#include "point.hpp"
|
||||
|
||||
struct Fruit {
|
||||
int unsigned m_row;
|
||||
int unsigned m_col;
|
||||
|
||||
Point m_point;
|
||||
Fruit();
|
||||
void create_point();
|
||||
};
|
||||
#endif // FRUIT_HPP
|
||||
@@ -0,0 +1,7 @@
|
||||
#ifndef GLOBALS_HPP
|
||||
#define GLOBALS_HPP
|
||||
|
||||
constexpr unsigned int ROW = 10;
|
||||
constexpr unsigned int COL = 10;
|
||||
|
||||
#endif // GLOBALS_HPP
|
||||
@@ -0,0 +1,9 @@
|
||||
#ifndef INPUT_HPP
|
||||
#define INPUT_HPP
|
||||
|
||||
struct Input {
|
||||
char m_current_key = ' ';
|
||||
void get_input();
|
||||
};
|
||||
|
||||
#endif // INPUT_HPP
|
||||
@@ -0,0 +1,18 @@
|
||||
#ifndef POINT_HPP
|
||||
#define POINT_HPP
|
||||
|
||||
#include <array>
|
||||
#include "globals.hpp"
|
||||
|
||||
struct Point {
|
||||
int m_row;
|
||||
int m_col;
|
||||
Point() {}
|
||||
Point(int x, int y) : m_row(x), m_col(y) {}
|
||||
|
||||
std::string get_point() const;
|
||||
void clear(std::array<std::array<char, COL>, ROW> &arr) const;
|
||||
std::pair<int, int> get_point(int direction, int row, int col);
|
||||
};
|
||||
|
||||
#endif // POINT_HPP
|
||||
+6
-2
@@ -1,7 +1,11 @@
|
||||
#ifndef SNAKE_HPP
|
||||
#define SNAKE_HPP
|
||||
|
||||
void create_snake();
|
||||
void draw_snake();
|
||||
struct Snake {
|
||||
Snake(int default_direction);
|
||||
int get_direction() const;
|
||||
void set_direction(int x);
|
||||
int direction; // 1: Down, 2: Up, 3: Left, 4: Right
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
#ifndef WINDOW_HPP
|
||||
#define WINDOW_HPP
|
||||
#include <array>
|
||||
#include "globals.hpp"
|
||||
|
||||
struct Window {
|
||||
std::array<std::array<char, COL>, ROW> m_board;
|
||||
// Initializes board with . for each value
|
||||
Window();
|
||||
|
||||
void draw_window();
|
||||
void clear_window();
|
||||
void tick(double frames_per_second);
|
||||
void update_loop(int fps);
|
||||
};
|
||||
|
||||
#endif // WINDOW_HPP
|
||||
Reference in New Issue
Block a user