snakeplusplus/src/snake.cpp
2023-08-19 23:32:53 -05:00

32 lines
622 B
C++
Executable File

// Snake.cpp
#include <queue>
#include <SFML/Graphics.hpp>
#include "common.hpp"
#include "snake.hpp"
namespace snakeplusplus
{
void Snake::Pop(void)
{
*(body.front()) = ' ';
body.pop();
return;
}
void Snake::Reset(void)
{
while (!body.empty()) Pop();
speed.x = 0;
speed.y = 0;
return;
}
// Returns a new food object for the snakeFood
void Food::GenerateNewFood(sf::Vector2f boundaries)
{
location.x = GenerateRandomNumber(boundaries.x);
location.y = GenerateRandomNumber(boundaries.y);
return;
}
}