Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

[FlappyOrx_HS17] fixed some warnings (MSVC)

File:
1 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;
Note: See TracChangeset for help on using the changeset viewer.