Fixed snake not showing on start
This commit is contained in:
parent
49182ce07d
commit
71dfa043a9
@ -1,6 +1,7 @@
|
|||||||
// GameState.cpp
|
// GameState.cpp
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <SFML/Graphics.hpp>
|
#include <SFML/Graphics.hpp>
|
||||||
|
#include <tuple>
|
||||||
#include "common.hpp"
|
#include "common.hpp"
|
||||||
#include "playerinterface.hpp"
|
#include "playerinterface.hpp"
|
||||||
#include "gamestate.hpp"
|
#include "gamestate.hpp"
|
||||||
@ -58,6 +59,7 @@ namespace snakeplusplus
|
|||||||
|
|
||||||
void GameEngine::PlaceNewSnakePart(sf::Vector2f location)
|
void GameEngine::PlaceNewSnakePart(sf::Vector2f location)
|
||||||
{
|
{
|
||||||
|
if (!player.speed.x && !player.speed.y) { return; }
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
char* locationState;
|
char* locationState;
|
||||||
|
@ -74,25 +74,22 @@ namespace snakeplusplus
|
|||||||
void PlayerOutput::DisplayGameState(std::vector< std::vector<char> >& gameBoard)
|
void PlayerOutput::DisplayGameState(std::vector< std::vector<char> >& gameBoard)
|
||||||
{
|
{
|
||||||
CheckWindowEvents();
|
CheckWindowEvents();
|
||||||
sf::Vector2f location;
|
|
||||||
char* letterOnBoard;
|
char* letterOnBoard;
|
||||||
for (float y = 0; y < gameBoundaries.y; y++)
|
for (float y = 0; y < gameBoundaries.y; y++)
|
||||||
{
|
{
|
||||||
for (float x = 0; x < gameBoundaries.x; x++)
|
for (float x = 0; x < gameBoundaries.x; x++)
|
||||||
{
|
{
|
||||||
location.x = x;
|
letterOnBoard = &gameBoard.at(y).at(x);
|
||||||
location.y = y;
|
|
||||||
letterOnBoard = &gameBoard.at(location.y).at(location.x);
|
|
||||||
switch (*letterOnBoard)
|
switch (*letterOnBoard)
|
||||||
{
|
{
|
||||||
case 'O':
|
case 'O':
|
||||||
DrawSnake(location);
|
DrawSnake(sf::Vector2f(x, y));
|
||||||
break;
|
break;
|
||||||
case 'X':
|
case 'X':
|
||||||
DrawFood(location);
|
DrawFood(sf::Vector2f(x,y));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
DrawEmpty(location);
|
DrawEmpty(sf::Vector2f(x,y));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user