
GameManager.h
By: a guest on Feb 27th, 2010 | syntax:
C++ | size: 1.90 KB | hits: 439 | expires: Never
#ifndef GAMEMANAGER_H
#define GAMEMANAGER_H
//------------------------------------------------------------------------
//
// Name: GameManager.h
//
// Desc: Manages the game states.
//
// Author: Nikko Bertoa 2010 (nicobertoa@gmail.com)
//
//------------------------------------------------------------------------
//
// Headers
//
#include "ImageManager.hpp"
#include "Fps.h"
// Forward
class State;
class GameManager
{
public:
GameManager();
virtual ~GameManager();
//use these methods to initialize the machine
void SetCurrentState(State* s) { m_pCurrentState = s; }
State* CurrentState()const { return m_pCurrentState; }
void SetGlobalState(State* s) { m_pGlobalState = s; }
State* GlobalState()const { return m_pGlobalState; }
void SetPreviousState(State* s) { m_pPreviousState = s; }
State* PreviousState()const { return m_pPreviousState; }
void Run();
void Exit();
//change to a new state
void ChangeState(State* pNewState);
//change state back to the previous state
void RevertToPreviousState() { ChangeState(m_pPreviousState); }
//returns true if the current state's type is equal to the type of the
//class passed as a parameter.
// m_pCurrentState's entity_type == st's entity_type
bool IsInState(const State* st)const { return typeid(*m_pCurrentState) == typeid(st); }
private:
//call this to update the machine
void Update();
void DrawFPS();
State* m_pCurrentState;
//a record of the last state the agent was in
State* m_pPreviousState;
//this is called every time the FSM is updated
State* m_pGlobalState;
sftools::ImageManager m_imgManager;
sf::RenderWindow m_screen;
Fps m_fpsManager;
sf::Font* m_font;
sf::String* m_fpsText;
bool m_close;
};
#endif // GAMEMANAGER_H