aboutsummaryrefslogtreecommitdiffstats
path: root/src/UIClass.cpp
diff options
context:
space:
mode:
authorClyne Sullivan <tullivan99@gmail.com>2015-09-12 20:35:06 -0400
committerClyne Sullivan <tullivan99@gmail.com>2015-09-12 20:35:06 -0400
commit16b3df909a66c9a70309e878f67a962230b799ed (patch)
tree3a50a24cfbdcc31bdcb8ef3aec484dd3d2042627 /src/UIClass.cpp
parent9e04811e52203e4b814c6668208931aeeb8e752e (diff)
ortho stuff
Diffstat (limited to 'src/UIClass.cpp')
-rw-r--r--src/UIClass.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/UIClass.cpp b/src/UIClass.cpp
index c1c1180..e416bc1 100644
--- a/src/UIClass.cpp
+++ b/src/UIClass.cpp
@@ -16,16 +16,20 @@ void UIClass::handleEvents(){
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;
+ if(e.key.keysym.sym == SDLK_SPACE) player.loc.y += .5;
if(e.key.keysym.sym == SDLK_i)
if(currentWorld->behind){
- player.loc.x-=(currentWorld->getWidth()-currentWorld->behind->getWidth())/2;
- currentWorld=currentWorld->behind;
+ player.loc.x-=(currentWorld->getWidth()-currentWorld->behind->getWidth())/2; // Match player's location to new area
+ currentWorld=currentWorld->behind; // Go to new area
+ if(player.loc.x>-1+currentWorld->getWidth()) // Don't let player fall out of world if previous area was bigger
+ player.loc.x=-1+currentWorld->getWidth()-player.width-HLINE;
}
if(e.key.keysym.sym == SDLK_k)
if(currentWorld->infront){
- player.loc.x+=(currentWorld->infront->getWidth()-currentWorld->getWidth())/2;
- currentWorld=currentWorld->infront;
+ player.loc.x+=(currentWorld->infront->getWidth()-currentWorld->getWidth())/2; // Match player's location to new area
+ currentWorld=currentWorld->infront; // Go to new area
+ if(player.loc.x>-1+currentWorld->getWidth()) // Don't let player fall out of world if previous area was bigger
+ player.loc.x=-1+currentWorld->getWidth()-player.width-HLINE;
}
break;
case SDL_KEYUP: