Fixed generation issue with snakeFood
Fixed generation issue with snakeFood and game should be fully playable without an official end screen implemented. So when the snake gets stuck or the game finishes, there is nothing to close the game automatically.
This commit is contained in:
+11
-1
@@ -1,8 +1,8 @@
|
||||
// SnakeFood.cpp
|
||||
#include <iostream>
|
||||
#include <SFML\Graphics.hpp>
|
||||
#include "GeneralFunctions.h"
|
||||
#include "SnakeFood.h"
|
||||
#include "Snake.h"
|
||||
|
||||
SnakeFood::SnakeFood()
|
||||
{
|
||||
@@ -29,3 +29,13 @@ void SnakeFood::GenerateNewLocation(int horizontalLocation, int verticalLocation
|
||||
snakeFoodObject.setPosition(newPosition);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
int SnakeFood::GenerateRandomNumber(int generationLimit)
|
||||
{
|
||||
int generatedNumber;
|
||||
std::uniform_int_distribution<> distribution(0, generationLimit);
|
||||
generatedNumber = distribution(generator);
|
||||
generatedNumber -= (generatedNumber % 25);
|
||||
return generatedNumber;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user