I am working on a game, and right now I have followed a GameState manager tutorial but I'm not sure why isn't the code working. It might be because it's an older version of c++ in the tutorial but I can't seem to find how can I fix it.
#pragma once
#include "GameEngine.h"
class GameState
{
public:
virtual void Init() = 0;
virtual void Cleanup() = 0;
virtual void SplashScreen() = 0;
virtual void Pause() = 0;
virtual void Resume() = 0;
virtual void HandleEvents(GameEngine *game) = 0;
virtual void Update(GameEngine *game) = 0;
virtual void Draw(GameEngine *game) = 0;
void ChageState(GameEngine* game,
GameState* state) {
game->ChangeState(state);
}
protected: GameState() {}
};
If I don't game the GameEgine *game and GameState *state and remove every line that uses them my program works okay, my window appears but I can't change the game states which is really important. If nobody has an answer that's okay :)
EDIT: I forgot to show the GameEngine.h file
#pragma once
#include "GameState.h"
#include "include.h"
class GameEngine
{
public:
Recources recource;
void Init(std::string name, int x, int y);
void Cleanup();
void SplashScreen();
void ChangeState(GameState* state);
void PushState(GameState* state);
void PopState();
void HandleEvents();
void Update();
void Draw(sf::RenderWindow &widnow);
bool Running() { return m_running; }
void Quit() { m_running = false; }
private:
// the stack of states
std::vector<GameState*> states;
bool m_running;
};