Advertisement
Guest User

OptionsMenuState.cpp

a guest
Aug 20th, 2014
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.35 KB | None | 0 0
  1. #include <memory>
  2. #include <iostream>
  3.  
  4. #include "StateMachine.hpp"
  5. #include "OptionsMenuState.hpp"
  6. #include "PlayState.hpp"
  7. #include "GameState.hpp"
  8. #include "StateMachine.hpp"
  9. #include "MenuState.hpp"
  10.  
  11. #include <SFML/Graphics/RenderWindow.hpp>
  12. #include <SFML/Window/Event.hpp>
  13.  
  14. OptionsMenuState::OptionsMenuState(StateMachine& machine, sf::RenderWindow& window, bool replace)
  15. : GameState(machine, window, replace)
  16. {
  17.     std::cout << "PlayState Init" << std::endl;
  18. }
  19.  
  20. void OptionsMenuState::pause()
  21. {
  22.     std::cout << "PlayState Pause" << std::endl;
  23. }
  24.  
  25. void OptionsMenuState::resume()
  26. {
  27.     std::cout << "PlayState Resume" << std::endl;
  28. }
  29.  
  30. void OptionsMenuState::update()
  31. {
  32.     sf::Event event;
  33.  
  34.     while (m_window.pollEvent(event))
  35.     {
  36.         switch (event.type)
  37.         {
  38.         case sf::Event::Closed:
  39.             m_machine.quit();
  40.             break;
  41.  
  42.         case sf::Event::KeyPressed:
  43.             switch (event.key.code)
  44.             {
  45.             case sf::Keyboard::Escape:
  46.                 m_machine.quit();
  47.                 break;
  48.                
  49. //For some reason the "PlayState" below is also Undeclared. \/ \/
  50.             case sf::Keyboard::BackSpace:
  51.                 m_next = StateMachine::build<PlayState>(m_machine, m_window, false);
  52.                 break;
  53.  
  54.             default:
  55.                 break;
  56.             }
  57.             break;
  58.  
  59.         default:
  60.             break;
  61.         }
  62.     }
  63.     }
  64.     else{
  65.  
  66.     }
  67. }
  68.  
  69. void OptionsMenuState::draw()
  70. {
  71.     // Clear the previous drawing
  72.     m_window.clear();
  73.     m_window.display();
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement