Changeset 11537 for code/branches/FlappyOrx_HS17/src/modules/flappyorx
- Timestamp:
- Nov 6, 2017, 3:32:04 PM (7 years ago)
- Location:
- code/branches/FlappyOrx_HS17/src/modules/flappyorx
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrx.cc
r11533 r11537 74 74 75 75 void FlappyOrx::updatePlayerPos(int x){ 76 76 77 if(this->tubes.size()==0||x-this->tubes.back()-tubeOffsetX>spawnDistance){ 77 78 spawnTube(); … … 82 83 levelUp(); 83 84 point++; 85 } 86 while((this->asteroids.front())->getPosition().x<x-300){ 87 MovableEntity* deleteMe = asteroids.front(); 88 asteroids.pop(); 89 deleteMe->destroy(); 84 90 } 85 91 } … … 144 150 } 145 151 152 void deleteAsteroid(MovableEntity* asteroid){ 153 //center_->getContext().getObjectList().removeElement(asteroid); 154 } 155 146 156 void FlappyOrx::createAsteroid(Circle &c){ 147 157 orxout() << "created Asteroid at x="<<c.x<<" y="<<c.y << std::endl; 158 148 159 MovableEntity* newAsteroid = new MovableEntity(this->center_->getContext()); 160 161 149 162 if(c.r<=5) 150 163 newAsteroid->addTemplate(Asteroid5[rand()%6]); … … 160 173 newAsteroid->setOrientation(Vector3::UNIT_Y, Degree(rand()%360)); 161 174 175 asteroids.push(newAsteroid); 176 177 162 178 } 163 179 … … 169 185 void FlappyOrx::costLife() 170 186 { 171 lives--; 172 multiplier = 1; 173 // end the game in 30 seconds. 174 if (lives <= 0) 175 enemySpawnTimer.setTimer(30.0f, false, createExecutor(createFunctor(&FlappyOrx::end, this))); 187 176 188 }; 177 189 … … 206 218 point += numPoints * multiplier; 207 219 b_combo = true; 220 } 221 } 222 223 void FlappyOrx::death(){ 224 if (Highscore::exists()){ 225 int score = this->getPoints(); 226 if(score > Highscore::getInstance().getHighestScoreOfGame("Orxonox Arcade")) 227 Highscore::getInstance().storeHighscore("Orxonox Arcade",score); 228 229 } 230 point = 0; 231 while (!tubes.empty()) 232 { 233 tubes.pop(); 234 } 235 while (!asteroids.empty()) 236 { 237 MovableEntity* deleteMe = asteroids.front(); 238 asteroids.pop(); 239 deleteMe->destroy(); 208 240 } 209 241 } -
code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrx.h
r11533 r11537 68 68 virtual void start() override; 69 69 virtual void end() override; 70 virtual void death(); 70 71 virtual void addBots(unsigned int amount) override{} //<! overwrite function in order to bypass the addbots command 71 72 … … 92 93 bool bShowLevel; 93 94 std::queue<int> tubes; 95 std::queue<MovableEntity*> asteroids; 94 96 int spawnDistance; 95 97 int tubeOffsetX; … … 146 148 int point; 147 149 bool b_combo; 148 std::string Asteroid5[6] = {"Asteroid3_1","Asteroid3_2","Asteroid3_3","Asteroid3_4","Asteroid3_5","Asteroid3_6"}; 149 std::string Asteroid10[6] = {"Asteroid6_1","Asteroid6_2","Asteroid6_3","Asteroid6_4","Asteroid6_5","Asteroid6_6"}; 150 std::string Asteroid15[6] = {"Asteroid9_1","Asteroid9_2","Asteroid9_3","Asteroid9_4","Asteroid9_5","Asteroid9_6"}; 151 std::string Asteroid20[6] = {"Asteroid12_1","Asteroid12_2","Asteroid12_3","Asteroid12_4","Asteroid12_5","Asteroid12_6"}; 150 151 const std::string Asteroid5[6] = {"Asteroid3_1","Asteroid3_2","Asteroid3_3","Asteroid3_4","Asteroid3_5","Asteroid3_6"}; 152 const std::string Asteroid10[6] = {"Asteroid6_1","Asteroid6_2","Asteroid6_3","Asteroid6_4","Asteroid6_5","Asteroid6_6"}; 153 const std::string Asteroid15[6] = {"Asteroid9_1","Asteroid9_2","Asteroid9_3","Asteroid9_4","Asteroid9_5","Asteroid9_6"}; 154 const std::string Asteroid20[6] = {"Asteroid12_1","Asteroid12_2","Asteroid12_3","Asteroid12_4","Asteroid12_5","Asteroid12_6"}; 155 152 156 153 157 -
code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxAsteroid.cc
r11530 r11537 1 /*2 * ORXONOX - the hottest 3D action shooter ever to exist3 * > www.orxonox.net <4 *5 *6 * License notice:7 *8 * This program is free software; you can redistribute it and/or9 * modify it under the terms of the GNU General Public License10 * as published by the Free Software Foundation; either version 211 * of the License, or (at your option) any later version.12 *13 * This program is distributed in the hope that it will be useful,14 * but WITHOUT ANY WARRANTY; without even the implied warranty of15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the16 * GNU General Public License for more details.17 *18 * You should have received a copy of the GNU General Public License19 * along with this program; if not, write to the Free Software20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.21 *22 * Author:23 * Florian Zinggeler24 * Co-authors:25 * ...26 *27 */28 29 /**30 @file FlappyOrxAsteroid.h31 @brief Declaration of the FlappyOrxAsteroid class.32 */33 34 #include "FlappyOrxAsteroid.h"35 36 #include "core/CoreIncludes.h"37 #include "FlappyOrx.h"38 #include "FlappyOrxShip.h"39 40 namespace orxonox41 {42 RegisterClass(FlappyOrxAsteroid);43 44 FlappyOrxAsteroid::FlappyOrxAsteroid(Context* context) : Pawn(context)45 {46 RegisterObject(FlappyOrxAsteroid);47 enableCollisionCallback();48 lifetime = 0;49 }50 51 void FlappyOrxAsteroid::tick(float dt)52 {53 lifetime += dt;54 // die after 5 seconds.55 if (lifetime > 5000)56 removeHealth(2000);57 58 if (player != nullptr)59 {60 float newZ = 2/(pow(std::abs(getPosition().x - player->getPosition().x) * 0.01f, 2) + 1) * (player->getPosition().z - getPosition().z);61 setVelocity(Vector3(1000.f - level * 100 , 0, newZ));62 }63 SUPER(FlappyOrxAsteroid, tick, dt);64 }65 66 inline bool FlappyOrxAsteroid::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint)67 {68 if(orxonox_cast<FlappyOrxShip*>(otherObject))69 removeHealth(2000);70 return false;71 }72 73 FlappyOrx* FlappyOrxAsteroid::getGame()74 {75 if (game == nullptr)76 {77 for (FlappyOrx* flappyOrx : ObjectList<FlappyOrx>())78 game = flappyOrx;79 }80 return game;81 }82 83 void FlappyOrxAsteroid::damage(float damage, float healthdamage, float shielddamage, Pawn* originator, const btCollisionShape* cs)84 {85 Pawn::damage(damage, healthdamage, shielddamage, originator, cs);86 if (getGame() && orxonox_cast<FlappyOrxShip*>(originator) != nullptr && getHealth() <= 0)87 getGame()->addPoints(42);88 }89 } -
code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxAsteroid.h
r11530 r11537 1 /*2 * ORXONOX - the hottest 3D action shooter ever to exist3 * > www.orxonox.net <4 *5 *6 * License notice:7 *8 * This program is free software; you can redistribute it and/or9 * modify it under the terms of the GNU General Public License10 * as published by the Free Software Foundation; either version 211 * of the License, or (at your option) any later version.12 *13 * This program is distributed in the hope that it will be useful,14 * but WITHOUT ANY WARRANTY; without even the implied warranty of15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the16 * GNU General Public License for more details.17 *18 * You should have received a copy of the GNU General Public License19 * along with this program; if not, write to the Free Software20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.21 *22 * Author:23 * Florian Zinggeler24 * Co-authors:25 * ...26 *27 */28 29 /**30 @file FlappyOrxAsteroid.h31 @brief Declaration of the FlappyOrxAsteroid class.32 */33 34 #ifndef _FlappyOrxAsteroid_H__35 #define _FlappyOrxAsteroid_H__36 37 #include "flappyorx/FlappyOrxPrereqs.h"38 39 #include "worldentities/pawns/Pawn.h"40 41 namespace orxonox42 {43 class _FlappyOrxExport FlappyOrxAsteroid : public Pawn44 {45 public:46 FlappyOrxAsteroid(Context* context);47 48 virtual void tick(float dt) override;49 virtual bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) override;50 virtual void damage(float damage, float healthdamage, float shielddamage, Pawn* originator, const btCollisionShape* cs) override;51 virtual void setFlappyOrxPlayer(FlappyOrxShip* player){this->player = player;}52 53 int level;54 protected:55 FlappyOrx* getGame();56 WeakPtr<FlappyOrx> game;57 WeakPtr<FlappyOrxShip> player;58 Camera* camera;59 bool isFireing;60 float speed, damping;61 float lastTimeFront, lastTimeLeft;62 float lifetime;63 struct Velocity64 {65 float x;66 float y;67 } velocity, desiredVelocity;68 69 };70 }71 72 #endif /* _FlappyOrxAsteroid_H__ */ -
code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxShip.cc
r11529 r11537 70 70 if(getHealth()<0){ 71 71 getGame()->costLife(); 72 getGame()->end(); 72 getGame()->death(); 73 death(); 73 74 } 74 75 Vector3 pos = getPosition(); … … 151 152 void FlappyOrxShip::death() 152 153 { 153 154 Vector3 pos = getPosition(); 155 pos.x = 0; 156 setPosition(pos); 154 157 } 155 158 }
Note: See TracChangeset
for help on using the changeset viewer.