2023-04-06 19:27:10 -05:00
|
|
|
// GameState.h
|
|
|
|
#ifndef GAMESTATE_HPP
|
|
|
|
#define GAMESTATE_HPP
|
|
|
|
|
|
|
|
#include <SFML/Graphics.hpp>
|
2024-08-02 19:45:07 -05:00
|
|
|
#include <memory>
|
2023-10-13 19:07:08 -05:00
|
|
|
#include "botinterface.hpp"
|
2023-04-06 19:27:10 -05:00
|
|
|
#include "snake.hpp"
|
|
|
|
#include "playerinterface.hpp"
|
|
|
|
|
2024-08-02 19:45:07 -05:00
|
|
|
const int kUnitSpeed = 1;
|
2023-08-19 23:32:53 -05:00
|
|
|
|
2024-08-02 19:45:07 -05:00
|
|
|
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;
|
|
|
|
};
|
2023-04-06 19:27:10 -05:00
|
|
|
|
2024-08-02 19:50:48 -05:00
|
|
|
inline std::unique_ptr<GameEngine> g_pEngine;
|
|
|
|
|
2023-04-06 19:27:10 -05:00
|
|
|
#endif
|