Game finishes, but is buggy. Proper grid needed
This commit is contained in:
@@ -20,7 +20,9 @@ private:
|
||||
SnakeFood playerFood;
|
||||
Snake player;
|
||||
sf::Time delay;
|
||||
void DisplayEndScreen(void);
|
||||
void GetKeyboardInput(void);
|
||||
bool PlayerWantsToContinue(void);
|
||||
void RegenerateFood(void);
|
||||
void RunGameLoop(void);
|
||||
void RenderWindow(void);
|
||||
|
||||
+5
-1
@@ -10,21 +10,25 @@
|
||||
class Snake
|
||||
{
|
||||
public:
|
||||
bool gameFinished = false;
|
||||
Snake(void);
|
||||
Snake(sf::Vector2f head);
|
||||
void DisplaySnake(sf::RenderWindow& window);
|
||||
sf::RectangleShape GetSnakeHead(void);
|
||||
sf::Vector2f GetSnakeHeadPosition(void);
|
||||
bool IsTouchingObject(sf::RectangleShape object);
|
||||
void MoveSnake(SnakeFood* playerFood);
|
||||
void Reset(void);
|
||||
void UpdateDirection(int newDirection);
|
||||
protected:
|
||||
;
|
||||
private:
|
||||
std::deque<sf::RectangleShape> snakeBody;
|
||||
sf::Vector2f bodyPartSize;
|
||||
int snakeDirection = 0;
|
||||
void AddBodyPart(sf::RectangleShape newBodyPart);
|
||||
sf::Vector2f CalculateNewPosition(sf::Vector2f position);
|
||||
bool CheckBoundaries(void);
|
||||
void CreateHead(void);
|
||||
bool IsSelfCollision(sf::RectangleShape testRectangle);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user