2022-08-15 23:51:18 -05:00
|
|
|
// Snake.cpp
|
2022-08-21 02:51:33 -05:00
|
|
|
#include <queue>
|
2023-03-17 17:27:02 -05:00
|
|
|
#include <SFML/Graphics.hpp>
|
2023-08-18 19:09:57 -05:00
|
|
|
#include "common.hpp"
|
2023-04-06 19:27:10 -05:00
|
|
|
#include "snake.hpp"
|
2022-07-25 15:40:45 -05:00
|
|
|
|
2024-08-02 19:45:07 -05:00
|
|
|
void Snake::Pop(void)
|
2023-03-12 08:50:50 -05:00
|
|
|
{
|
2024-08-02 19:45:07 -05:00
|
|
|
*(body.front()) = ' ';
|
|
|
|
body.pop();
|
|
|
|
return;
|
|
|
|
}
|
2023-04-06 19:27:10 -05:00
|
|
|
|
2024-08-02 19:45:07 -05:00
|
|
|
void Snake::Reset(void)
|
|
|
|
{
|
|
|
|
while (!body.empty()) Pop();
|
|
|
|
speed.x = 0;
|
|
|
|
speed.y = 0;
|
|
|
|
return;
|
|
|
|
}
|
2023-08-10 18:47:40 -05:00
|
|
|
|
2024-08-02 19:45:07 -05:00
|
|
|
// 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;
|
2022-07-26 16:56:26 -05:00
|
|
|
}
|