diff --git a/src/gamestate.cpp b/src/gamestate.cpp index 14b3ec9..8394f78 100755 --- a/src/gamestate.cpp +++ b/src/gamestate.cpp @@ -96,14 +96,20 @@ namespace snakeplusplus gameBoard.clear(); sf::Vector2f boardDimensions = GetGameBoundaries(); gameBoard.resize(boardDimensions.y, std::vector (boardDimensions.x, ' ')); - player.headLocation.x = 4; - player.headLocation.y = 5; - char* locationState = &gameBoard.at(player.headLocation.y).at(player.headLocation.x); - player.body.push(locationState); - *player.body.front() = 'O'; - playerFood.GenerateNewFood(GetGameBoundaries()); - sf::Vector2f newLocation = playerFood.location; - gameBoard.at(newLocation.y).at(newLocation.x) = 'X'; + // Snake setup + { + player.headLocation.x = GenerateRandomNumber(boardDimensions.x); + player.headLocation.y = GenerateRandomNumber(boardDimensions.y); + char* locationState = &gameBoard.at(player.headLocation.y).at(player.headLocation.x); + player.body.push(locationState); + *locationState = 'O'; + } + // Food setup + { + playerFood.GenerateNewFood(boardDimensions); + sf::Vector2f newLocation = playerFood.location; + gameBoard.at(newLocation.y).at(newLocation.x) = 'X'; + } return; } diff --git a/src/snake.cpp b/src/snake.cpp index f6c635b..4dfc7f4 100755 --- a/src/snake.cpp +++ b/src/snake.cpp @@ -6,7 +6,6 @@ namespace snakeplusplus { - void Snake::Pop(void) { *(body.front()) = ' ';