Moved snakeFood to be a separate class
Moved snakeFood to be a separate class and a temporary unused function was added for randomly generating the new location.
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
#include <random>
|
||||
#include "SnakeFood.h"
|
||||
|
||||
SnakeFood::SnakeFood()
|
||||
{
|
||||
snakeFoodObject.setSize(sf::Vector2f(25,25));
|
||||
snakeFoodObject.setFillColor(sf::Color::Red);
|
||||
}
|
||||
|
||||
SnakeFood::SnakeFood(sf::Vector2f snakeFoodSize)
|
||||
{
|
||||
snakeFoodObject.setSize(snakeFoodSize);
|
||||
snakeFoodObject.setFillColor(sf::Color::Red);
|
||||
}
|
||||
|
||||
void SnakeFood::GenerateNewLocation(int maxLocation)
|
||||
{
|
||||
sf::Vector2f newPosition;
|
||||
std::default_random_engine generator;
|
||||
std::uniform_int_distribution<int> distribution(0, maxLocation);
|
||||
newPosition.x = distribution(generator);
|
||||
newPosition.y = distribution(generator);
|
||||
snakeFoodObject.setPosition(newPosition);
|
||||
}
|
||||
Reference in New Issue
Block a user