aboutsummaryrefslogtreecommitdiffstats
path: root/src/ui.cpp
diff options
context:
space:
mode:
authorClyne Sullivan <tullivan99@gmail.com>2016-03-01 08:33:27 -0500
committerClyne Sullivan <tullivan99@gmail.com>2016-03-01 08:33:27 -0500
commit32cb1880f018fc149d1c8a71a83426a8f5a92a6a (patch)
treebfa73ddb4076018639b6ec2e14492471b82c0649 /src/ui.cpp
parent6241707a788269e09adb957c659397750d19fda3 (diff)
world rewrite
Diffstat (limited to 'src/ui.cpp')
-rw-r--r--src/ui.cpp44
1 files changed, 25 insertions, 19 deletions
diff --git a/src/ui.cpp b/src/ui.cpp
index 6e616a7..47110cc 100644
--- a/src/ui.cpp
+++ b/src/ui.cpp
@@ -1039,42 +1039,48 @@ DONE:
vec2 oldpos,tmppos;
SDL_Event e;
- mouse.x=premouse.x+offset.x-(SCREEN_WIDTH/2);
- mouse.y=(offset.y+SCREEN_HEIGHT/2)-premouse.y;
+ // update mouse coords
+ mouse.x = premouse.x + offset.x - ( SCREEN_WIDTH / 2 );
+ mouse.y = ( offset.y + SCREEN_HEIGHT / 2 ) - premouse.y;
while(SDL_PollEvent(&e)){
switch(e.type){
+
+ // escape - quit game
case SDL_QUIT:
gameRunning=false;
break;
+
+ // mouse movement - update mouse vector
case SDL_MOUSEMOTION:
premouse.x=e.motion.x;
premouse.y=e.motion.y;
break;
+
+ // mouse clicks
case SDL_MOUSEBUTTONDOWN:
- if((e.button.button & SDL_BUTTON_RIGHT) && dialogBoxExists)
+ // right click advances dialog
+ if ( ( e.button.button & SDL_BUTTON_RIGHT ) && dialogBoxExists )
dialogAdvance();
- if((e.button.button & SDL_BUTTON_LEFT) && !dialogBoxExists)
+ // left click uses item
+ if ( ( e.button.button & SDL_BUTTON_LEFT ) && !dialogBoxExists )
player->inv->usingi = true;
break;
- /*
- KEYDOWN
- */
+
+ // key presses
case SDL_KEYDOWN:
- /*if(SDL_KEY == SDLK_ESCAPE){
- //gameRunning = false;
- pMenu = true;
- return;
- }else */if(SDL_KEY == SDLK_SPACE){
- /*if(dialogBoxExists)
- dialogAdvance();
- else */if(player->ground){
- player->vel.y=.4;
- player->loc.y+=HLINE*2;
- player->ground=false;
+
+ // space - make player jump
+ if ( SDL_KEY == SDLK_SPACE ) {
+ if ( player->ground ) {
+ player->loc.y += HLINE * 2;
+ player->vel.y = .4;
+ player->ground = false;
}
break;
- }else if(!dialogBoxExists || dialogPassive){
+
+ // only let other keys be handled if dialog allows it
+ } else if ( !dialogBoxExists || dialogPassive ) {
tmp = currentWorld;
switch(SDL_KEY){
case SDLK_a: