[Orxonox-commit 7502] r12108 - in code/branches/OrxoKart_HS18: data/levels src/modules/orxokart

ottka at orxonox.net ottka at orxonox.net
Wed Nov 21 09:32:16 CET 2018


Author: ottka
Date: 2018-11-21 09:32:15 +0100 (Wed, 21 Nov 2018)
New Revision: 12108

Added:
   code/branches/OrxoKart_HS18/src/modules/orxokart/OrxoKartFlag.cc
   code/branches/OrxoKart_HS18/src/modules/orxokart/OrxoKartFlag.h
Modified:
   code/branches/OrxoKart_HS18/data/levels/OrxoKart1.oxw
   code/branches/OrxoKart_HS18/src/modules/orxokart/CMakeLists.txt
   code/branches/OrxoKart_HS18/src/modules/orxokart/OrxoKart.cc
   code/branches/OrxoKart_HS18/src/modules/orxokart/OrxoKart.h
   code/branches/OrxoKart_HS18/src/modules/orxokart/OrxoKartPrereqs.h
   code/branches/OrxoKart_HS18/src/modules/orxokart/TimeHUD.cc
Log:
implement simple respawn

Modified: code/branches/OrxoKart_HS18/data/levels/OrxoKart1.oxw
===================================================================
--- code/branches/OrxoKart_HS18/data/levels/OrxoKart1.oxw	2018-11-15 21:23:48 UTC (rev 12107)
+++ code/branches/OrxoKart_HS18/data/levels/OrxoKart1.oxw	2018-11-21 08:32:15 UTC (rev 12108)
@@ -18,7 +18,7 @@
 
 <?lua
 --number of tiles
-N = 11
+N = 25
 --scaling factor
 S = 80
 
@@ -64,7 +64,7 @@
     
     <SpawnPoint
       team=0
-      position="<?lua print(S*0)?>,40,<?lua print(8*S)?>"
+      position="<?lua print(S*0)?>,40,<?lua print(19*S)?>"
       lookat="0,40,0"
       spawnclass=OrxoKartKart
       pawndesign=OrxoKartKart

Modified: code/branches/OrxoKart_HS18/src/modules/orxokart/CMakeLists.txt
===================================================================
--- code/branches/OrxoKart_HS18/src/modules/orxokart/CMakeLists.txt	2018-11-15 21:23:48 UTC (rev 12107)
+++ code/branches/OrxoKart_HS18/src/modules/orxokart/CMakeLists.txt	2018-11-21 08:32:15 UTC (rev 12108)
@@ -3,6 +3,7 @@
   OrxoKartKart.cc
   OrxoKartTile.cc
   OrxoKartOrigin.cc
+  OrxoKartFlag.cc
   TimeHUD.cc
 )
 

Modified: code/branches/OrxoKart_HS18/src/modules/orxokart/OrxoKart.cc
===================================================================
--- code/branches/OrxoKart_HS18/src/modules/orxokart/OrxoKart.cc	2018-11-15 21:23:48 UTC (rev 12107)
+++ code/branches/OrxoKart_HS18/src/modules/orxokart/OrxoKart.cc	2018-11-21 08:32:15 UTC (rev 12108)
@@ -32,7 +32,8 @@
 */
 
 #include "OrxoKart.h"
-
+#include "OrxoKartFlag.h"
+#include "OrxoKartKart.h"
 #include "OrxoKartOrigin.h"
 #include "OrxoKartTile.h"
 #include "core/CoreIncludes.h"
@@ -46,7 +47,7 @@
         RegisterObject(OrxoKart);
 
         this->origin_ = nullptr;
-        // this->numberOfFlags_ = 1;
+        this->numberOfFlags_ = 1;
         this->firstTick_ = true;
 
         this->setHUDTemplate("OrxoKartHUD");
