[Orxonox-commit 6916] r11537 - code/branches/FlappyOrx_HS17/src/modules/flappyorx

pascscha at orxonox.net pascscha at orxonox.net
Mon Nov 6 15:32:04 CET 2017


Author: pascscha
Date: 2017-11-06 15:32:04 +0100 (Mon, 06 Nov 2017)
New Revision: 11537

Modified:
   code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrx.cc
   code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrx.h
   code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxAsteroid.cc
   code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxAsteroid.h
   code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxShip.cc
Log:
Death

Modified: code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrx.cc
===================================================================
--- code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrx.cc	2017-11-06 14:04:36 UTC (rev 11536)
+++ code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrx.cc	2017-11-06 14:32:04 UTC (rev 11537)
@@ -73,6 +73,7 @@
     }
 
     void FlappyOrx::updatePlayerPos(int x){
+
         if(this->tubes.size()==0||x-this->tubes.back()-tubeOffsetX>spawnDistance){
             spawnTube();
             this->tubes.push(x+tubeOffsetX);
@@ -82,6 +83,11 @@
             levelUp();
             point++;
         }
+        while((this->asteroids.front())->getPosition().x<x-300){
+            MovableEntity* deleteMe = asteroids.front();
+            asteroids.pop();
+            deleteMe->destroy();
+        }
     }
 
     void FlappyOrx::levelUp()
@@ -143,9 +149,16 @@
         }
     }
 
+    void deleteAsteroid(MovableEntity* asteroid){
+        //center_->getContext().getObjectList().removeElement(asteroid);
+    }
+
     void FlappyOrx::createAsteroid(Circle &c){
         orxout() << "created Asteroid at x="<<c.x<<" y="<<c.y << std::endl;
+
         MovableEntity* newAsteroid = new MovableEntity(this->center_->getContext());
+
+
         if(c.r<=5)
             newAsteroid->addTemplate(Asteroid5[rand()%6]);
         else if(c.r<=10)
@@ -159,6 +172,9 @@
         newAsteroid->setOrientation(Vector3::UNIT_Z, Degree(rand()%360));
         newAsteroid->setOrientation(Vector3::UNIT_Y, Degree(rand()%360));
 
+        asteroids.push(newAsteroid);
+
+
     }
 
     void FlappyOrx::setCenterpoint(FlappyOrxCenterPoint* center)
@@ -168,11 +184,7 @@
 
     void FlappyOrx::costLife()
     {
-        lives--;
-        multiplier = 1;
-        // end the game in 30 seconds.
-        if (lives <= 0)
-            enemySpawnTimer.setTimer(30.0f, false, createExecutor(createFunctor(&FlappyOrx::end, this)));
+        
     };
 
     void FlappyOrx::comboControll()
@@ -208,6 +220,26 @@
         }
     }
 
+    void FlappyOrx::death(){
+        if (Highscore::exists()){
+                    int score = this->getPoints();
+                    if(score > Highscore::getInstance().getHighestScoreOfGame("Orxonox Arcade")) 
+                        Highscore::getInstance().storeHighscore("Orxonox Arcade",score);
+
+        }
+        point = 0;
+        while (!tubes.empty())
+        {
+            tubes.pop();
+        }
+        while (!asteroids.empty())
+        {
+            MovableEntity* deleteMe = asteroids.front();
+            asteroids.pop();
+            deleteMe->destroy();
+        }
+    }
+
     void FlappyOrx::end()
     {
         // DON'T CALL THIS!

Modified: code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrx.h
===================================================================
--- code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrx.h	2017-11-06 14:04:36 UTC (rev 11536)
+++ code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrx.h	2017-11-06 14:32:04 UTC (rev 11537)
@@ -67,6 +67,7 @@
 
             virtual void start() override;
             virtual void end() override;
+            virtual void death();
             virtual void addBots(unsigned int amount) override{} //<! overwrite function in order to bypass the addbots command
 
             void updatePlayerPos(int x);
@@ -91,6 +92,7 @@
             bool bEndGame;
             bool bShowLevel;
             std::queue<int> tubes;
+            std::queue<MovableEntity*> asteroids;
             int spawnDistance;
             int tubeOffsetX;
         private:
@@ -145,13 +147,15 @@
             int level;
             int point;
             bool b_combo;
-            std::string Asteroid5[6] = {"Asteroid3_1","Asteroid3_2","Asteroid3_3","Asteroid3_4","Asteroid3_5","Asteroid3_6"};
-            std::string Asteroid10[6] = {"Asteroid6_1","Asteroid6_2","Asteroid6_3","Asteroid6_4","Asteroid6_5","Asteroid6_6"};
-            std::string Asteroid15[6] = {"Asteroid9_1","Asteroid9_2","Asteroid9_3","Asteroid9_4","Asteroid9_5","Asteroid9_6"};
-            std::string Asteroid20[6] = {"Asteroid12_1","Asteroid12_2","Asteroid12_3","Asteroid12_4","Asteroid12_5","Asteroid12_6"};
 
+            const std::string Asteroid5[6] = {"Asteroid3_1","Asteroid3_2","Asteroid3_3","Asteroid3_4","Asteroid3_5","Asteroid3_6"};
+            const std::string Asteroid10[6] = {"Asteroid6_1","Asteroid6_2","Asteroid6_3","Asteroid6_4","Asteroid6_5","Asteroid6_6"};
+            const std::string Asteroid15[6] = {"Asteroid9_1","Asteroid9_2","Asteroid9_3","Asteroid9_4","Asteroid9_5","Asteroid9_6"};
+            const std::string Asteroid20[6] = {"Asteroid12_1","Asteroid12_2","Asteroid12_3","Asteroid12_4","Asteroid12_5","Asteroid12_6"};
+            
 
 
+
     };
 }
 

