snake can collide and removed some magic numbers
This commit is contained in:
+11
-3
@@ -3,20 +3,28 @@
|
||||
|
||||
#include "globals.hpp"
|
||||
|
||||
enum Direction {
|
||||
NONE = 0,
|
||||
UP = -2,
|
||||
DOWN = 2,
|
||||
LEFT = -1,
|
||||
RIGHT = 1
|
||||
};
|
||||
|
||||
struct Point {
|
||||
int m_row;
|
||||
int m_col;
|
||||
char m_symbol;
|
||||
int m_direction;
|
||||
enum Direction m_dir;
|
||||
Point() : m_row(-1), m_col(-1), m_symbol('@') {}
|
||||
Point(int x, int y, char s) : m_row(x), m_col(y), m_symbol(s) {}
|
||||
Point(int x, int y, char s, int d) : m_row(x), m_col(y), m_symbol(s), m_direction(d) {}
|
||||
void to_string();
|
||||
void set_new_point(int row, int col);
|
||||
};
|
||||
|
||||
int get_score();
|
||||
void determine_index_zero_pos(Point* (*board)[COL], Point** segments);
|
||||
void move_tail_indicies(Point** segments);
|
||||
void on_fruit_eaten(Point* (*board)[COL], Point** segments);
|
||||
bool segment_overlap(Point** segments);
|
||||
|
||||
#endif // ELEMENT_HPP
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
#ifndef GLOBALS_HPP
|
||||
#define GLOBALS_HPP
|
||||
#define ROW 10
|
||||
#define COL 10
|
||||
#define ROW 11
|
||||
#define COL 11
|
||||
#endif // GLOBALS_HPP
|
||||
|
||||
+3
-2
@@ -1,10 +1,11 @@
|
||||
#ifndef INPUT_HPP
|
||||
#define INPUT_HPP
|
||||
#include "element.hpp"
|
||||
|
||||
struct Input {
|
||||
int m_current_key = 0;
|
||||
enum Direction m_current_key = NONE;
|
||||
int m_getch = 0;
|
||||
void get_input(int &d, bool &r);
|
||||
void get_input(enum Direction &dir, bool &r);
|
||||
};
|
||||
|
||||
#endif // INPUT_HPP
|
||||
|
||||
Reference in New Issue
Block a user