- Timestamp:
- Nov 6, 2017, 12:52:38 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrx.cc
r11521 r11529 47 47 #include "FlappyOrxCenterPoint.h" 48 48 #include "FlappyOrxShip.h" 49 #include "FlappyOrxAsteroid.h" 49 50 50 51 #include "core/command/ConsoleCommand.h" … … 67 68 multiplier = 1; 68 69 b_combo = false; 69 70 this->spawnDistance=300; 71 this->tubeOffsetX=500; 70 72 this->setHUDTemplate("FlappyOrxHUD"); 71 73 } 72 74 75 void FlappyOrx::updatePlayerPos(int x){ 76 if(this->tubes.size()==0||x-this->tubes.back()-tubeOffsetX>spawnDistance){ 77 spawnTube(); 78 this->tubes.push(x+tubeOffsetX); 79 } 80 if(this->tubes.size()!=0&&x>this->tubes.front()){ 81 this->tubes.pop(); 82 levelUp(); 83 } 84 } 85 73 86 void FlappyOrx::levelUp() 74 87 { 75 88 level++; 76 if (getPlayer() != nullptr) 77 { 78 for (int i = 0; i < 7; i++) 79 { 80 81 WeakPtr<ExplosionPart> chunk5 = new ExplosionPart(this->center_->getContext()); 82 chunk5->setPosition(this->center_->getPosition()); 83 chunk5->setVelocity(Vector3(1000, 0, 0)); //player->getVelocity() 84 chunk5->setScale(10); 85 chunk5->setEffect1("Orxonox/explosion2b"); 86 chunk5->setEffect2("Orxonox/smoke6"); 87 chunk5->setMinSpeed(0); 88 chunk5->setMaxSpeed(0); 89 chunk5->Explode(); 90 91 } 92 } 93 addPoints(multiplier * 42); 94 multiplier *= 2; 95 toggleShowLevel(); 96 showLevelTimer.setTimer(1.0f, false, createExecutor(createFunctor(&FlappyOrx::toggleShowLevel, this))); 89 //toggleShowLevel(); 90 //showLevelTimer.setTimer(3.0f, false, createExecutor(createFunctor(&FlappyOrx::toggleShowLevel, this))); 97 91 } 98 92 … … 108 102 } 109 103 110 104 void FlappyOrx::spawnTube() 105 { 106 int space = 90; 107 int height = (float(rand())/RAND_MAX-0.5)*(280-space); 108 109 if (getPlayer() == nullptr) 110 return; 111 112 Vector3 pos = player->getPosition(); 113 114 asteroidField(pos.x+tubeOffsetX,height-space/2,0.8); 115 asteroidField(pos.x+tubeOffsetX,height+space/2,-0.8); 116 } 117 118 void FlappyOrx::asteroidField(int x, int y, float slope){ 119 int r = 20; 120 int noadd = 0; 121 122 ClearAsteroids(); 123 Circle newAsteroid = Circle(); 124 while(r>0){ 125 if(slope>0) 126 newAsteroid.y=float(rand())/RAND_MAX*(150+y)-150; 127 else 128 newAsteroid.y=float(rand())/RAND_MAX*(150-y)+y; 129 130 newAsteroid.x=x+(float(rand())/RAND_MAX-0.5)*(y-newAsteroid.y)/slope; 131 newAsteroid.r=r; 132 133 int i = addIfPossible(newAsteroid); 134 if(i==0) 135 noadd++; 136 else if(i==2) 137 r=0; 138 if(noadd>=5){ 139 noadd=0; 140 r-=5; 141 } 142 } 143 } 144 145 void FlappyOrx::createAsteroid(Circle &c){ 146 orxout() << "created Asteroid at x="<<c.x<<" y="<<c.y << std::endl; 147 MovableEntity* newAsteroid = new MovableEntity(this->center_->getContext()); 148 if(c.r<=5) 149 newAsteroid->addTemplate(Asteroid5[rand()%6]); 150 else if(c.r<=10) 151 newAsteroid->addTemplate(Asteroid10[rand()%6]); 152 else if(c.r<=15) 153 newAsteroid->addTemplate(Asteroid15[rand()%6]); 154 else 155 newAsteroid->addTemplate(Asteroid20[rand()%6]); 156 157 newAsteroid->setPosition(Vector3(c.x, 0, c.y)); 158 newAsteroid->setOrientation(Vector3::UNIT_Z, Degree(rand()%360)); 159 newAsteroid->setOrientation(Vector3::UNIT_Y, Degree(rand()%360)); 160 161 } 111 162 112 163 void FlappyOrx::setCenterpoint(FlappyOrxCenterPoint* center)
Note: See TracChangeset
for help on using the changeset viewer.