snakeplusplus/src/gamestate.hpp

52 lines
1.2 KiB
C++
Raw Normal View History

// GameState.h
#ifndef GAMESTATE_HPP
#define GAMESTATE_HPP
#include <SFML/Graphics.hpp>
#include <memory>
2023-10-13 19:07:08 -05:00
#include "botinterface.hpp"
#include "snake.hpp"
#include "playerinterface.hpp"
const int kUnitSpeed = 1;
2023-08-19 23:32:53 -05:00
class GameEngine
{
public:
GameEngine();
void Start(void);
void Reset(void);
void AddIteration(void);
sf::Vector2f GetGameBoundaries(void);
struct GameState {
unsigned char m_bIsGameOver : 1 = 0;
unsigned char m_bIsBotControlled : 1 = 1;
unsigned char m_bNoDisplay : 1 = 0;
unsigned char _3 : 1 = 0;
unsigned char _4 : 1 = 0;
unsigned char _5 : 1 = 0;
unsigned char _6 : 1 = 0;
unsigned char _7 : 1 = 0;
} state;
private:
std::vector< std::vector<GameSpace> > gameBoard;
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 UpdateAverage();
int totalLength = 0;
int amountPlayed = 0;
double average = 0;
};
inline std::unique_ptr<GameEngine> g_pEngine;
#endif