]> code.bitgloo.com Git - clyne/gamedev.git/commitdiff
fixed jumping
authorClyne Sullivan <tullivan99@gmail.com>
Sun, 13 Sep 2015 16:05:07 +0000 (12:05 -0400)
committerClyne Sullivan <tullivan99@gmail.com>
Sun, 13 Sep 2015 16:05:07 +0000 (12:05 -0400)
src/UIClass.cpp
src/main.cpp

index 46c7124e227f025752639d5f350018954da31241..1376d104a9e9ed171c8e30d5e91fd849b75f3e1e 100644 (file)
@@ -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;
index ed80ee2e941bd882bf6efed797d07a5b516c342b..88c08efd7ad3efecfa9ab4df889a09a97f64ad80 100644 (file)
@@ -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);