[Orxonox-commit 7267] r11882 - code/branches/OrxyRoad_FS18/src/modules/orxyroad

jacobsr at orxonox.net jacobsr at orxonox.net
Thu Apr 19 14:16:42 CEST 2018


Author: jacobsr
Date: 2018-04-19 14:16:41 +0200 (Thu, 19 Apr 2018)
New Revision: 11882

Added:
   code/branches/OrxyRoad_FS18/src/modules/orxyroad/OrxyRoad.h
   code/branches/OrxyRoad_FS18/src/modules/orxyroad/OrxyRoadShip.cc
   code/branches/OrxyRoad_FS18/src/modules/orxyroad/OrxyRoadShip.h
Log:
renamed files

Added: code/branches/OrxyRoad_FS18/src/modules/orxyroad/OrxyRoad.h
===================================================================
--- code/branches/OrxyRoad_FS18/src/modules/orxyroad/OrxyRoad.h	                        (rev 0)
+++ code/branches/OrxyRoad_FS18/src/modules/orxyroad/OrxyRoad.h	2018-04-19 12:16:41 UTC (rev 11882)
@@ -0,0 +1,145 @@
+/*
+ *   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 OrxyRoad.h
+    @brief Gametype.
+    @ingroup OrxyRoad
+*/
+
+#ifndef _OrxyRoad_H__
+#define _OrxyRoad_H__
+
+#include "OrxyRoadPrereqs.h"
+
+#include "OrxyRoadCenterPoint.h" // Necessary for WeakPointer??
+//#include "OrxyRoadShip.h"        DO NOT include in Header. Will cause forward declaration issues
+
+//#include "OrxyRoadHUDinfo.h"
+
+
+#include "core/EventIncludes.h"
+#include "core/command/Executor.h"
+#include "core/config/ConfigValueIncludes.h"
+
+#include "gamestates/GSLevel.h"
+#include "chat/ChatManager.h"
+#include <vector>
+
+// ! HACK
+#include "infos/PlayerInfo.h"
+
+#include "core/command/ConsoleCommand.h"
+
+#include "gametypes/Deathmatch.h"
+#include "tools/Timer.h"
+
+namespace orxonox
+{
+
+    class _OrxyRoadExport OrxyRoad : public Deathmatch
+    {
+       public:
+            OrxyRoad(Context* context);
+
+            virtual void start() override;
+            virtual void end() override;
+
+            virtual void tick(float dt) override;
+
+            virtual void playerPreSpawn(PlayerInfo* player) override;
+
+            void levelUp();
+
+            int getLives(){return this->lives;}
+            int getLevel(){return this->level;}
+            int getPoints(){return this->point;}
+            int getMultiplier(){return this->multiplier;}
+
+            void setCenterpoint(OrxyRoadCenterPoint* center)
+                       { this->center_ = center; }
+            virtual void addBots(unsigned int amount) override{} //<! overwrite function in order to bypass the addbots command
+
+            // checks if multiplier should be reset.
+            void comboControll();
+            void costLife();
+
+            bool bEndGame;
+            bool bShowLevel;
+            int lives;
+            int multiplier;
+            float counter;
+            int pattern;
+            float currentPosition;
+            float lastPosition;
+
+       private:
+            Timer endGameTimer;
+
+            OrxyRoadShip* getPlayer();
+            WeakPtr<PlayerInfo> playerInfo_;
+            std::vector<OrxyRoadCube*> cubeList;
+            void toggleShowLevel(){bShowLevel = !bShowLevel;}
+            void addPoints(int numPoints);
+
+            WeakPtr<OrxyRoadCenterPoint> center_;
+            int level;
+            int point;
+            bool b_combo;
+
+            Timer enemySpawnTimer;
+            Timer comboTimer;
+            Timer showLevelTimer;
+
+
+         /*
+
+            //void spawnEnemy();
+
+
+
+
+
+
+
+
+
+
+
+
+        private:
+
+
+
+
+            //Context* context;
+            */
+    };
+}
+
+#endif /* _OrxyRoad_H__ */

