Advertisement
Guest User

Untitled

a guest
Nov 5th, 2014
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.75 KB | None | 0 0
  1. struct State
  2. {
  3.    enum { Game, /*...*/ } mode;
  4.  
  5.    struct
  6.    {
  7.       bool drawMinimap;
  8.    } game;
  9. } State;
  10.  
  11. // -----------------------
  12.  
  13. class BaseScene
  14. {
  15.    virtual void update();
  16.    virtual void draw();
  17. };
  18.  
  19. class Minimap : BaseScene
  20. {
  21. }
  22.  
  23. class Game : Basescene
  24. {
  25.    Minimap * minimap;
  26.  
  27.    void draw()
  28.    {
  29.      if(state.game.drawMinimap)
  30.        minimap->draw();
  31.    }
  32. }
  33.  
  34. // -----------------------
  35.  
  36. class Application
  37. {
  38.    Game  * game;
  39.  
  40.    void run()
  41.    {
  42.       while(...)
  43.       {
  44.          events();
  45.          update();
  46.          render();
  47.       }  
  48.    }
  49.  
  50.    void render()
  51.    {
  52.       switch(state.mode)
  53.       {
  54.          case State::Game:
  55.             game->draw();
  56.  
  57.             break;
  58.  
  59.          //...
  60.       }
  61.    }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement