[Orxonox-commit 7138] r11755 - code/branches/Presentation_HS17_merge/src/modules/flappyorx

landauf at orxonox.net landauf at orxonox.net
Fri Feb 16 00:37:37 CET 2018


Author: landauf
Date: 2018-02-16 00:37:37 +0100 (Fri, 16 Feb 2018)
New Revision: 11755

Modified:
   code/branches/Presentation_HS17_merge/src/modules/flappyorx/FlappyOrx.cc
   code/branches/Presentation_HS17_merge/src/modules/flappyorx/FlappyOrx.h
   code/branches/Presentation_HS17_merge/src/modules/flappyorx/FlappyOrxHUDinfo.cc
   code/branches/Presentation_HS17_merge/src/modules/flappyorx/FlappyOrxShip.cc
   code/branches/Presentation_HS17_merge/src/modules/flappyorx/FlappyOrxShip.h
Log:
[FlappyOrx_HS17] fixed some warnings (MSVC)

Modified: code/branches/Presentation_HS17_merge/src/modules/flappyorx/FlappyOrx.cc
===================================================================
--- code/branches/Presentation_HS17_merge/src/modules/flappyorx/FlappyOrx.cc	2018-02-15 22:42:36 UTC (rev 11754)
+++ code/branches/Presentation_HS17_merge/src/modules/flappyorx/FlappyOrx.cc	2018-02-15 23:37:37 UTC (rev 11755)
@@ -66,14 +66,14 @@
         bIsDead = true;
         firstGame = true;                   //needed for the HUD
 
-        tubeDistance=200;                  //distance between tubes
-        tubeOffsetX=500;                    //tube offset (so that we can't see them spawn)
+        tubeDistance=200.0f;                  //distance between tubes
+        tubeOffsetX=500.0f;                    //tube offset (so that we can't see them spawn)
 
         circlesUsed=0;
         setHUDTemplate("FlappyOrxHUD");
     }
     
