Advertisement
Guest User

Untitled

a guest
Nov 24th, 2014
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.96 KB | None | 0 0
  1. class game
  2. {
  3.     game_loop()
  4.     {
  5.         while (window.isOpen())
  6.         {
  7.         loops = 0;
  8.  
  9.         while (clock.getElapsedTime().asMilliseconds() > next_tick && loops < MAX_FRAMESKIP)
  10.         {
  11.             next_tick += SKIP_TICKS;
  12.             ++loops;
  13.            
  14.             m_state.on_update();   
  15.         }
  16.  
  17.         interpolation = static_cast <float> (clock.getElapsedTime().asMilliseconds() + SKIP_TICKS - next_tick) / static_cast <float> (SKIP_TICKS);
  18.  
  19.         m_state.on_draw();
  20.  
  21.         }
  22.  
  23.     }
  24.  
  25.     game_state m_state; // can be any of the 2
  26. };
  27.  
  28. class game_state
  29. {
  30.     sf::RenderWindow m_window;
  31.  
  32.     virtual void on_draw() = 0;
  33.     virtual void on_update() = 0;
  34. }
  35.  
  36. class login_state : public game_state
  37. {
  38.     // same idea as channel, there is no other state in the game
  39. }
  40.  
  41. class channel_state : public game_state
  42. {
  43.     channel_state()
  44.     {
  45.     // make sure all the drawing class have a variable to the game_logic class, so they know the current x,y and what animation it is doing
  46.     }
  47.    
  48.     override void on_draw()
  49.     {
  50.         // handle input
  51.         // handle packets
  52.        
  53.         m_char.update();
  54.         m_mobs.update();
  55.         m_drop.update();
  56.         // etcetc
  57.        
  58.     }
  59.  
  60.     override void on_update()
  61.     {
  62.         m_draw_map.draw();
  63.         m_draw_chars.draw();// etcetc
  64.     }
  65.  
  66.     map  m_map;
  67.     draw_map m_draw_map;
  68.     draw_character m_draw_chars;
  69.  
  70.     character m_char
  71. }
  72.  
  73. class camera
  74. {
  75.      // compare the local_character possition in addition to the map, so lets us know what rect the user can actually see
  76. }
  77.  
  78. class map
  79. {
  80.     std::vector<footholds> m_fh;
  81.     std::unordered_map<ID, drops> m_drops;
  82.     std::unordered_map<ID, character> m_chars; // multyplaer, so there could be 4 players (or more if I ever make it like that )
  83. }
  84.  
  85. class thingie // what is a name for this
  86. {
  87.     dword m_x, m_y;
  88.     dword m_speed;
  89.     dword m_acc;
  90. }
  91.  
  92. class footholds
  93. {
  94. }
  95.  
  96. class drop : thingie
  97. {
  98. }
  99.  
  100. class drops
  101. {
  102.     std::unoredered_map<ID, drop> m_drops;
  103. }
  104.  
  105. class mob : thingie
  106. {
  107. }
  108.  
  109. class mobs
  110. {
  111.     std::unoredered_map<ID, mob> m_mobs;
  112. }
  113.  
  114. class character : thingie
  115. {
  116.  
  117. }
  118.  
  119. class local_character : character
  120. {
  121.  
  122. }
  123.  
  124. class char_pool
  125. {
  126.     std::unoredered_map<ID, character> m_chars;
  127. }
  128.  
  129. //////////////////////////////////////////////////
  130. // different namespace and stuff
  131. //////////////////////////////////////////////////
  132.  
  133. class drawable
  134. {
  135.     virtual void draw() = 0;
  136. }
  137.  
  138. class draw_map : public drawable
  139. {
  140.     std::vector<map_regio>  m_regions;
  141.  
  142.     draw()
  143.     {
  144.         // check the camera class to know what map_regions are visible, then draw these
  145.     }
  146.  
  147.     // load some theme of the map texture_sheet
  148.     // load some specific textures for background? maybe?
  149.     // no need for info about it, map is static.
  150. }
  151.  
  152. class map_region : public drawable
  153. {
  154.     std::vector<tile> m_tiles;
  155.  
  156.     const size = 600; // rect of 600x600
  157.  
  158.     draw()
  159.     {
  160.         // first draw background
  161.         // draw layer 1 tiles
  162.         // draw layer 2 tiles
  163.     }
  164. }
  165.  
  166. class tile
  167. {
  168.     dword m_x;
  169.     dword m_y;
  170.  
  171. }
  172.  
  173. class draw_windows : public drawable
  174. {
  175.     // this class draws all the curent active window/menu and stuff
  176.     // only 1 texutre sheeet needed for this
  177.     draw()
  178.     {
  179.     }
  180.  
  181.     // make something for this
  182. }
  183.  
  184. class draw_drops : public drawable
  185. {
  186.     // load texture sheet from all drops - constant (reuse the one from inveotry frmo user)
  187.     draw()
  188.     {
  189.         // draw all items in range, if we need performance, make sure items are in order, so we can use the same texture_sheet
  190.     }
  191.  
  192.     m_drops m_info;
  193. }
  194.  
  195. class draw_mobs : public drawable
  196. {
  197.     // load texture for the current monster, so all its moves, walking/ standing/ jumping
  198.     // use some animation class to know which texture to use
  199.     draw()
  200.     {
  201.         // draw mobs in view and determine what texture to use for its current animation
  202.     }
  203.  
  204.     mobs m_info;
  205. }
  206.  
  207. class draw_characters : public drawable
  208. {
  209.     // load texture for the character, so all its moves, walking/ standing/ jumping
  210.     // also load textures for the current items people are wearing, DONT LOAD ALL OF THEM INTO A TEXUTRE
  211.     // use some animation class to know which texture to use
  212.     draw()
  213.     {
  214.         // draw all character including the user
  215.  
  216.     }
  217.  
  218.     m_char_pool m_info;
  219. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement