Changeset 11755 for code/branches/Presentation_HS17_merge
- Timestamp:
- Feb 16, 2018, 12:37:37 AM (7 years ago)
- 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 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; -
code/branches/Presentation_HS17_merge/src/modules/flappyorx/FlappyOrx.h
r11630 r11755 46 46 { 47 47 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){ 52 52 r=new_r; 53 53 x=new_x; … … 70 70 virtual void death(); 71 71 72 void updatePlayerPos( int x);72 void updatePlayerPos(float x); 73 73 void createAsteroid(Circle &c); 74 void asteroidField( int x, int y, float slope);74 void asteroidField(float x, float y, float slope); 75 75 void spawnTube(); 76 76 … … 89 89 float speedIncrease; 90 90 91 int tubeDistanceBase;92 int tubeDistanceIncrease;93 int tubeDistance;94 int tubeOffsetX;91 float tubeDistanceBase; 92 float tubeDistanceIncrease; 93 float tubeDistance; 94 float tubeOffsetX; 95 95 96 96 int upwardThrust; 97 97 int gravity; 98 98 99 inline void setSpeedBase( int speedBase){ this-> speedBase = speedBase;}99 inline void setSpeedBase(float speedBase){ this-> speedBase = speedBase;} 100 100 inline float getSpeedBase(){ return speedBase;} 101 inline void setSpeedIncrease( int speedIncrease){ this-> speedIncrease = speedIncrease;}101 inline void setSpeedIncrease(float speedIncrease){ this-> speedIncrease = speedIncrease;} 102 102 inline float getSpeedIncrease(){ return speedIncrease;} 103 103 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;} 108 108 109 109 … … 112 112 bool firstGame; 113 113 std::string sDeathMessage; 114 std::queue< int> tubes; //Saves Position of Tubes114 std::queue<float> tubes; //Saves Position of Tubes 115 115 std::queue<MovableEntity*> asteroids; //Stores Asteroids which build up the tubes 116 116 float speed = 100; -
code/branches/Presentation_HS17_merge/src/modules/flappyorx/FlappyOrxHUDinfo.cc
r11630 r11755 107 107 break; 108 108 case 3: 109 int time = this->FlappyOrxGame->getPlayer()->timeUntilRespawn();109 time_t time = this->FlappyOrxGame->getPlayer()->timeUntilRespawn(); 110 110 if(time<=0) 111 111 message = "Press space to restart."; -
code/branches/Presentation_HS17_merge/src/modules/flappyorx/FlappyOrxShip.cc
r11754 r11755 137 137 } 138 138 139 int FlappyOrxShip::timeUntilRespawn(){139 time_t FlappyOrxShip::timeUntilRespawn(){ 140 140 return 2-time(0)+deathTime; 141 141 } -
code/branches/Presentation_HS17_merge/src/modules/flappyorx/FlappyOrxShip.h
r11635 r11755 58 58 inline void setSpeedBase(float speedBase){ getGame()->setSpeedBase(speedBase);} 59 59 inline float getSpeedBase(){ return getGame()->getSpeedBase();} 60 inline void setSpeedIncrease( int speedIncrease){ getGame()->setSpeedIncrease(speedIncrease);}60 inline void setSpeedIncrease(float speedIncrease){ getGame()->setSpeedIncrease(speedIncrease);} 61 61 inline float getSpeedIncrease(){ return getGame()->getSpeedIncrease();} 62 62 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();} 67 67 68 68 inline void setUpwardthrust( float upwardThrust ){ this->upwardThrust = upwardThrust; } … … 75 75 76 76 77 virtual int timeUntilRespawn();77 virtual time_t timeUntilRespawn(); 78 78 79 79 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); … … 91 91 float speed, upwardThrust, gravity; 92 92 float particleAge, particleLifespan; 93 longdeathTime;93 time_t deathTime; 94 94 struct Velocity 95 95 {
Note: See TracChangeset
for help on using the changeset viewer.