snakeplusplus/include/Snake.h

37 lines
863 B
C
Raw Normal View History

// Snake.h
#ifndef SNAKE_H
#define SNAKE_H
#include <deque>
#include <SFML\Graphics.hpp>
#include "SnakeFood.h"
class Snake
{
public:
bool gameFinished = false;
Snake(void);
void DisplaySnake(sf::RenderWindow& window);
sf::RectangleShape GetSnakeHead(void);
sf::Vector2f GetSnakeHeadPosition(void);
2023-03-12 08:50:50 -05:00
bool IsTouchingObject(sf::RectangleShape object);
void MoveSnake(SnakeFood* playerFood);
void Reset(void);
void UpdateDirection(int newDirection);
2023-03-12 08:50:50 -05:00
protected:
;
private:
std::deque<sf::RectangleShape> snakeBody;
sf::Vector2f bodyPartSize;
2023-03-12 08:50:50 -05:00
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);
};
#endif