- Timestamp:
- Feb 16, 2018, 12:37:37 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/Presentation_HS17_merge/src/modules/flappyorx/FlappyOrx.cc
r11754 r11755 67 67 firstGame = true; //needed for the HUD 68 68 69 tubeDistance=200 ; //distance between tubes70 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) 71 71 72 72 circlesUsed=0; … … 74 74 } 75 75 76 void FlappyOrx::updatePlayerPos( int x){76 void FlappyOrx::updatePlayerPos(float x){ 77 77 78 78 //Spawn a new Tube when the spawn distance is reached … … 116 116 return; 117 117 118 int space = 130; //vertical space between top and bottom tube119 int height = (float(rand())/RAND_MAX-0.5)*(280-space); //Randomize height118 float space = 130.0f; //vertical space between top and bottom tube 119 float height = (rnd()-0.5f)*(280.0f-space); //Randomize height 120 120 121 121 Vector3 pos = player->getPosition(); 122 122 123 123 //create the two Asteroid fields (Tubes) 124 asteroidField(pos.x+tubeOffsetX,height-space/2,0.8 ); //bottom125 asteroidField(pos.x+tubeOffsetX,height+space/2,-0.8 ); //top124 asteroidField(pos.x+tubeOffsetX,height-space/2,0.8f); //bottom 125 asteroidField(pos.x+tubeOffsetX,height+space/2,-0.8f); //top 126 126 } 127 127 128 128 //Creates a new asteroid Field 129 void FlappyOrx::asteroidField( int x, int y, float slope){130 int r = 20; //Radius of added Asteroids129 void FlappyOrx::asteroidField(float x, float y, float slope){ 130 float r = 20.0f; //Radius of added Asteroids 131 131 int noadd = 0; //how many times we failed to add a new asteroid 132 132 … … 141 141 while(noadd<5&&circlesUsed<nCircles){ 142 142 if(slope>0) 143 newAsteroid.y= float(rand())/RAND_MAX*(150+y)-150; //create asteroid on bottom143 newAsteroid.y=rnd(150+y)-150; //create asteroid on bottom 144 144 else 145 newAsteroid.y= float(rand())/RAND_MAX*(150-y)+y; //create asteroid on top145 newAsteroid.y=rnd(150-y)+y; //create asteroid on top 146 146 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; 148 148 newAsteroid.r=r; 149 149 … … 174 174 175 175 //Randomize orientation 176 newAsteroid->setOrientation(Vector3::UNIT_Z, Degree(r and()%360));177 newAsteroid->setOrientation(Vector3::UNIT_Y, Degree(r and()%360));176 newAsteroid->setOrientation(Vector3::UNIT_Z, Degree(rnd(360))); 177 newAsteroid->setOrientation(Vector3::UNIT_Y, Degree(rnd(360))); 178 178 179 179 //add to Queue (so that we can delete it again) … … 193 193 if(c1.r<=0 || c2.r<=0) 194 194 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; 198 198 199 199 return x*x+y*y<r*r*1.5;
Note: See TracChangeset
for help on using the changeset viewer.