[Orxonox-commit 6750] r11378 - code/branches/SuperOrxoBros_FS17/src/modules/superorxobros

jkindle at orxonox.net jkindle at orxonox.net
Thu Mar 23 15:53:52 CET 2017


Author: jkindle
Date: 2017-03-23 15:53:52 +0100 (Thu, 23 Mar 2017)
New Revision: 11378

Modified:
   code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/CMakeLists.txt
   code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOB.cc
   code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOB.h
Log:
added some structire. Next to do, fix Centerpoint and error when compiling

Modified: code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/CMakeLists.txt
===================================================================
--- code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/CMakeLists.txt	2017-03-23 14:51:57 UTC (rev 11377)
+++ code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/CMakeLists.txt	2017-03-23 14:53:52 UTC (rev 11378)
@@ -1,6 +1,9 @@
-SET_SOURCE_FILES(Superorxobros_SRC_FILES
-  Orxo.cc
+SET_SOURCE_FILES(SOB_SRC_FILES
 
+  SOBCenterpoint.cc
+  SOB.cc
+  SOBFigure.cc
+  
 
 )
 
@@ -10,6 +13,5 @@
   LINK_LIBRARIES
     orxonox
     overlays
-    weapons
-  SOURCE_FILES ${Superorxobros_SRC_FILES}
+  SOURCE_FILES ${SOB_SRC_FILES}
 )

Modified: code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOB.cc
===================================================================
--- code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOB.cc	2017-03-23 14:51:57 UTC (rev 11377)
+++ code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOB.cc	2017-03-23 14:53:52 UTC (rev 11378)
@@ -20,7 +20,7 @@
  *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  *
  *   Author:
- *      Florian Zinggeler
+ *      Fabian 'x3n' Landau
  *   Co-authors:
  *      ...
  *
@@ -27,12 +27,12 @@
  */
 
 /**
-    @file Invader.cc
-    @brief Implementation of the Invader class.
+    @file Pong.cc
+    @brief Implementation of the Pong class.
 */
 
-#include "Invader.h"
-#include "Highscore.h"
+#include "SOB.h"
+
 #include "core/CoreIncludes.h"
 #include "core/EventIncludes.h"
 #include "core/command/Executor.h"
@@ -41,159 +41,113 @@
 #include "gamestates/GSLevel.h"
 #include "chat/ChatManager.h"
 
-// ! HACK
-#include "infos/PlayerInfo.h"
+#include "SOBCenterpoint.h"
 
-#include "InvaderCenterPoint.h"
-#include "InvaderShip.h"
-#include "InvaderEnemy.h"
-#include "InvaderEnemyShooter.h"
+//#include "PongBat.h"
+//#include "PongBot.h"
+//#include "PongAI.h"
 
-#include "core/command/ConsoleCommand.h"
-#include "worldentities/ExplosionPart.h"
-
 namespace orxonox
 {
-    RegisterUnloadableClass(Invader);
+  
+    RegisterUnloadableClass(SOB);
 
-    Invader::Invader(Context* context) : Deathmatch(context)
+    /**
+    @brief
+        Constructor. Registers and initializes the object.
+    */
+    SOB::SOB(Context* context) : Deathmatch(context)
     {
-        RegisterObject(Invader);
-        this->numberOfBots_ = 0; //sets number of default bots temporarly to 0
+        RegisterObject(SOB);
+
         this->center_ = nullptr;
-        bEndGame = false;
-        lives = 3;
-        level = 1;
-        point = 0;
-        bShowLevel = false;
-        multiplier = 1;
-        b_combo = false;
-        // spawn enemy every 3.5 seconds
-        enemySpawnTimer.setTimer(3.5f, true, createExecutor(createFunctor(&Invader::spawnEnemy, this)));
-        comboTimer.setTimer(3.0f, true, createExecutor(createFunctor(&Invader::comboControll, this)));
-        this->setHUDTemplate("InvaderHUD");
+           figure_ = nullptr;
+
     }
 
-    void Invader::levelUp()
+    /**
+    @brief
+        Destructor. Cleans up, if initialized.
+    */
+    SOB::~SOB()
     {
-        level++;
-        if (getPlayer() != nullptr)
-        {
-            for (int i = 0; i < 7; i++)
-            {
+        if (this->isInitialized())
+            this->cleanup();
+    }
 
-                WeakPtr<ExplosionPart> chunk5 = new ExplosionPart(this->center_->getContext());
-                chunk5->setPosition(this->center_->getPosition());
-                chunk5->setVelocity(Vector3(1000, 0, 0));  //player->getVelocity()
-                chunk5->setScale(10);
-                chunk5->setEffect1("Orxonox/explosion2b");
-                chunk5->setEffect2("Orxonox/smoke6");
-                chunk5->setMinSpeed(0);
-                chunk5->setMaxSpeed(0);
-                chunk5->Explode();
 
-            }
-        }
-        addPoints(multiplier * 42);
-        multiplier *= 2;
-        toggleShowLevel();
-        showLevelTimer.setTimer(1.0f, false, createExecutor(createFunctor(&Invader::toggleShowLevel, this)));
-    }
 
