fruit: fixed bug where fruit could generate under tail
This commit is contained in:
+9
-4
@@ -4,6 +4,12 @@
|
||||
#include <vector>
|
||||
#include "globals.hpp"
|
||||
|
||||
struct Point;
|
||||
struct Head;
|
||||
struct Tail;
|
||||
struct Body;
|
||||
struct Fruit;
|
||||
|
||||
struct Point {
|
||||
int m_row;
|
||||
int m_col;
|
||||
@@ -11,12 +17,11 @@ struct Point {
|
||||
Point() {}
|
||||
Point(int x, int y) : m_row(x), m_col(y) {}
|
||||
Point(int x, int y, int dir) : m_row(x), m_col(y), m_direction(dir) {}
|
||||
|
||||
void set_new_point(int row, int col, int dir);
|
||||
};
|
||||
|
||||
struct Head {
|
||||
Head();
|
||||
Head() : m_head(5, 5, 2) {};
|
||||
Point m_head;
|
||||
Point m_previous_head;
|
||||
void get_new_pos();
|
||||
@@ -28,7 +33,7 @@ struct Tail {
|
||||
};
|
||||
|
||||
struct Body {
|
||||
Body();
|
||||
Body() : m_score(0), m_collision(false) {};
|
||||
std::vector<Tail> m_body;
|
||||
int m_score;
|
||||
bool m_collision;
|
||||
@@ -38,7 +43,7 @@ struct Body {
|
||||
};
|
||||
|
||||
struct Fruit {
|
||||
Fruit();
|
||||
Fruit(char (&board)[ROW][COL]);
|
||||
Point m_point;
|
||||
void get_new_pos(char (&board)[ROW][COL], Head &head, int &score);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user