aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorClyne Sullivan <tullivan99@gmail.com>2015-09-13 12:05:07 -0400
committerClyne Sullivan <tullivan99@gmail.com>2015-09-13 12:05:07 -0400
commit8a88ef32f41a69166280dae8f59fa6477fd3609a (patch)
tree75029feae16259416fb05da791c5b89fdf4766a7 /src
parenta8fb538152c5e7d83b161a3868870aa4009ea36f (diff)
fixed jumping
Diffstat (limited to 'src')
-rw-r--r--src/UIClass.cpp6
-rw-r--r--src/main.cpp2
2 files changed, 6 insertions, 2 deletions
diff --git a/src/UIClass.cpp b/src/UIClass.cpp
index 46c7124..1376d10 100644
--- a/src/UIClass.cpp
+++ b/src/UIClass.cpp
@@ -4,6 +4,7 @@ extern Player player;
extern World *currentWorld;
void UIClass::handleEvents(){
+ static bool space=false;
float thing;
SDL_Event e;
while(SDL_PollEvent(&e)){
@@ -19,7 +20,8 @@ void UIClass::handleEvents(){
if(e.key.keysym.sym == SDLK_a) player.left = true;
if(e.key.keysym.sym == SDLK_LSHIFT) player.speed = 3;
if(e.key.keysym.sym == SDLK_SPACE){
- if(player.vel.y<=0){
+ if(!space&&player.vel.y<=0){
+ space=true;
player.loc.y += HLINE*1.2;
player.vel.y += .004;
}
@@ -45,6 +47,8 @@ void UIClass::handleEvents(){
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_LSHIFT) player.speed = 1.0;
+ if(e.key.keysym.sym == SDLK_SPACE)
+ if(player.vel.y<=.001)space=false;
if(e.key.keysym.sym == SDLK_ESCAPE) gameRunning = false;
break;
diff --git a/src/main.cpp b/src/main.cpp
index ed80ee2..88c08ef 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -191,7 +191,7 @@ void logic(){
if(player.left == true) {player.vel.x = -.00075;}
if(player.right == false && player.left == false) {player.vel.x = 0;}
- std::cout<<"\r("<<player.loc.x<<","<<player.loc.y<<")"<<std::endl;
+ std::cout<<"\r("<<player.loc.x<<","<<player.loc.y<<")";
currentWorld->detect(&player.loc,&player.vel,player.width);