39 lines
625 B
C++
39 lines
625 B
C++
#pragma once
|
|
#include <SFML/Graphics.hpp>
|
|
|
|
#include <Util.h>
|
|
|
|
enum class Direction
|
|
{
|
|
up,
|
|
down,
|
|
left,
|
|
right
|
|
};
|
|
|
|
struct SnakeNode
|
|
{
|
|
SnakeNode(sf::Vector2u gridPos_in, const sf::Color& color_in = sf::Color::White);
|
|
sf::Vector2u gridPos{};
|
|
sf::Vector2u previousGridPos{};
|
|
Color color{};
|
|
|
|
[[nodiscard]] sf::Vector2f windowPos(sf::Vector2f gameBoundsOrigin, float size) const;
|
|
};
|
|
|
|
struct Player
|
|
{
|
|
Player() = default;
|
|
|
|
SnakeNode& head();
|
|
|
|
std::vector<SnakeNode> body;
|
|
|
|
int score{};
|
|
Direction facing{Direction::up};
|
|
Direction inputBuffer{};
|
|
bool left{false};
|
|
bool right{false};
|
|
bool up{false};
|
|
bool down{false};
|
|
}; |