Guest User

Untitled

a guest
May 23rd, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. /*
  2. * Game.cpp
  3. *
  4. * Created on: Jul 3, 2010
  5. * Author: itsbth
  6. */
  7.  
  8. #include "Game.h"
  9.  
  10. #include <SFML/System/Clock.hpp>
  11.  
  12. namespace pw
  13. {
  14.  
  15. Game::Game(sf::RenderWindow& App) :
  16. App(App)
  17. {
  18. // TODO Auto-generated constructor stub
  19.  
  20. }
  21.  
  22. Game::~Game()
  23. {
  24. // TODO Auto-generated destructor stub
  25. while (!States.empty())
  26. States.pop(); // Free all states
  27. }
  28.  
  29. void Game::Run()
  30. {
  31. sf::Clock Clock;
  32. while (!States.empty())
  33. {
  34. sf::Event Event;
  35. while (App.GetEvent(Event))
  36. ;
  37. State& Top = *States.top();
  38. if (!Top.Update(Clock.GetElapsedTime()))
  39. {
  40. States.pop();
  41. continue;
  42. }
  43. Clock.Reset();
  44. App.Clear();
  45. Top.Draw(App);
  46. App.Display();
  47. }
  48. }
  49.  
  50. /**
  51. * Get the input
  52. */
  53. const sf::Input& Game::GetInput() const
  54. {
  55. return App.GetInput();
  56. }
  57.  
  58. }
Add Comment
Please, Sign In to add comment