Added: code/branches/OrxyRoad_FS18/src/modules/orxyroad/OrxyRoadShip.cc
===================================================================
--- code/branches/OrxyRoad_FS18/src/modules/orxyroad/OrxyRoadShip.cc	                        (rev 0)
+++ code/branches/OrxyRoad_FS18/src/modules/orxyroad/OrxyRoadShip.cc	2018-04-19 12:16:41 UTC (rev 11882)
@@ -0,0 +1,169 @@
+/*
+ *   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 OrxyRoadShip.cc
+    @brief Implementation of the OrxyRoadShip class.
+*/
+
+#include "OrxyRoadShip.h"
+#include "core/CoreIncludes.h"
+
+namespace orxonox
+{
+    RegisterClass(OrxyRoadShip);
+
+    OrxyRoadShip::OrxyRoadShip(Context* context) : SpaceShip(context)
+    {
+        RegisterObject(OrxyRoadShip);
+
+        speed = 830;
+        isFireing = false;
+        damping = 10;
+
+        // not sure if has to be zero?
+        lastTimeFront = 0;
+        lastTimeLeft = 0;
+        lastTime = 0;
+    }
+
+    void OrxyRoadShip::tick(float dt)
+    {
+        Vector3 pos = getPosition();
+
+        //Movement calculation
+        lastTimeFront += dt * damping;
+        lastTimeLeft += dt * damping;
+        lastTime += dt;
+
+        velocity.x = interpolate(clamp(lastTimeLeft, 0.0f, 1.0f), desiredVelocity.x, 0.0f);
+        velocity.y = interpolate(clamp(lastTimeFront, 0.0f, 1.0f), desiredVelocity.y, 0.0f);
+
+        //Execute movement
+        if (this->hasLocalController())
+        {
+            float dist_y = velocity.y * dt;
+            //float dist_x = velocity.x * dt;
+            if(dist_y + posforeward > -42*3 && dist_y + posforeward < 42*6)
+                posforeward += dist_y;
+            else
+            {
+                velocity.y = 0;
+                // restart if game ended
+/*
+                if (getGame())
+                    if (getGame()->bEndGame)
+                    {
+                        getGame()->start();
+                        return;
+                    }*/
+            }
+
+            pos += Vector3(1000 + velocity.y, 0, velocity.x) * dt;
+        }
+
+
+        // Camera
+        Camera* camera = this->getCamera();
+        if (camera != nullptr)
+        {
+            // camera->setPosition(Vector3(-pos.z, -posforeward, 0));
+            camera->setOrientation(Vector3::UNIT_Z, Degree(0));
+        }
+
+
+
+        // bring back on track!
+        if(pos.y != 0)
+        {
+            pos.y = 0;
+        }
+
+        setPosition(pos);
+        setOrientation(Vector3::UNIT_Y, Degree(270));
+
+        // Level up!
+        if (pos.x > 42000)
+        {
+            updateLevel();
+            setPosition(Vector3(0, 0, pos.z)); // pos - Vector3(30000, 0, 0)
+        }
+
+        SUPER(OrxyRoadShip, tick, dt);
+    }
+
+    void OrxyRoadShip::updateLevel()
+    {
+        lastTime = 0;
+        if (getGame())
+            getGame()->levelUp();
+    }
+
+    void OrxyRoadShip::moveFrontBack(const Vector2& value)
+    {
+        //lastTimeFront = 0;
+        //desiredVelocity.y = value.y * speed * 42;
+
+    }
+
+    void OrxyRoadShip::moveRightLeft(const Vector2& value)
+    {
+        lastTimeLeft = 0;
+        desiredVelocity.x = value.x * speed;
+    }
+    void OrxyRoadShip::boost(bool bBoost)
+    {
+        //getGame()->bEndGame = bBoost;
+    }
+
+    inline bool OrxyRoadShip::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint)
+    {
+
+        removeHealth(100);
+        this->death();
+        return false;
+    }
+
+    OrxyRoad* OrxyRoadShip::getGame()
+    {
+        if (game == nullptr)
+        {
+            for (OrxyRoad* race : ObjectList<OrxyRoad>())
+            {
+                game = race;
+            }
+        }
+        return game;
+    }
+
+    void OrxyRoadShip::death()
+    {
+        getGame()->costLife();
+        SpaceShip::death();
+    }
+}

Added: code/branches/OrxyRoad_FS18/src/modules/orxyroad/OrxyRoadShip.h
===================================================================
--- code/branches/OrxyRoad_FS18/src/modules/orxyroad/OrxyRoadShip.h	                        (rev 0)
+++ code/branches/OrxyRoad_FS18/src/modules/orxyroad/OrxyRoadShip.h	2018-04-19 12:16:41 UTC (rev 11882)
@@ -0,0 +1,95 @@
+/*
+ *   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 OrxyRoadShip.h
+    @brief Declaration of the OrxyRoadShip class.
+*/
+
+#ifndef _OrxyRoadShip_H__
+#define _OrxyRoadShip_H__
+
+
+#include "OrxyRoadPrereqs.h"
+
+#include "core/XMLPort.h"
+#include "worldentities/pawns/SpaceShip.h"
+#include "graphics/Camera.h"
+
+#include "OrxyRoad.h" // Is necessary for getGame function
+//#include "OrxyRoadCenterPoint.h"
+
+namespace orxonox
+{
+    class _OrxyRoadExport OrxyRoadShip : public SpaceShip
+    {
+        public:
+            OrxyRoadShip(Context* context);
+
+            virtual void tick(float dt) override;
+
+            // overwrite for 2d movement
+            virtual void moveFrontBack(const Vector2& value) override;
+            virtual void moveRightLeft(const Vector2& value) override;
+
+            // Starts or stops fireing
+            virtual void boost(bool bBoost) override;
+
+            //no rotation!
+            virtual void rotateYaw(const Vector2& value) override{};
+            virtual void rotatePitch(const Vector2& value) override{};
+
+            //return to main menu if game has ended.
+            virtual void rotateRoll(const Vector2& value) override{if (getGame()) if (getGame()->bEndGame) getGame()->end();};
+
+            virtual void updateLevel();
+
+            virtual inline bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) override;
+
+            float speed, damping, posforeward;
+            bool isFireing;
+
+        protected:
+            virtual void death() override;
+
+        private:
+            OrxyRoad* getGame();
+            WeakPtr<OrxyRoad> game;
+            WeakPtr<WorldEntity> lastEntity;
+            Camera* camera;
+            float lastTimeFront, lastTimeLeft, lastTime;
+            struct Velocity
+            {
+                float x;
+                float y;
+            } velocity, desiredVelocity;
+
+    };
+}
+
+#endif /* _OrxyRoadShip_H__ */



More information about the Orxonox-commit mailing list