diff --git a/src/GameState.cpp b/src/GameState.cpp index c293cf6..dcc6e66 100644 --- a/src/GameState.cpp +++ b/src/GameState.cpp @@ -28,10 +28,6 @@ void GameState::startNewGame() int snakeDirection = 0; Snake player(sf::Vector2f(25,25)); SnakeFood playerFood(sf::Vector2f(25,25)); - // sf::RectangleShape snakeHead(sf::Vector2f(25,25)); - sf::RectangleShape snakeFood(sf::Vector2f(25,25)); - snakeFood.setFillColor(sf::Color::Red); - snakeFood.setPosition(25,25); while (gameWindow.isOpen()) { diff --git a/src/GameState.h b/src/GameState.h index ad8c7bd..f5ccb13 100644 --- a/src/GameState.h +++ b/src/GameState.h @@ -2,7 +2,6 @@ #ifndef GAMESTATE_H #define GAMESTATE_H #include -#include class GameState { diff --git a/src/Snake.cpp b/src/Snake.cpp index 8e4887d..824ddcb 100644 --- a/src/Snake.cpp +++ b/src/Snake.cpp @@ -1,6 +1,5 @@ #include #include -#include #include "Snake.h" // Test for collision between two objects diff --git a/src/SnakeFood.cpp b/src/SnakeFood.cpp index 464ea25..b5c0edb 100644 --- a/src/SnakeFood.cpp +++ b/src/SnakeFood.cpp @@ -13,12 +13,11 @@ SnakeFood::SnakeFood(sf::Vector2f snakeFoodSize) snakeFoodObject.setFillColor(sf::Color::Red); } -void SnakeFood::GenerateNewLocation(int maxLocation) +int SnakeFood::GenerateNewLocation(int maxLocation) { - sf::Vector2f newPosition; + int newPosition; std::default_random_engine generator; std::uniform_int_distribution distribution(0, maxLocation); - newPosition.x = distribution(generator); - newPosition.y = distribution(generator); - snakeFoodObject.setPosition(newPosition); + newPosition = distribution(generator); + return newPosition; } diff --git a/src/SnakeFood.h b/src/SnakeFood.h index 4c25630..18717d7 100644 --- a/src/SnakeFood.h +++ b/src/SnakeFood.h @@ -10,7 +10,7 @@ public: sf::RectangleShape snakeFoodObject; SnakeFood(); SnakeFood(sf::Vector2f snakeFoodSize); - void GenerateNewLocation(int maxLocation); + int GenerateNewLocation(int maxLocation); }; #endif