Advertisement
Vchavauty

OnEvent.cpp

Jul 26th, 2013
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.76 KB | None | 0 0
  1. #include "Capp.h"
  2.  
  3. void CApp::OnEvent(SDL_Event *event)
  4. {
  5.     MyEvents::OnEvent(event);
  6.     if(event->type == SDL_QUIT)
  7.     {
  8.         Running = false;
  9.     }
  10.  
  11. }
  12. void CApp::OnExit()
  13. {
  14.     Running = false;
  15. }
  16.  
  17. void CApp::OnKeyDown(SDLKey sym, SDLMod mod, Uint16 unicode)
  18. {
  19.     if(sym == SDLK_ESCAPE)
  20.         OnExit();
  21.     if(sym == SDLK_RIGHT)
  22.     {
  23.         MainCharacter.ReceiveEvent(EVENT_WALK, 0);
  24.     }
  25.     else if(sym == SDLK_LEFT)
  26.     {
  27.         MainCharacter.ReceiveEvent(EVENT_WALK, 1);
  28.     }
  29. }
  30. void CApp:: OnKeyUp(SDLKey sym, SDLMod mod, Uint16 unicode)
  31. {
  32.     if(sym == SDLK_RIGHT)
  33.     {
  34.         MainCharacter.ReceiveEvent(EVENT_STOP, 0);
  35.     }
  36.     else if(sym == SDLK_LEFT)
  37.     {
  38.         MainCharacter.ReceiveEvent(EVENT_STOP, 1);
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement