The open source repository for the action RPG game in development by Sig Productions titled 'Adventures in Lestoria'!
https://forums.lestoria.net
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
1.1 KiB
43 lines
1.1 KiB
#pragma once
|
|
#include <map>
|
|
#include <iostream>
|
|
|
|
class Crawler;
|
|
|
|
namespace States{
|
|
enum State{
|
|
GAME_RUN,
|
|
MAIN_MENU,
|
|
};
|
|
};
|
|
|
|
class GameState{
|
|
public:
|
|
inline static GameState*STATE=nullptr;
|
|
inline static std::map<States::State,GameState*>states;
|
|
static void Initialize();
|
|
virtual void OnStateChange(GameState*prevState)=0;
|
|
virtual void OnUserUpdate(Crawler*game)=0;
|
|
virtual void Draw(Crawler*game)=0;
|
|
static inline void ChangeState(States::State newState){
|
|
GameState*prevState=STATE;
|
|
if(!states.count(newState)){
|
|
std::cout<<"WARNING! State not defined for state "<<newState<<"!"<<std::endl;
|
|
throw;
|
|
}
|
|
STATE=states.at(newState);
|
|
STATE->OnStateChange(prevState);
|
|
}
|
|
};
|
|
|
|
class State_GameRun:public GameState{
|
|
virtual void OnStateChange(GameState*prevState)override;
|
|
virtual void OnUserUpdate(Crawler*game)override;
|
|
virtual void Draw(Crawler*game)override;
|
|
};
|
|
|
|
class State_MainMenu:public GameState{
|
|
virtual void OnStateChange(GameState*prevState)override;
|
|
virtual void OnUserUpdate(Crawler*game)override;
|
|
virtual void Draw(Crawler*game)override;
|
|
}; |