Skip to content

Instantly share code, notes, and snippets.

@luizdepra
Created August 17, 2012 19:51
Show Gist options
  • Save luizdepra/3382006 to your computer and use it in GitHub Desktop.
Save luizdepra/3382006 to your computer and use it in GitHub Desktop.
StateMachine State
#ifndef __STATE_H__
#define __STATE_H__
#include <string>
class State
{
public:
State(const std::string &name, void (*startFunction)(), void (*updateFunction)(float), void (*stopFunction)());
~State();
std::string getName();
void start();
void update(float delta);
void stop();
private:
std::string _name;
void (*_startFunction);
void (*_updateFunction)(float);
void (*_stopFunction)();
}
#endif
#ifndef __STATE_H__
#define __STATE_H__
#include <string>
#include <map>
#include "State.h"
class StateMachine
{
public:
StateMachine();
~StateMachine();
void createState(const std::string &name, void (*startFunction)(), void (*updateFunction)(float), void (*stopFunction)());
void addState(const State &state);
void remove
void update(float delta);
private:
std::map<std::string, State> _stateMap;
}
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment