diff options
author | Clyne Sullivan <tullivan99@gmail.com> | 2015-09-12 13:39:36 -0400 |
---|---|---|
committer | Clyne Sullivan <tullivan99@gmail.com> | 2015-09-12 13:39:36 -0400 |
commit | ec1a918b845457b4d578f4d31257b989b5de3d42 (patch) | |
tree | d4e8105d31368b9f2d8d18e7e72614ec6271ff61 /src/UIClass.cpp | |
parent | 8bf284574d5a4c1aba3e488e8d9417e788dae5b6 (diff) | |
parent | 6a28f446c501f09153ca77eb22951de7bb144e18 (diff) |
Merge branch 'master' of https://github.com/tcsullivan/gamedev
Diffstat (limited to 'src/UIClass.cpp')
-rw-r--r-- | src/UIClass.cpp | 46 |
1 files changed, 14 insertions, 32 deletions
diff --git a/src/UIClass.cpp b/src/UIClass.cpp index 731e387..319db5c 100644 --- a/src/UIClass.cpp +++ b/src/UIClass.cpp @@ -7,40 +7,22 @@ void UIClass::handleEvents(){ SDL_Event e; while(SDL_PollEvent(&e)){ switch(e.type){ - case SDL_QUIT: - gameRunning=false; - break; - case SDL_KEYDOWN: - switch(e.key.keysym.sym){ - case 27: ///ESCAPE - gameRunning=false; - break; - case SDLK_d: ///D - player.velg.x = 10; - break; - case SDLK_a: ///A - player.velg.x = -10; - break; - case SDLK_i: - if(currentWorld->behind)currentWorld=currentWorld->behind; - break; - case SDLK_k: - if(currentWorld->infront)currentWorld=currentWorld->infront; - break; - default: + case SDL_WINDOWEVENT: + switch(e.window.event){ + case SDL_WINDOWEVENT_CLOSE: + gameRunning = false; break; } + case SDL_KEYDOWN: + if(e.key.keysym.sym == SDLK_d) player.right = true; + if(e.key.keysym.sym == SDLK_a) player.left = true; + if(e.key.keysym.sym == SDLK_SPACE) player.loc.y += 10; + break; case SDL_KEYUP: - switch(e.key.keysym.sym){ - /*case SDLK_d: ///D - break; - case SDLK_a: ///A - break;*/ - default: - break; - } - default: + if(e.key.keysym.sym == SDLK_d) player.right = false; + if(e.key.keysym.sym == SDLK_a) player.left = false; + if(e.key.keysym.sym == SDLK_ESCAPE) gameRunning = false; break; - } + } } -} +}
\ No newline at end of file |