[Orxonox-commit 7372] r11988 - code/branches/SuperOrxoBros_FS18/src/modules/superorxobros

micwagne at orxonox.net micwagne at orxonox.net
Thu May 24 15:05:14 CEST 2018


Author: micwagne
Date: 2018-05-24 15:05:14 +0200 (Thu, 24 May 2018)
New Revision: 11988

Added:
   code/branches/SuperOrxoBros_FS18/src/modules/superorxobros/SOBTube.cc
   code/branches/SuperOrxoBros_FS18/src/modules/superorxobros/SOBTube.h
Log:
Tube files

Added: code/branches/SuperOrxoBros_FS18/src/modules/superorxobros/SOBTube.cc
===================================================================
--- code/branches/SuperOrxoBros_FS18/src/modules/superorxobros/SOBTube.cc	                        (rev 0)
+++ code/branches/SuperOrxoBros_FS18/src/modules/superorxobros/SOBTube.cc	2018-05-24 13:05:14 UTC (rev 11988)
@@ -0,0 +1,121 @@
+/*
+ *   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:
+ *      Julien
+ *   Co-authors:
+ *      
+ *
+ */
+
+/**
+    @file SOBTube.cc
+     @brief Declaration of the SOBTube class. 
+            This class is used for the tubes in the game. It adds the function that the figure can slip through Tube.
+*/
+
+#include "SOBTube.h"
+
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "SOBFigure.h"
+#include "util/Output.h"
+#include "objects/collisionshapes/BoxCollisionShape.h"
+
+
+namespace orxonox
+{
+    RegisterClass(SOBTube);
+
+    SOBTube::SOBTube(Context* context) : MovableEntity(context)
+    {
+        RegisterObject(SOBTube);
+        setAngularFactor(0.0);
+        this->enableCollisionCallback();
+        k=0;u=0;                        //initializing variables for tick function
+        a=CollisionType::None;          //initializing Collisiontypes for tick function
+        b=CollisionType::Dynamic;       //initializing Collisiontypes for tick function
+        movedown=false;                 //initializing variable movedown (movedown is used for allowing figure to get through tube)
+        hasCollided_=false;             //initializing variable
+        
+        left = new BoxCollisionShape(context);  //BoxCollisionshape initialized for tube (here in Programm not in SOB.oxw as others)
+        left->setHalfExtents(Vector3(10, 10, 30));// set CollisionShape
+        attachCollisionShape(left);             //attach CollisionShape
+        
+         
+       
+    }
+    
+
+    
+
+    void SOBTube::XMLPort(Element& xmlelement, XMLPort::Mode mode) //set parameters for SOB.oxw file
+    {
+        SUPER(SOBTube, XMLPort, xmlelement, mode);
+        XMLPortParam(SOBTube,"cool",getcool,setcool,xmlelement,mode); 
+        
+
+
+    }
+
+    
+    bool SOBTube::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) {
+          
+          
+         
+
+        return true;
+    }
+
+     void SOBTube::tick(float dt)
+    {
+        SUPER(SOBTube, tick, dt);
+        Vector3 velocity = getVelocity(); //velocity of tube
+        Vector3 position = getPosition(); //position of tube
+        position.y=0;                     //position in y axes must be 0 
+
+        setPosition(position);     //set new position of tube
+        velocity.z = 0*dt;         //velocity in all directions must be 0 or else tube is moving 
+        velocity.y = 0*dt;
+        velocity.x = 0*dt;
+        setVelocity(velocity);     //set new velocity
+       
+        
+
+        
+           
+        if(movedown && k==0){                       //if movedown is allowed change Collisiontype from dynamic to None
+            CollisionType a = CollisionType::None;
+            this->setCollisionType(a);                   
+
+         
+            k++;
+        }
+       if(k!=0){u++;}
+
+        if(u>=50){
+            this->setCollisionType(b);k=0;u=0;movedown=false; //set Collisiontype from None to dynamic
+        }
+    }
+    
+
+    
+}

Added: code/branches/SuperOrxoBros_FS18/src/modules/superorxobros/SOBTube.h
===================================================================
--- code/branches/SuperOrxoBros_FS18/src/modules/superorxobros/SOBTube.h	                        (rev 0)
+++ code/branches/SuperOrxoBros_FS18/src/modules/superorxobros/SOBTube.h	2018-05-24 13:05:14 UTC (rev 11988)
@@ -0,0 +1,77 @@
+/*
+ *   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:
+ *      Julien Kindle
+ *   Co-authors:
+ *      
+ *
+ */
+
+/**
+    @file SOBTube.h
+    @brief Declaration of the SOBTube class. 
+            This class is used for the tubes in the game. It adds the function that the figure can slip through Tubes.
+*/
+
+#ifndef _SOBTube_H__
+#define _SOBTube_H__
+
+
+#include "superorxobros/SOBPrereqs.h"
+#include "worldentities/MovableEntity.h"         //includes MovableEntity from WorldEntity important because Superclass is MovableEntity 
+#include "objects/collisionshapes/BoxCollisionShape.h"
+
+namespace orxonox
+{
+    class _SOBExport SOBTube : public MovableEntity
+    {
+        public:
+            SOBTube(Context* context);
+           
+
+            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
+            virtual  bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) override;
+            virtual void tick(float dt) override;       //tick function override for removing collisionshape and adding them
+
+            void setcool(const bool cool)  //here you could add additional information about tube
+                { this->cool_ = cool; }
+            bool getcool() const
+                { return cool_; }
+           
+           
+            BoxCollisionShape* left;        //Collision shape for removing collisionshape of the tube
+            
+            CollisionType a;    //different Type of collision (none, dynamic for tubes)
+            CollisionType b;
+            float u;            //helping variables
+            int k;
+            int Height;
+            int Right;
+            int Left;
+            bool movedown;      //says if it is allowed to move through tube
+            bool hasCollided_;  //says if figure has Collided with tube ones
+        protected:
+            bool cool_;
+    };
+}
+
+#endif /* _SOBTube_H__ */



More information about the Orxonox-commit mailing list