Commits

Dino Drokan committed d70bfe1

Smooth PlayerShip moving.

Comments (0)

Files changed (2)

 #include <SDL/SDL_events.h>
 
 static const double playerShipAngleV = 180;
+static const double playerShipYV = 150;
 
 PlayerShip::PlayerShip(const std::string& textureFile,
                        const int argX,
-                       const int argY) : texture(new Texture(textureFile)), x(argX), y(argY), angle(0), angleV(0)
+                       const int argY) : texture(new Texture(textureFile)), x(argX), y(argY), angle(0), angleV(0), yv(0)
 {
 
 }
 PlayerShip::updateSelf(double timeDelta)
 {
     angle += angleV * timeDelta;
+    y += yv * timeDelta;
 }
 
 void
         break;
 
         case SDLK_UP:
-        y = y - 5;
+        yv = -playerShipYV;
         break;
 
         case SDLK_DOWN:
-        y = y + 5;
+        yv =  playerShipYV;
         break;
 
         default:
         case SDLK_RIGHT:
             angleV = 0;
             break;
-            
+
         case SDLK_LEFT:
             angleV = 0;
             break;
-            
+
+        case SDLK_UP:
+            yv = 0;
+            break;
+        case SDLK_DOWN:
+            yv = 0;
+
         default:
             break;
     }
-    
 
 }
 
     float x, y;
     double angle;
     double angleV;
+    double yv;
 };
 #endif