@@ -56,6 +57,7 @@
     { 
         SUPER(OrxoKart, tick, dt);
 
+
         if(this->firstTick_ && this->origin_)
         {
             this->firstTick_ = false;
@@ -63,19 +65,49 @@
             int n = this->origin_->getNumCells();
             int s = this->origin_->getCellSize();
 
-            int levelcodeArray[] =  {1,1,1,1,1,1,1,1,0,0,0
-                                    ,1,0,0,0,0,0,0,1,1,1,0
-                                    ,1,0,1,1,1,1,0,0,0,1,1
-                                    ,1,1,1,0,0,1,1,0,0,0,1
-                                    ,0,0,0,0,0,0,1,0,1,1,1
-                                    ,1,1,1,1,1,1,1,0,1,0,0
-                                    ,1,0,0,0,0,0,0,0,1,0,0
-                                    ,1,0,0,0,0,0,0,0,1,0,0
-                                    ,1,1,1,1,1,0,0,0,1,1,1
-                                    ,0,0,0,0,1,0,0,0,0,0,1
-                                    ,0,0,0,0,1,1,1,2,1,1,1};
+            int map_1[] =   {1,1,1,1,1,1,1,1,0,0,0
+                            ,1,0,0,0,0,0,0,1,1,1,0
+                            ,1,0,1,1,1,1,0,0,0,1,1
+                            ,1,1,1,0,0,1,1,0,0,0,1
+                            ,0,0,0,0,0,0,1,0,1,1,1
+                            ,1,1,1,1,1,1,1,0,1,0,0
+                            ,1,0,0,0,0,0,0,0,1,0,0
+                            ,1,0,0,0,0,0,0,0,1,0,0
+                            ,1,1,1,1,1,0,0,0,1,1,1
+                            ,0,0,0,0,1,0,0,0,0,0,1
+                            ,0,0,0,0,1,1,1,2,1,1,1};
 
+            int map_2[] =  {1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,
+                            1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,
+                            1,0,1,1,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,
+                            1,0,1,0,0,0,0,0,0,0,1,0,1,0,1,1,1,1,1,1,1,1,1,0,0,
+                            1,0,1,0,1,1,1,1,1,0,1,0,1,0,1,0,0,0,0,0,0,0,1,0,0,
+                            1,0,1,0,1,0,0,0,1,0,1,0,1,0,1,0,1,1,1,1,1,0,1,0,0,
+                            1,0,1,0,1,1,1,0,1,0,1,0,1,0,1,0,1,0,0,0,1,0,1,0,0,
+                            1,0,1,0,0,0,1,0,1,0,1,0,1,0,1,0,1,0,1,1,1,0,1,0,0,
+                            1,0,1,1,1,1,1,0,1,0,1,0,1,0,1,0,1,0,1,0,0,0,1,0,0,
+                            1,0,0,0,0,0,0,0,1,0,1,0,1,0,1,0,1,0,1,1,1,1,1,0,0,
+                            1,1,1,1,1,1,1,1,1,0,1,0,1,0,1,0,1,0,0,0,0,0,0,0,0,
+                            0,0,0,0,0,0,0,0,0,0,1,0,1,0,1,0,1,1,1,1,1,1,1,1,1,
+                            0,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0,0,0,0,0,0,0,0,0,1,
+                            0,1,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,0,0,0,0,0,0,1,
+                            0,1,0,0,0,0,0,0,1,1,1,1,1,0,0,0,0,1,0,0,0,0,0,0,1,
+                            0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,1,1,1,1,1,
+                            0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,
+                            0,1,0,1,1,1,0,0,1,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,
+                            0,1,0,1,0,1,0,0,1,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,
+                            0,1,0,1,0,1,0,0,1,1,1,1,1,1,1,1,1,1,0,0,1,1,1,1,1,
+                            0,1,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,
+                            0,1,0,1,0,1,0,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,
+                            0,1,1,1,0,1,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,
+                            0,0,0,0,0,1,1,1,0,0,0,1,0,0,0,0,0,0,0,0,1,1,1,0,1,
+                            0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,2,1,1,1,0,1,1,1};
 
+
+
+            int *levelcodeArray =  map_2;
+
+
             //Generate floor according to levelcode
             for(int i=0; i<n; i++){
                 for(int j=0; j<n; j++){
@@ -84,18 +116,35 @@
                 }   
             }
 
+            //bottom flag
             
+                OrxoKartFlag* flag = new OrxoKartFlag(origin_->getContext());
+                flag->init(n, s);
+                flag_ = flag;
+            
 
+
+            
+
         }//firsttick end
-            /*
-        // Check if ship collided with one of the flags
-        for ( unsigned int i = 0; i < flags_.size(); i++ ){
-            if(flags_[i]->getCollided()){
-                flags_[i]->destroyLater();
-                flags_.erase (flags_.begin()+i);
-            }
+
+        
+            
+        // Check if ship collided with the flag
+        if(flag_->getCollided()){
+            OrxoKartKart* player = flag_->getObjectofCollision();
+            orxout() << "Orientation= " << player->getOrientation() << endl;
+            player->setPosition(Vector3(80*0, 40, 80*18));
+            player->setOrientation(Quaternion(1, 0, 0, 0));   // 0, 0, 0
+            player->setVelocity(Vector3(0,0,0));
+            player->setAcceleration(Vector3(0,0,0));
+            flag_->setCollided(false); 
+
+
+            // flag_->destroyLater();
+           // flags_.erase (flags_.begin()+i);
+            numberOfFlags_ = 0;
         }
-        numberOfFlags_ = flags_.size(); */
         
     }
 }

