Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Feb 16, 2018, 12:37:37 AM (7 years ago)
Author:
landauf
Message:

[FlappyOrx_HS17] fixed some warnings (MSVC)

Location:
code/branches/Presentation_HS17_merge/src/modules/flappyorx
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • code/branches/Presentation_HS17_merge/src/modules/flappyorx/FlappyOrx.cc

    r11754 r11755  
    6767        firstGame = true;                   //needed for the HUD
    6868
    69         tubeDistance=200;                  //distance between tubes
    70         tubeOffsetX=500;                    //tube offset (so that we can't see them spawn)
     69        tubeDistance=200.0f;                  //distance between tubes
     70        tubeOffsetX=500.0f;                    //tube offset (so that we can't see them spawn)
    7171
    7272        circlesUsed=0;
     
    7474    }
    7575   
    76     void FlappyOrx::updatePlayerPos(int x){
     76    void FlappyOrx::updatePlayerPos(float x){
    7777
    7878        //Spawn a new Tube when the spawn distance is reached
     
    116116            return;
    117117
    118         int space = 130;    //vertical space between top and bottom tube
    119         int height = (float(rand())/RAND_MAX-0.5)*(280-space);  //Randomize height
     118        float space = 130.0f;    //vertical space between top and bottom tube
     119        float height = (rnd()-0.5f)*(280.0f-space);  //Randomize height
    120120           
    121121        Vector3 pos = player->getPosition();
    122122
    123123        //create the two Asteroid fields (Tubes)
    124         asteroidField(pos.x+tubeOffsetX,height-space/2,0.8);  //bottom 
    125         asteroidField(pos.x+tubeOffsetX,height+space/2,-0.8); //top
     124        asteroidField(pos.x+tubeOffsetX,height-space/2,0.8f);  //bottom
     125        asteroidField(pos.x+tubeOffsetX,height+space/2,-0.8f); //top
    126126    }
    127127
    128128    //Creates a new asteroid Field
    129     void FlappyOrx::asteroidField(int x, int y, float slope){
    130         int r = 20;     //Radius of added Asteroids
     129    void FlappyOrx::asteroidField(float x, float y, float slope){
     130        float r = 20.0f;     //Radius of added Asteroids
    131131        int noadd = 0;  //how many times we failed to add a new asteroid
    132132
     
    141141        while(noadd<5&&circlesUsed<nCircles){
    142142            if(slope>0)
    143                 newAsteroid.y=float(rand())/RAND_MAX*(150+y)-150;   //create asteroid on bottom
     143                newAsteroid.y=rnd(150+y)-150;   //create asteroid on bottom
    144144            else
    145                 newAsteroid.y=float(rand())/RAND_MAX*(150-y)+y;     //create asteroid on top
     145                newAsteroid.y=rnd(150-y)+y;     //create asteroid on top
    146146           
    147             newAsteroid.x=x+(float(rand())/RAND_MAX-0.5)*(y-newAsteroid.y)/slope;
     147            newAsteroid.x=x+(rnd()-0.5f)*(y-newAsteroid.y)/slope;
    148148            newAsteroid.r=r;
    149149           
     
    174174
    175175        //Randomize orientation
    176         newAsteroid->setOrientation(Vector3::UNIT_Z, Degree(rand()%360));
    177         newAsteroid->setOrientation(Vector3::UNIT_Y, Degree(rand()%360));
     176        newAsteroid->setOrientation(Vector3::UNIT_Z, Degree(rnd(360)));
     177        newAsteroid->setOrientation(Vector3::UNIT_Y, Degree(rnd(360)));
    178178
    179179        //add to Queue (so that we can delete it again)
     
    193193        if(c1.r<=0 || c2.r<=0)
    194194            return false;
    195         int x = c1.x - c2.x;
    196         int y = c1.y - c2.y;
    197         int r = c1.r + c2.r;
     195        float x = c1.x - c2.x;
     196        float y = c1.y - c2.y;
     197        float r = c1.r + c2.r;
    198198
    199199        return x*x+y*y<r*r*1.5;
  • code/branches/Presentation_HS17_merge/src/modules/flappyorx/FlappyOrx.h

    r11630 r11755  
    4646{
    4747    struct Circle{
    48         int r;
    49         int x;
    50         int y;
    51         Circle(int new_r, int new_x, int new_y){
     48        float r;
     49        float x;
     50        float y;
     51        Circle(float new_r, float new_x, float new_y){
    5252            r=new_r;
    5353            x=new_x;
     
    7070            virtual void death();
    7171           
    72             void updatePlayerPos(int x);
     72            void updatePlayerPos(float x);
    7373            void createAsteroid(Circle &c);
    74             void asteroidField(int x, int y, float slope);
     74            void asteroidField(float x, float y, float slope);
    7575            void spawnTube();
    7676           
     
    8989            float speedIncrease;
    9090
    91             int tubeDistanceBase;
    92             int tubeDistanceIncrease;
    93             int tubeDistance;
    94             int tubeOffsetX;
     91            float tubeDistanceBase;
     92            float tubeDistanceIncrease;
     93            float tubeDistance;
     94            float tubeOffsetX;
    9595
    9696            int upwardThrust;
    9797            int gravity;
    9898
    99             inline void setSpeedBase(int speedBase){ this-> speedBase =  speedBase;}
     99            inline void setSpeedBase(float speedBase){ this-> speedBase =  speedBase;}
    100100            inline float  getSpeedBase(){ return speedBase;}
    101             inline void setSpeedIncrease(int speedIncrease){ this-> speedIncrease =  speedIncrease;}
     101            inline void setSpeedIncrease(float speedIncrease){ this-> speedIncrease =  speedIncrease;}
    102102            inline float  getSpeedIncrease(){ return speedIncrease;}
    103103
    104             inline void setTubeDistanceBase(int tubeDistanceBase){ this-> tubeDistanceBase =  tubeDistanceBase;}
    105             inline int  getTubeDistanceBase(){ return tubeDistanceBase;}
    106             inline void setTubeDistanceIncrease(int tubeDistanceIncrease){ this-> tubeDistanceIncrease =  tubeDistanceIncrease;}
    107             inline int  getTubeDistanceIncrease(){ return tubeDistanceIncrease;}
     104            inline void setTubeDistanceBase(float tubeDistanceBase){ this-> tubeDistanceBase =  tubeDistanceBase;}
     105            inline float  getTubeDistanceBase(){ return tubeDistanceBase;}
     106            inline void setTubeDistanceIncrease(float tubeDistanceIncrease){ this-> tubeDistanceIncrease =  tubeDistanceIncrease;}
     107            inline float  getTubeDistanceIncrease(){ return tubeDistanceIncrease;}
    108108
    109109           
     
    112112            bool firstGame;
    113113            std::string sDeathMessage;
    114             std::queue<int> tubes;                  //Saves Position of Tubes
     114            std::queue<float> tubes;                  //Saves Position of Tubes
    115115            std::queue<MovableEntity*> asteroids;   //Stores Asteroids which build up the tubes
    116116            float speed = 100;
  • code/branches/Presentation_HS17_merge/src/modules/flappyorx/FlappyOrxHUDinfo.cc

    r11630 r11755  
    107107                            break;
    108108                            case 3:
    109                                 int time = this->FlappyOrxGame->getPlayer()->timeUntilRespawn();
     109                                time_t time = this->FlappyOrxGame->getPlayer()->timeUntilRespawn();
    110110                                if(time<=0)
    111111                                    message = "Press space to restart.";
  • code/branches/Presentation_HS17_merge/src/modules/flappyorx/FlappyOrxShip.cc

    r11754 r11755  
    137137    }
    138138
    139     int FlappyOrxShip::timeUntilRespawn(){
     139    time_t FlappyOrxShip::timeUntilRespawn(){
    140140        return 2-time(0)+deathTime;
    141141    }
  • code/branches/Presentation_HS17_merge/src/modules/flappyorx/FlappyOrxShip.h

    r11635 r11755  
    5858            inline void  setSpeedBase(float speedBase){ getGame()->setSpeedBase(speedBase);}
    5959            inline float getSpeedBase(){ return getGame()->getSpeedBase();}
    60             inline void  setSpeedIncrease(int speedIncrease){ getGame()->setSpeedIncrease(speedIncrease);}
     60            inline void  setSpeedIncrease(float speedIncrease){ getGame()->setSpeedIncrease(speedIncrease);}
    6161            inline float getSpeedIncrease(){ return getGame()->getSpeedIncrease();}
    6262
    63             inline void setTubeDistanceBase(int tubeDistanceBase){ getGame()->setTubeDistanceBase(tubeDistanceBase);}
    64             inline int  getTubeDistanceBase(){ return getGame()->getTubeDistanceBase();}
    65             inline void setTubeDistanceIncrease(int tubeDistanceIncrease){ getGame()->setTubeDistanceIncrease(tubeDistanceIncrease);}
    66             inline int  getTubeDistanceIncrease(){ return getGame()->getTubeDistanceIncrease();}
     63            inline void setTubeDistanceBase(float tubeDistanceBase){ getGame()->setTubeDistanceBase(tubeDistanceBase);}
     64            inline float  getTubeDistanceBase(){ return getGame()->getTubeDistanceBase();}
     65            inline void setTubeDistanceIncrease(float tubeDistanceIncrease){ getGame()->setTubeDistanceIncrease(tubeDistanceIncrease);}
     66            inline float  getTubeDistanceIncrease(){ return getGame()->getTubeDistanceIncrease();}
    6767
    6868            inline void  setUpwardthrust( float upwardThrust ){ this->upwardThrust = upwardThrust; }
     
    7575           
    7676   
    77             virtual int timeUntilRespawn();
     77            virtual time_t timeUntilRespawn();
    7878           
    7979            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
     
    9191            float speed, upwardThrust, gravity;
    9292            float particleAge, particleLifespan;
    93             long deathTime;
     93            time_t deathTime;
    9494            struct Velocity
    9595            {
Note: See TracChangeset for help on using the changeset viewer.