45 lines
963 B
C++
Executable File
45 lines
963 B
C++
Executable File
// GameState.h
|
|
#ifndef GAMESTATE_HPP
|
|
#define GAMESTATE_HPP
|
|
|
|
#include <SFML/Graphics.hpp>
|
|
#include <memory>
|
|
#include "botinterface.hpp"
|
|
#include "snake.hpp"
|
|
#include "playerinterface.hpp"
|
|
|
|
const int kUnitSpeed = 1;
|
|
|
|
class GameEngine
|
|
{
|
|
public:
|
|
GameEngine();
|
|
void Start(void);
|
|
void Reset(void);
|
|
void AddIteration(void);
|
|
sf::Vector2f GetGameBoundaries(void);
|
|
private:
|
|
std::vector< std::vector<char> > gameBoard;
|
|
PlayerOutput graphics;
|
|
Snake player;
|
|
Food playerFood;
|
|
AISnake bot;
|
|
bool isGameOver = 0;
|
|
bool isBotControlled = 1;
|
|
void DisplayEndScreen(void);
|
|
void Loop(void);
|
|
sf::Vector2f MovePlayer(void);
|
|
void PlaceNewSnakePart(sf::Vector2f location);
|
|
void RegenerateFood(void);
|
|
void PrepareGameBoard(void);
|
|
void UpdatePlayerSpeed();
|
|
void UpdateAverage();
|
|
int totalLength = 0;
|
|
int amountPlayed = 0;
|
|
double average = 0;
|
|
};
|
|
|
|
inline std::unique_ptr<GameEngine> g_pEngine;
|
|
|
|
#endif
|