29 lines
514 B
C++
Executable File
29 lines
514 B
C++
Executable File
// Snake.cpp
|
|
#include <queue>
|
|
#include <SFML/Graphics.hpp>
|
|
#include "common.hpp"
|
|
#include "snake.hpp"
|
|
|
|
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;
|
|
}
|