-    InvaderShip* Invader::getPlayer()
+        void SOB::start()
     {
-        if (player == nullptr)
+        if (center_ != nullptr) // There needs to be a SOBCenterpoint, i.e. the area the game takes place.
         {
-            for (InvaderShip* ship : ObjectList<InvaderShip>())
-                player = ship;
+            if (figure_ == nullptr)
+            {
+                figure_ = new SOBFigure(center_->getContext());
+                figure_->addTemplate(center_->getFigureTemplate()); /
+                figure_->InitializeAnimation(center_->getContext()); //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+            }
+
+            center_->attach(figure_);   //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+            figure_->setPosition(0, 0, 0);
         }
-        return player;
-    }
-
-    void Invader::spawnEnemy()
-    {
-        if (getPlayer() == nullptr)
+        else // If no centerpoint was specified, an error is thrown and the level is exited.
+        {
+            orxout(internal_error) << "SOB: No Centerpoint specified." << endl;
+            GSLevel::startMainMenu();
             return;
+        }
 
-        for (int i = 0; i < (3*log10(static_cast<double>(level)) + 1); i++)
+        // Call start for the parent class.
+        Deathmatch::start();
+
+        if (figure_ != nullptr)
         {
-            InvaderEnemy* newPawn;
-            if (rand() % 42/(1 + level*level) == 0)
-            {
-                newPawn = new InvaderEnemyShooter(this->center_->getContext());
-                newPawn->addTemplate("enemyinvadershooter");
-            }
-            else
-            {
-                newPawn = new InvaderEnemy(this->center_->getContext());
-                newPawn->addTemplate("enemyinvader");
-            }
-            newPawn->setInvaderPlayer(player);
-            newPawn->level = level;
-            // spawn enemy at random points in front of player.
-            newPawn->setPosition(player->getPosition() + Vector3(500.f + 100 * i, 0, float(rand())/RAND_MAX * 400 - 200));
+            camera = figure_->getCamera();
         }
-    }
 
-    void Invader::setCenterpoint(InvaderCenterPoint* center)
-    {
-        this->center_ = center;
+        totalScreenShift_ = 0.0;
+        screenShiftSinceLastUpdate_ = 0.0;
+        sectionNumber_ = 0;
+        adventureNumber_ = 0;
+
+        addStartSection();
+        addSection();
+        addSection();
     }
 
-    void Invader::costLife()
+    void SOB::end()
     {
-        lives--;
-        multiplier = 1;
-        // end the game in 30 seconds.
-        if (lives <= 0)
-            enemySpawnTimer.setTimer(30.0f, false, createExecutor(createFunctor(&Invader::end, this)));
-    };
-
-    void Invader::comboControll()
-    {
-        if (b_combo)
-            multiplier++;
-        // if no combo was performed before, reset multiplier
-        else
-            multiplier = 1;
-        b_combo = false;
+        cleanup();
+        GSLevel::startMainMenu();
+ 
+        Deathmatch::end();
     }
 
-    void Invader::start()
+    void SOB::spawnPlayer(PlayerInfo* player)
     {
-        // Set variable to temporarily force the player to spawn.
-        this->bForceSpawn_ = true;
+        assert(player);
 
-        if (this->center_ == nullptr)  // abandon mission!
+        if (figure_->getPlayer() == nullptr)
         {
-            orxout(internal_error) << "Invader: No Centerpoint specified." << endl;
-            GSLevel::startMainMenu();
-            return;
+            player->startControl(figure_);
+            players_[player].state_ = PlayerState::Alive;
         }
-        // Call start for the parent class.
-        Deathmatch::start();
     }
-    void Invader::addPoints(int numPoints)
+
+    PlayerInfo* SOB::getPlayer() const
     {
-        if (!bEndGame)
+        if (this->figure_ != nullptr)
         {
-            point += numPoints * multiplier;
-            b_combo = true;
+            return this->figure_->getPlayer();
         }
+        else
+        {
+            return nullptr;
+        }
     }
 
-    void Invader::end()
-    {
-        // DON'T CALL THIS!
-        //      Deathmatch::end();
-        // It will misteriously crash the game!
-        // Instead startMainMenu, this won't crash.
-        if (Highscore::exists()){
-                    int score = this->getPoints();
-                    if(score > Highscore::getInstance().getHighestScoreOfGame("Orxonox Arcade")) 
-                        Highscore::getInstance().storeHighscore("Orxonox Arcade",score);
 
-          }
-        GSLevel::startMainMenu();
-    }
+   
+ 
 }

