Added random generation on start

This commit is contained in:
Trimutex 2023-08-18 18:15:21 -05:00
parent 709cf26f99
commit 441c52ab0f

View File

@ -100,10 +100,9 @@ namespace snakeplusplus
char* locationState = &gameBoard.at(player.headLocation.y).at(player.headLocation.x); char* locationState = &gameBoard.at(player.headLocation.y).at(player.headLocation.x);
player.body.push(locationState); player.body.push(locationState);
*player.body.front() = 'O'; *player.body.front() = 'O';
playerFood.location.x = 2; playerFood.GenerateNewFood(GetGameBoundaries());
playerFood.location.y = 2; sf::Vector2f newLocation = playerFood.location;
playerFood.food = &gameBoard.at(2).at(2); gameBoard.at(newLocation.y).at(newLocation.x) = 'X';
*playerFood.food = 'X';
return; return;
} }