aboutsummaryrefslogtreecommitdiffstats
path: root/src/UIClass.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/UIClass.cpp')
-rw-r--r--src/UIClass.cpp46
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