Modified: code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOB.h
===================================================================
--- code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOB.h	2017-03-23 14:51:57 UTC (rev 11377)
+++ code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOB.h	2017-03-23 14:53:52 UTC (rev 11378)
@@ -20,7 +20,7 @@
  *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  *
  *   Author:
- *      Florian Zinggeler
+ *      Fabian 'x3n' Landau
  *   Co-authors:
  *      ...
  *
@@ -27,63 +27,50 @@
  */
 
 /**
-    @file Invader.h
-    @brief Gametype.
-    @ingroup Invader
+    @file Pong.h
+    @brief Declaration of the Pong class.
+    @ingroup Pong
 */
 
-#ifndef _Invader_H__
-#define _Invader_H__
+#ifndef _SOB_H__
+#define _SOB_H__
 
-#include "invader/InvaderPrereqs.h"
+#include "superorxobros/SOBPrereqs.h"
 
-#include "gametypes/Deathmatch.h"
 #include "tools/Timer.h"
 
+#include "gametypes/Deathmatch.h"
+#include "SOBCenterpoint.h"
+
 namespace orxonox
 {
 
-    class _InvaderExport Invader : public Deathmatch
+  
+    class _SOBExport SOB : public Deathmatch
     {
         public:
-            Invader(Context* context);
+            SOB(Context* context); //!< Constructor. Registers and initializes the object.
+            virtual ~SOB(); //!< Destructor. Cleans up, if initialized.
 
-            virtual void start() override;
-            virtual void end() override;
-            virtual void addBots(unsigned int amount) override{} //<! overwrite function in order to bypass the addbots command
+       
+            void setCenterpoint(SOBCenterpoint* center)
+                { this->center_ = center; }
+            void setFigureTemplate(const std::string& newTemplate)
+                { this->figureTemplate_ = newTemplate; }
+            
+            const std::string& getFigureTemplate() const
+                { return this->figureTemplate_; }
+        
+          
+        protected:
+        
 
-            void spawnEnemy();
-
-            void setCenterpoint(InvaderCenterPoint* center);
-
-            int getLives(){return this->lives;}
-            int getLevel(){return this->level;}
-            int getPoints(){return this->point;}
-            int getMultiplier(){return this->multiplier;}
-
-            void costLife();
-            void levelUp();
-            void addPoints(int numPoints);
-            // checks if multiplier should be reset.
-            void comboControll();
-            int lives;
-            int multiplier;
-            bool bEndGame;
-            bool bShowLevel;
-        private:
-            void toggleShowLevel(){bShowLevel = !bShowLevel;}
-            InvaderShip* getPlayer();
-            WeakPtr<InvaderCenterPoint> center_;
-            WeakPtr<InvaderShip> player;
-
-            Timer enemySpawnTimer;
-            Timer comboTimer;
-            Timer showLevelTimer;
-            //Context* context;
-            int level;
-            int point;
-            bool b_combo;
+            void cleanup(); //!< Cleans up the Gametype by destroying the ball and the bats.
+             WeakPtr<SOBCenterpoint> center_;
+            WeakPtr<SOBFigure> figure_;
+            WeakPtr<Camera> camera;
+          
     };
 }
 
-#endif /* _Invader_H__ */
+#endif /* _Pong_H__ */



More information about the Orxonox-commit mailing list