aboutsummaryrefslogtreecommitdiffstats
path: root/src/ui.cpp
diff options
context:
space:
mode:
authorClyne Sullivan <tullivan99@gmail.com>2015-09-21 21:52:28 -0400
committerClyne Sullivan <tullivan99@gmail.com>2015-09-21 21:52:28 -0400
commitb3e625cf2e6fea860fc669f3a2a46cf96a01da0f (patch)
treebc01dccc2e7f148b3c291eb4e145c9263aeaa20d /src/ui.cpp
parent1118f22a60dffeb204ec4845d009cf057b51f088 (diff)
added/fixed world linking
Diffstat (limited to 'src/ui.cpp')
-rw-r--r--src/ui.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/ui.cpp b/src/ui.cpp
index 877dacb..a2fe7bf 100644
--- a/src/ui.cpp
+++ b/src/ui.cpp
@@ -1,10 +1,12 @@
#include <ui.h>
+#include <world.h>
#include <ft2build.h>
#include FT_FREETYPE_H
#define SDL_KEY e.key.keysym.sym
extern Player *player;
+extern World *currentWorld;
static FT_Library ftl;
static FT_Face ftf;
@@ -89,9 +91,17 @@ namespace ui {
break;
case SDL_KEYDOWN:
if(SDL_KEY==SDLK_ESCAPE)gameRunning=false;
- if(SDL_KEY==SDLK_a)player->vel.x=-.15;
- if(SDL_KEY==SDLK_d)player->vel.x=.15;
+ if(SDL_KEY==SDLK_a){
+ player->vel.x=-.15;
+ currentWorld=currentWorld->goWorldLeft(&player->loc,player->width);
+ }
+ if(SDL_KEY==SDLK_d){
+ player->vel.x=.15;
+ currentWorld=currentWorld->goWorldRight(&player->loc,player->width);
+ }
if(SDL_KEY==SDLK_SPACE)player->vel.y=.25;
+ if(SDL_KEY==SDLK_i)currentWorld=currentWorld->goWorldBack(&player->loc,player->width);
+ if(SDL_KEY==SDLK_k)currentWorld=currentWorld->goWorldFront(&player->loc,player->width);
break;
case SDL_KEYUP:
if(SDL_KEY==SDLK_a)player->vel.x=0;