[Orxonox-commit 7705] r12298 - code/branches/OrxoBlox_FS19/src/modules/OrxoBlox

pomselj at orxonox.net pomselj at orxonox.net
Thu Apr 11 15:45:52 CEST 2019


Author: pomselj
Date: 2019-04-11 15:45:52 +0200 (Thu, 11 Apr 2019)
New Revision: 12298

Added:
   code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxShip.cc
   code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxShip.h
Modified:
   code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/CMakeLists.txt
Log:
We got a Ship!

Modified: code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/CMakeLists.txt
===================================================================
--- code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/CMakeLists.txt	2019-04-11 13:36:59 UTC (rev 12297)
+++ code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/CMakeLists.txt	2019-04-11 13:45:52 UTC (rev 12298)
@@ -8,6 +8,7 @@
   OrxoBloxCenterpoint.cc
   OrxoBloxStones.cc
   OrxoBloxCanon.cc
+  OrxoBloxShip.cc
 END_BUILD_UNIT
 )
 

Added: code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxShip.cc
===================================================================
--- code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxShip.cc	                        (rev 0)
+++ code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxShip.cc	2019-04-11 13:45:52 UTC (rev 12298)
@@ -0,0 +1,98 @@
+/*
+ *   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:
+ *      Viviane Yang
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/*  TODO: 
+
+    @file OrxoBloxShip.cc
+    @brief Implementation of the OrxoBloxShip class.
+*/
+
+#include "OrxoBloxShip.h"
+#include "OrxoBloxShip.h"
+#include "core/CoreIncludes.h"
+
+namespace orxonox
+{
+    RegisterClass(OrxoBloxShip);
+
+    OrxoBloxShip::OrxoBloxShip(Context* context) : SpaceShip(context)
+    {
+        RegisterObject(OrxoBloxShip);
+
+        this->bImmune = false;
+        this->width = 120;
+        this->height = 100;
+
+        //timer.setTimer(3.5f, true, createExecutor(createFunctor(&OrxoBloxShip::showorientation, this)));
+    }
+
+    //Use this function to display your position on the field -> to determine field width and height
+    void OrxoBloxShip::showposition()
+    {
+        Vector3 pos = this->getPosition();
+        orxout() << "x = "<< pos.x << " y = " << pos.y << " z = "<< pos.z << endl; 
+    }
+
+    //Same thing for orientation
+    void OrxoBloxShip::showorientation()
+    {
+        Quaternion ort = this->getOrientation();
+        orxout() << "w = " << ort.w << " x = " << ort.x << " y = " << ort.y << "z = " << ort.z << endl;
+    }
+
+    void OrxoBloxShip::tick(float dt)
+    {
+        SUPER(OrxoBloxShip, tick, dt);
+        Vector3 pos = this->getPosition();
+
+        //ensure that the ship stays in playing field
+        if(pos.x > width/2)   pos.x = -width/2;
+        if(pos.x < -width/2)  pos.x = width/2;
+
+        //2D movement, position should always = 0 on y-axis
+        if(pos.y!=0) pos.y = 0;
+        this->setPosition(pos);
+        if(pos.z!=50) pos.z = 50;
+    }
+
+    OrxoBlox* OrxoBloxShip::getGame()
+    {
+        if (game == nullptr)
+        {
+            for (OrxoBlox* race : ObjectList<OrxoBlox>())
+            {
+                game = race;
+            }
+        }
+        return game;
+    }
+    void OrxoBloxShip::death()
+    {
+        SpaceShip::death();
+    }
+}

Added: code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxShip.h
===================================================================
--- code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxShip.h	                        (rev 0)
+++ code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxShip.h	2019-04-11 13:45:52 UTC (rev 12298)
@@ -0,0 +1,82 @@
+/*
+ *   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 Asteroids2DShip.h
+    @brief Declaration of the Asteroids2DShip class.
+*/
+
+#ifndef _OrxoBloxShip_H__
+#define _OrxoBloxShip_H__
+
+
+#include "asteroids2D/Asteroids2DPrereqs.h"
+
+#include "worldentities/pawns/SpaceShip.h"
+#include "tools/Timer.h"
+
+namespace orxonox
+{
+    class _OrxoBloxExport OrxoBloxShip : public SpaceShip
+    {
+        public:
+            OrxoBloxShip(Context* context);
+
+            virtual void tick(float dt) override;
+
+            //no rotation in x and z direction!
+            virtual void rotatePitch(const Vector2& value) override{}; // Rotate in pitch direction.
+            virtual void rotateRoll(const Vector2& value) override{}; // Rotate in roll direction.
+            
+            /*Functions that can be helpful while debugging.
+                - Set a timer so that the function is called for instance every 3s to display the coordinates
+                - Open console with "~`"-key in when you start the Asteroids2D - Minigame.
+            */
+            void showposition();
+            void showorientation();
+
+
+            void toggleImmune()
+            {
+                bImmune = !bImmune;
+            }
+
+        protected:
+            virtual void death() override;
+        private:
+            OrxoBlox* getGame();
+
+            float width, height;
+            WeakPtr<OrxoBlox> game;
+            bool bImmune;
+            Timer timer;
+            Timer isimmune;
+    };
+}
+
+#endif /* _Asteroids2DShip_H__ */



More information about the Orxonox-commit mailing list