Modified: code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxAsteroid.cc
===================================================================
--- code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxAsteroid.cc	2017-11-06 14:04:36 UTC (rev 11536)
+++ code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxAsteroid.cc	2017-11-06 14:32:04 UTC (rev 11537)
@@ -1,89 +0,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Florian Zinggeler
- *   Co-authors:
- *      ...
- *
- */
-
-/**
-    @file FlappyOrxAsteroid.h
-    @brief Declaration of the FlappyOrxAsteroid class.
-*/
-
-#include "FlappyOrxAsteroid.h"
-
-#include "core/CoreIncludes.h"
-#include "FlappyOrx.h"
-#include "FlappyOrxShip.h"
-
-namespace orxonox
-{
-    RegisterClass(FlappyOrxAsteroid);
-
-    FlappyOrxAsteroid::FlappyOrxAsteroid(Context* context) : Pawn(context)
-    {
-        RegisterObject(FlappyOrxAsteroid);
-        enableCollisionCallback();
-        lifetime = 0;
-    }
-
-    void FlappyOrxAsteroid::tick(float dt)
-    {
-        lifetime += dt;
-        // die after 5 seconds.
-        if (lifetime > 5000)
-            removeHealth(2000);
-
-        if (player != nullptr)
-        {
-            float newZ = 2/(pow(std::abs(getPosition().x - player->getPosition().x) * 0.01f, 2) + 1) * (player->getPosition().z - getPosition().z);
-            setVelocity(Vector3(1000.f - level * 100 , 0, newZ));
-        }
-        SUPER(FlappyOrxAsteroid, tick, dt);
-    }
-
-    inline bool FlappyOrxAsteroid::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint)
-    {
-        if(orxonox_cast<FlappyOrxShip*>(otherObject))
-            removeHealth(2000);
-        return false;
-    }
-
-    FlappyOrx* FlappyOrxAsteroid::getGame()
-    {
-        if (game == nullptr)
-        {
-            for (FlappyOrx* flappyOrx : ObjectList<FlappyOrx>())
-                game = flappyOrx;
-        }
-        return game;
-    }
-
-    void FlappyOrxAsteroid::damage(float damage, float healthdamage, float shielddamage, Pawn* originator, const btCollisionShape* cs)
-    {
-        Pawn::damage(damage, healthdamage, shielddamage, originator, cs);
-        if (getGame() && orxonox_cast<FlappyOrxShip*>(originator) != nullptr && getHealth() <= 0)
-            getGame()->addPoints(42);
-    }
-}

Modified: code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxAsteroid.h
===================================================================
--- code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxAsteroid.h	2017-11-06 14:04:36 UTC (rev 11536)
+++ code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxAsteroid.h	2017-11-06 14:32:04 UTC (rev 11537)
@@ -1,72 +0,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Florian Zinggeler
- *   Co-authors:
- *      ...
- *
- */
-
-/**
-    @file FlappyOrxAsteroid.h
-    @brief Declaration of the FlappyOrxAsteroid class.
-*/
-
-#ifndef _FlappyOrxAsteroid_H__
-#define _FlappyOrxAsteroid_H__
-
-#include "flappyorx/FlappyOrxPrereqs.h"
-
-#include "worldentities/pawns/Pawn.h"
-
-namespace orxonox
-{
-    class _FlappyOrxExport FlappyOrxAsteroid : public Pawn
-    {
-        public:
-            FlappyOrxAsteroid(Context* context);
-
-            virtual void tick(float dt) override;
-            virtual bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) override;
-            virtual void damage(float damage, float healthdamage, float shielddamage, Pawn* originator, const btCollisionShape* cs) override;
-            virtual void setFlappyOrxPlayer(FlappyOrxShip* player){this->player = player;}
-
-            int level;
-        protected:
-            FlappyOrx* getGame();
-            WeakPtr<FlappyOrx> game;
-            WeakPtr<FlappyOrxShip> player;
-            Camera* camera;
-            bool isFireing;
-            float speed, damping;
-            float lastTimeFront, lastTimeLeft;
-            float lifetime;
-            struct Velocity
-            {
-                float x;
-                float y;
-            } velocity, desiredVelocity;
-
-    };
-}
-
-#endif /* _FlappyOrxAsteroid_H__ */

Modified: code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxShip.cc
===================================================================
--- code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxShip.cc	2017-11-06 14:04:36 UTC (rev 11536)
+++ code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxShip.cc	2017-11-06 14:32:04 UTC (rev 11537)
@@ -69,7 +69,8 @@
         {
             if(getHealth()<0){
                  getGame()->costLife();
-                 getGame()->end();
+                 getGame()->death();
+                 death();
             }
             Vector3 pos = getPosition();
 
@@ -150,6 +151,8 @@
 
     void FlappyOrxShip::death()
     {
-
+        Vector3 pos = getPosition();
+        pos.x = 0;
+        setPosition(pos);
     }
 }



More information about the Orxonox-commit mailing list