52 lines
1.3 KiB
C++
Executable File
52 lines
1.3 KiB
C++
Executable File
// GameState.h
|
|
#ifndef GAMESTATE_HPP
|
|
#define GAMESTATE_HPP
|
|
|
|
#include <SFML/Graphics.hpp>
|
|
#include <memory>
|
|
#include "botinterface.hpp"
|
|
#include "common.hpp"
|
|
#include "snake.hpp"
|
|
#include "playerinterface.hpp"
|
|
|
|
const int kUnitSpeed = 1;
|
|
|
|
class GameEngine {
|
|
public:
|
|
GameEngine(void);
|
|
void Start(void);
|
|
void Reset(void);
|
|
sf::Vector2f GetGameBoundaries(void);
|
|
struct GameState {
|
|
unsigned char m_bIsGameOver : 1 = 0;
|
|
unsigned char m_bIsBotControlled : 1 = 0;
|
|
unsigned char m_bNoDisplay : 1 = 0;
|
|
unsigned char m_bSmart : 1 = 0;
|
|
unsigned char m_bSkipIterations : 1 = 0;
|
|
unsigned char _5 : 1 = 0;
|
|
unsigned char _6 : 1 = 0;
|
|
unsigned char _7 : 1 = 0;
|
|
} state;
|
|
std::vector< std::vector<GameSpace> > gameBoard;
|
|
PlayerDirection GetCurrentDirection(void);
|
|
sf::Vector2f GetCurrentDirectionRaw(void);
|
|
int GetPlayerSize(void);
|
|
sf::Vector2f GetHeadLocation(void);
|
|
sf::Vector2f GetFoodLocation(void);
|
|
private:
|
|
PlayerOutput graphics;
|
|
Snake player;
|
|
Food playerFood;
|
|
AISnake bot;
|
|
void Loop(void);
|
|
sf::Vector2f MovePlayer(void);
|
|
void PlaceNewSnakePart(sf::Vector2f location);
|
|
void RegenerateFood(void);
|
|
void PrepareGameBoard(void);
|
|
void UpdatePlayerSpeed(void);
|
|
};
|
|
|
|
inline std::unique_ptr<GameEngine> g_pEngine;
|
|
|
|
#endif
|