Modified: code/branches/OrxoKart_HS18/src/modules/orxokart/OrxoKart.h
===================================================================
--- code/branches/OrxoKart_HS18/src/modules/orxokart/OrxoKart.h	2018-11-15 21:23:48 UTC (rev 12107)
+++ code/branches/OrxoKart_HS18/src/modules/orxokart/OrxoKart.h	2018-11-21 08:32:15 UTC (rev 12108)
@@ -54,13 +54,14 @@
             void setOrigin(OrxoKartOrigin* origin)
                 { this->origin_ = origin; }
 
-            /*inline int getNumberOfFlags() const
-                { return this->numberOfFlags_; }*/
+            inline int getNumberOfFlags() const
+                { return this->numberOfFlags_; }
 
         private:
             WeakPtr<OrxoKartOrigin> origin_;
+            OrxoKartFlag* flag_;
             //std::vector<OrxoKartFlag*> flags_;
-            //int numberOfFlags_;
+            int numberOfFlags_;
             bool firstTick_;
     };
 }

Added: code/branches/OrxoKart_HS18/src/modules/orxokart/OrxoKartFlag.cc
===================================================================
--- code/branches/OrxoKart_HS18/src/modules/orxokart/OrxoKartFlag.cc	                        (rev 0)
+++ code/branches/OrxoKart_HS18/src/modules/orxokart/OrxoKartFlag.cc	2018-11-21 08:32:15 UTC (rev 12108)
@@ -0,0 +1,115 @@
+/*
+ *   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:
+ *      Manuel Meier
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file OrxoKartFlag.cc
+    @brief The Flags that are being set in the OrxoKart Minigame They support two coordinates from 0-9 each
+*/
+
+#include "OrxoKartFlag.h"
+#include "OrxoKartKart.h"
+
+#include "core/CoreIncludes.h"
+
+#include "graphics/Model.h"
+#include "objects/collisionshapes/BoxCollisionShape.h"
+#include "core/XMLPort.h"
+
+namespace orxonox
+{
+    RegisterClass(OrxoKartFlag);
+
+    OrxoKartFlag::OrxoKartFlag(Context* context) : StaticEntity(context)
+    {
+        RegisterObject(OrxoKartFlag);
+
+        this->model_ = nullptr;
+        this->cs_ = nullptr;
+        this->collided_ = false;
+        this->kartCollider = nullptr;
+
+        this->enableCollisionCallback();
+        this->setCollisionResponse(true);
+        this->setCollisionType(CollisionType::Static);
+    }
+
+    /**
+    @brief
+        Destructor.
+    */
+    OrxoKartFlag::~OrxoKartFlag()
+    {
+        if (this->isInitialized())
+        {
+            if (this->model_)
+                this->model_->destroy();
+            if (this->cs_)
+                this->cs_->destroy();
+        }
+    }
+
+    /**
+    @brief
+        Initializes the flag.
+    @param xCoordinate
+        X-Coordinate of the flage, 0-9, origin is bottom left
+    @param yCoordinate
+        Y-Coordinate of the flage, 0-9, origin is bottom left
+    @param cellSize
+        The size of the cells
+    */
+    void OrxoKartFlag::init(int n, int s)
+    {
+        /*model_ = new Model(this->getContext());
+        model_->setMeshSource("OrxoKartStreckenabschnitt.mesh");
+        model_->setScale3D(Vector3(s*n*2, 1, s*n*2));
+        model_->setPosition(Vector3(s*n*0.5f,-60.0f, s*n*0.5f));
+
+        this->attach(model_);*/
+
+        cs_ = new BoxCollisionShape(this->getContext());
+        cs_->setHalfExtents(Vector3(s*n, 1, s*n));
+        cs_->setPosition(Vector3(s*n*0.5f,-60.0f, s*n*0.5f));
+
+        this->attachCollisionShape(cs_);
+    }
+
+    /**
+    @brief
+        Checks if the OrxoKartship collided with the flag
+    */
+    bool OrxoKartFlag::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint)
+    {
+        if(otherObject->isA(Class(OrxoKartKart))) {
+            collided_ = true;
+            kartCollider = (OrxoKartKart*) otherObject;
+        }
+
+        return false;
+    }
+}

