Skip to content

Instantly share code, notes, and snippets.

@awstanley
Created December 5, 2014 00:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save awstanley/d7a79552ae1f86d3a45b to your computer and use it in GitHub Desktop.
Save awstanley/d7a79552ae1f86d3a45b to your computer and use it in GitHub Desktop.
#include <stdint.h> // uint8_t
class Scene
{
public:
virtual void Run() {}
Scene() {}
~Scene() {}
};
int main(int argc, char **argv)
{
// Init
bool running = true;
// Say 6 scenes: "splash", "main menu", "options", "game", "lobby", "exit"
uint8_t scene_count = 6;
Scene** scenes = new Scene[scene_count];
// Create your scenes here abstracting from the above
// Start with the first scene (splash in this example)
uint8_t active_scene = 0;
while(running)
{
// Perform a single execution switching if asked
active_scene = scenes[active_scene]->Run();
};
// Term/cleanup
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment