snake/include/Player.h

39 lines
602 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 Color& color_in);
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};
};