Added: code/branches/OrxoKart_HS18/src/modules/orxokart/OrxoKartFlag.h
===================================================================
--- code/branches/OrxoKart_HS18/src/modules/orxokart/OrxoKartFlag.h	                        (rev 0)
+++ code/branches/OrxoKart_HS18/src/modules/orxokart/OrxoKartFlag.h	2018-11-21 08:32:15 UTC (rev 12108)
@@ -0,0 +1,75 @@
+/*
+ *   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:
+ *      Manuel Meier
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file OrxoKartFlag.h
+    @brief See .cc File
+    @ingroup OrxoKart
+*/
+
+#ifndef _OrxoKartFlag_H__
+#define _OrxoKartFlag_H__
+
+#include "OrxoKartPrereqs.h"
+#include "objects/ObjectsPrereqs.h"
+#include "OrxoKartKart.h"
+
+#include "worldentities/StaticEntity.h"
+
+namespace orxonox
+{
+    class _OrxoKartExport OrxoKartFlag : public StaticEntity
+    {
+        public:
+            OrxoKartFlag(Context* context);
+            virtual ~OrxoKartFlag();
+
+            void init(int n, int s);
+
+            virtual bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) override;
+
+            inline bool getCollided() const
+                { return this->collided_; }
+
+            inline OrxoKartKart* getObjectofCollision() const
+                { return this->kartCollider; }   
+
+            inline void setCollided(bool setValue)
+                { this->collided_ = setValue; }
+
+
+        private:
+            Model* model_;
+            BoxCollisionShape* cs_;
+            bool collided_;
+            OrxoKartKart* kartCollider;
+
+    };
+}
+
+#endif /* _OrxoKartFlag_H__ */

Modified: code/branches/OrxoKart_HS18/src/modules/orxokart/OrxoKartPrereqs.h
===================================================================
--- code/branches/OrxoKart_HS18/src/modules/orxokart/OrxoKartPrereqs.h	2018-11-15 21:23:48 UTC (rev 12107)
+++ code/branches/OrxoKart_HS18/src/modules/orxokart/OrxoKartPrereqs.h	2018-11-21 08:32:15 UTC (rev 12108)
@@ -68,6 +68,7 @@
 namespace orxonox
 {
     class OrxoKart;
+    class OrxoKartFlag;
     class OrxoKartOrigin;
     class OrxoKartKart;
     class OrxoKartTile;

Modified: code/branches/OrxoKart_HS18/src/modules/orxokart/TimeHUD.cc
===================================================================
--- code/branches/OrxoKart_HS18/src/modules/orxokart/TimeHUD.cc	2018-11-15 21:23:48 UTC (rev 12107)
+++ code/branches/OrxoKart_HS18/src/modules/orxokart/TimeHUD.cc	2018-11-21 08:32:15 UTC (rev 12108)
@@ -81,8 +81,8 @@
         if (this->orxokartGame_)
         {
             this->setCaption(getTimeString(this->time_));
-            //if (this->orxokartGame_->getNumberOfFlags() == 0)
-              //  setRunning(false);
+            if (this->orxokartGame_->getNumberOfFlags() == 0)
+                setRunning(false);
         }
         
     }



More information about the Orxonox-commit mailing list