-    void FlappyOrx::updatePlayerPos(int x){
+    void FlappyOrx::updatePlayerPos(float x){
 
         //Spawn a new Tube when the spawn distance is reached
         if(this->tubes.size()==0||x-tubes.back()+tubeOffsetX>tubeDistance){
@@ -115,19 +115,19 @@
         if (getPlayer() == nullptr)
             return;
 
-        int space = 130;    //vertical space between top and bottom tube
-        int height = (float(rand())/RAND_MAX-0.5)*(280-space);  //Randomize height
+        float space = 130.0f;    //vertical space between top and bottom tube
+        float height = (rnd()-0.5f)*(280.0f-space);  //Randomize height
            
         Vector3 pos = player->getPosition();
 
         //create the two Asteroid fields (Tubes)
-        asteroidField(pos.x+tubeOffsetX,height-space/2,0.8);  //bottom  
-        asteroidField(pos.x+tubeOffsetX,height+space/2,-0.8); //top
+        asteroidField(pos.x+tubeOffsetX,height-space/2,0.8f);  //bottom
+        asteroidField(pos.x+tubeOffsetX,height+space/2,-0.8f); //top
     }
 
     //Creates a new asteroid Field
-    void FlappyOrx::asteroidField(int x, int y, float slope){
-        int r = 20;     //Radius of added Asteroids
+    void FlappyOrx::asteroidField(float x, float y, float slope){
+        float r = 20.0f;     //Radius of added Asteroids
         int noadd = 0;  //how many times we failed to add a new asteroid
 
         clearCircles();   //Delete Circles (we use circles to make sure we don't spawn two asteroids on top of eachother)
@@ -140,11 +140,11 @@
         //Fill up triangle with asteroids
         while(noadd<5&&circlesUsed<nCircles){
             if(slope>0)
-                newAsteroid.y=float(rand())/RAND_MAX*(150+y)-150;   //create asteroid on bottom
+                newAsteroid.y=rnd(150+y)-150;   //create asteroid on bottom
             else
-                newAsteroid.y=float(rand())/RAND_MAX*(150-y)+y;     //create asteroid on top
+                newAsteroid.y=rnd(150-y)+y;     //create asteroid on top
             
-            newAsteroid.x=x+(float(rand())/RAND_MAX-0.5)*(y-newAsteroid.y)/slope;
+            newAsteroid.x=x+(rnd()-0.5f)*(y-newAsteroid.y)/slope;
             newAsteroid.r=r;
            
             int i = addIfPossible(newAsteroid); //Add Asteroid if it doesn't collide
@@ -173,8 +173,8 @@
         newAsteroid->setPosition(Vector3(c.x, 0, c.y));
 
         //Randomize orientation
-        newAsteroid->setOrientation(Vector3::UNIT_Z, Degree(rand()%360));
-        newAsteroid->setOrientation(Vector3::UNIT_Y, Degree(rand()%360));
+        newAsteroid->setOrientation(Vector3::UNIT_Z, Degree(rnd(360)));
+        newAsteroid->setOrientation(Vector3::UNIT_Y, Degree(rnd(360)));
 
         //add to Queue (so that we can delete it again)
         asteroids.push(newAsteroid);
@@ -192,9 +192,9 @@
     bool FlappyOrx::circleCollision(Circle &c1, Circle &c2){
         if(c1.r<=0 || c2.r<=0)
             return false;
-        int x = c1.x - c2.x;
-        int y = c1.y - c2.y;
-        int r = c1.r + c2.r;
+        float x = c1.x - c2.x;
+        float y = c1.y - c2.y;
+        float r = c1.r + c2.r;
 
         return x*x+y*y<r*r*1.5;
     }

Modified: code/branches/Presentation_HS17_merge/src/modules/flappyorx/FlappyOrx.h
===================================================================
--- code/branches/Presentation_HS17_merge/src/modules/flappyorx/FlappyOrx.h	2018-02-15 22:42:36 UTC (rev 11754)
+++ code/branches/Presentation_HS17_merge/src/modules/flappyorx/FlappyOrx.h	2018-02-15 23:37:37 UTC (rev 11755)
@@ -45,10 +45,10 @@
 namespace orxonox
 {
     struct Circle{
-        int r;
-        int x;
-        int y;
-        Circle(int new_r, int new_x, int new_y){
+        float r;
+        float x;
+        float y;
+        Circle(float new_r, float new_x, float new_y){
             r=new_r;
             x=new_x;
             y=new_y;
@@ -69,9 +69,9 @@
             virtual void end() override;
             virtual void death();
            
-            void updatePlayerPos(int x);
+            void updatePlayerPos(float x);
             void createAsteroid(Circle &c);
-            void asteroidField(int x, int y, float slope);
+            void asteroidField(float x, float y, float slope);
             void spawnTube();
             
             void setCenterpoint(FlappyOrxCenterPoint* center);
@@ -88,23 +88,23 @@
             float speedBase;
             float speedIncrease;
 
-            int tubeDistanceBase;
-            int tubeDistanceIncrease;
-            int tubeDistance;
-            int tubeOffsetX;
+            float tubeDistanceBase;
+            float tubeDistanceIncrease;
+            float tubeDistance;
+            float tubeOffsetX;
 
             int upwardThrust;
             int gravity;
 
-            inline void setSpeedBase(int speedBase){ this-> speedBase =  speedBase;}
+            inline void setSpeedBase(float speedBase){ this-> speedBase =  speedBase;}
             inline float  getSpeedBase(){ return speedBase;}
-            inline void setSpeedIncrease(int speedIncrease){ this-> speedIncrease =  speedIncrease;}
+            inline void setSpeedIncrease(float speedIncrease){ this-> speedIncrease =  speedIncrease;}
             inline float  getSpeedIncrease(){ return speedIncrease;}
 
-            inline void setTubeDistanceBase(int tubeDistanceBase){ this-> tubeDistanceBase =  tubeDistanceBase;}
-            inline int  getTubeDistanceBase(){ return tubeDistanceBase;}
-            inline void setTubeDistanceIncrease(int tubeDistanceIncrease){ this-> tubeDistanceIncrease =  tubeDistanceIncrease;}
-            inline int  getTubeDistanceIncrease(){ return tubeDistanceIncrease;}
+            inline void setTubeDistanceBase(float tubeDistanceBase){ this-> tubeDistanceBase =  tubeDistanceBase;}
+            inline float  getTubeDistanceBase(){ return tubeDistanceBase;}
+            inline void setTubeDistanceIncrease(float tubeDistanceIncrease){ this-> tubeDistanceIncrease =  tubeDistanceIncrease;}
+            inline float  getTubeDistanceIncrease(){ return tubeDistanceIncrease;}
 
             
             bool bEndGame;
@@ -111,7 +111,7 @@
             bool bIsDead;
             bool firstGame;
             std::string sDeathMessage;
-            std::queue<int> tubes;                  //Saves Position of Tubes
+            std::queue<float> tubes;                  //Saves Position of Tubes
             std::queue<MovableEntity*> asteroids;   //Stores Asteroids which build up the tubes
             float speed = 100;
             

Modified: code/branches/Presentation_HS17_merge/src/modules/flappyorx/FlappyOrxHUDinfo.cc
===================================================================
--- code/branches/Presentation_HS17_merge/src/modules/flappyorx/FlappyOrxHUDinfo.cc	2018-02-15 22:42:36 UTC (rev 11754)
+++ code/branches/Presentation_HS17_merge/src/modules/flappyorx/FlappyOrxHUDinfo.cc	2018-02-15 23:37:37 UTC (rev 11755)
@@ -106,7 +106,7 @@
                                                         "  Local High Score: "+multi_cast<std::string>(Highscore::getInstance().getHighestScoreOfGame("Flappy Orx"));
                             break;
                             case 3:
-                                int time = this->FlappyOrxGame->getPlayer()->timeUntilRespawn();
+                                time_t time = this->FlappyOrxGame->getPlayer()->timeUntilRespawn();
                                 if(time<=0)
                                     message = "Press space to restart.";
                                 else

Modified: code/branches/Presentation_HS17_merge/src/modules/flappyorx/FlappyOrxShip.cc
===================================================================
--- code/branches/Presentation_HS17_merge/src/modules/flappyorx/FlappyOrxShip.cc	2018-02-15 22:42:36 UTC (rev 11754)
+++ code/branches/Presentation_HS17_merge/src/modules/flappyorx/FlappyOrxShip.cc	2018-02-15 23:37:37 UTC (rev 11755)
@@ -136,7 +136,7 @@
         }
     }
 
-    int FlappyOrxShip::timeUntilRespawn(){
+    time_t FlappyOrxShip::timeUntilRespawn(){
         return 2-time(0)+deathTime;
     }
 

Modified: code/branches/Presentation_HS17_merge/src/modules/flappyorx/FlappyOrxShip.h
===================================================================
--- code/branches/Presentation_HS17_merge/src/modules/flappyorx/FlappyOrxShip.h	2018-02-15 22:42:36 UTC (rev 11754)
+++ code/branches/Presentation_HS17_merge/src/modules/flappyorx/FlappyOrxShip.h	2018-02-15 23:37:37 UTC (rev 11755)
@@ -57,13 +57,13 @@
             
             inline void  setSpeedBase(float speedBase){ getGame()->setSpeedBase(speedBase);}
             inline float getSpeedBase(){ return getGame()->getSpeedBase();}
-            inline void  setSpeedIncrease(int speedIncrease){ getGame()->setSpeedIncrease(speedIncrease);}
+            inline void  setSpeedIncrease(float speedIncrease){ getGame()->setSpeedIncrease(speedIncrease);}
             inline float getSpeedIncrease(){ return getGame()->getSpeedIncrease();}
 
-            inline void setTubeDistanceBase(int tubeDistanceBase){ getGame()->setTubeDistanceBase(tubeDistanceBase);}
-            inline int  getTubeDistanceBase(){ return getGame()->getTubeDistanceBase();}
-            inline void setTubeDistanceIncrease(int tubeDistanceIncrease){ getGame()->setTubeDistanceIncrease(tubeDistanceIncrease);}
-            inline int  getTubeDistanceIncrease(){ return getGame()->getTubeDistanceIncrease();}
+            inline void setTubeDistanceBase(float tubeDistanceBase){ getGame()->setTubeDistanceBase(tubeDistanceBase);}
+            inline float  getTubeDistanceBase(){ return getGame()->getTubeDistanceBase();}
+            inline void setTubeDistanceIncrease(float tubeDistanceIncrease){ getGame()->setTubeDistanceIncrease(tubeDistanceIncrease);}
+            inline float  getTubeDistanceIncrease(){ return getGame()->getTubeDistanceIncrease();}
 
             inline void  setUpwardthrust( float upwardThrust ){ this->upwardThrust = upwardThrust; }
             inline float getUpwardthrust(){ return this->upwardThrust; }
@@ -74,7 +74,7 @@
             inline float getSpeed( ){ return this->speed; }
             
    
-            virtual int timeUntilRespawn();
+            virtual time_t timeUntilRespawn();
             
             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
 
@@ -90,7 +90,7 @@
             bool isDead;
             float speed, upwardThrust, gravity;
             float particleAge, particleLifespan;
-            long deathTime;
+            time_t deathTime;
             struct Velocity
             {
                 float x;



More information about the Orxonox-commit mailing list