[Orxonox-commit 7144] r11761 - code/branches/Presentation_HS17_merge/src/modules/flappyorx

landauf at orxonox.net landauf at orxonox.net
Sun Feb 18 00:50:23 CET 2018


Author: landauf
Date: 2018-02-18 00:50:22 +0100 (Sun, 18 Feb 2018)
New Revision: 11761

Modified:
   code/branches/Presentation_HS17_merge/src/modules/flappyorx/FlappyOrxShip.cc
   code/branches/Presentation_HS17_merge/src/modules/flappyorx/FlappyOrxShip.h
Log:
[FlappyOrx_HS17] bugfix: velocity was never initialized (expecially x, which wasn't necessary anyway)

Modified: code/branches/Presentation_HS17_merge/src/modules/flappyorx/FlappyOrxShip.cc
===================================================================
--- code/branches/Presentation_HS17_merge/src/modules/flappyorx/FlappyOrxShip.cc	2018-02-17 22:50:25 UTC (rev 11760)
+++ code/branches/Presentation_HS17_merge/src/modules/flappyorx/FlappyOrxShip.cc	2018-02-17 23:50:22 UTC (rev 11761)
@@ -50,6 +50,7 @@
 
         isFlapping = false;
         isDead = true;
+        velocity = 0;
         speed = 0;
         upwardThrust = 0;
         gravity = 0;
@@ -106,14 +107,14 @@
             
 
             if(not isDead){
-                velocity.y += gravity*dt;
+                velocity += gravity*dt;
                 if(isFlapping){
                     isFlapping = false;
                     if(pos.z > -150)
-                        velocity.y = -upwardThrust;
+                        velocity = -upwardThrust;
                 }
 
-                pos += Vector3(speed + velocity.x, 0, velocity.y) * dt; 
+                pos += Vector3(speed, 0, velocity) * dt;
             }
             
                         
@@ -128,7 +129,7 @@
 
             
             setPosition(pos);
-            setOrientation(Vector3::UNIT_Y, Degree(270-velocity.y/10));
+            setOrientation(Vector3::UNIT_Y, Degree(270-velocity/10));
 
             if(pos.z > 150){
                 getGame()->death();
@@ -175,7 +176,7 @@
         pos.x = 0;
         pos.z = 0;
         pos.y = 0;
-        velocity.y = 0;
+        velocity = 0;
         setPosition(pos);
     }
 }

Modified: code/branches/Presentation_HS17_merge/src/modules/flappyorx/FlappyOrxShip.h
===================================================================
--- code/branches/Presentation_HS17_merge/src/modules/flappyorx/FlappyOrxShip.h	2018-02-17 22:50:25 UTC (rev 11760)
+++ code/branches/Presentation_HS17_merge/src/modules/flappyorx/FlappyOrxShip.h	2018-02-17 23:50:22 UTC (rev 11761)
@@ -87,14 +87,10 @@
             ParticleSpawner* particlespawner_;
             bool isFlapping;
             bool isDead;
+            float velocity;
             float speed, upwardThrust, gravity;
             float particleAge, particleLifespan;
             time_t deathTime;
-            struct Velocity
-            {
-                float x;
-                float y;
-            } velocity;
 
     };
 }



More information about the Orxonox-commit mailing list