[Orxonox-commit 6885] r11506 - in code/branches/Asteroid_HS17/src/modules: . asteroids

vyang at orxonox.net vyang at orxonox.net
Mon Oct 23 16:06:09 CEST 2017


Author: vyang
Date: 2017-10-23 16:06:09 +0200 (Mon, 23 Oct 2017)
New Revision: 11506

Added:
   code/branches/Asteroid_HS17/src/modules/asteroids/
   code/branches/Asteroid_HS17/src/modules/asteroids/Asteroids.cc
   code/branches/Asteroid_HS17/src/modules/asteroids/Asteroids.h
   code/branches/Asteroid_HS17/src/modules/asteroids/AsteroidsShip.cc
   code/branches/Asteroid_HS17/src/modules/asteroids/AsteroidsShip.h
   code/branches/Asteroid_HS17/src/modules/asteroids/AsteroidsStone.cc
   code/branches/Asteroid_HS17/src/modules/asteroids/AsteroidsStone.h
   code/branches/Asteroid_HS17/src/modules/asteroids/AsteroidsWeapon.cc
   code/branches/Asteroid_HS17/src/modules/asteroids/AsteroidsWeapon.h
   code/branches/Asteroid_HS17/src/modules/asteroids/CMakeLists.txt
Log:
 Asteroids, Ship, Stones, Weapon files created

Added: code/branches/Asteroid_HS17/src/modules/asteroids/Asteroids.cc
===================================================================
--- code/branches/Asteroid_HS17/src/modules/asteroids/Asteroids.cc	                        (rev 0)
+++ code/branches/Asteroid_HS17/src/modules/asteroids/Asteroids.cc	2017-10-23 14:06:09 UTC (rev 11506)
@@ -0,0 +1,23 @@
+#include "Asteroids.h"
+
+namespace orxonox
+{
+	RegisterUnloadableClass(Asteroids);
+
+	Asteroids::Asteroids(Context* context) : Deathmatch(context)
+	{
+		level = 1;
+		this->numberOfBots = 0;
+	}
+
+	void Asteroids::spawnAsteroid();
+
+	void Asteroids::setCenterpoint(InvaderCenterPoint* center)
+    {
+        this->center_ = center;
+    }
+
+    void Asteroids::start();
+    void Asteroids::end();
+    
+}
\ No newline at end of file

Added: code/branches/Asteroid_HS17/src/modules/asteroids/Asteroids.h
===================================================================
--- code/branches/Asteroid_HS17/src/modules/asteroids/Asteroids.h	                        (rev 0)
+++ code/branches/Asteroid_HS17/src/modules/asteroids/Asteroids.h	2017-10-23 14:06:09 UTC (rev 11506)
@@ -0,0 +1,89 @@
+/*
+ *   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 Invader.h
+    @brief Gametype.
+    @ingroup Invader
+*/
+
+#ifndef _Invader_H__
+#define _Invader_H__
+
+#include "invader/InvaderPrereqs.h"
+
+#include "gametypes/Deathmatch.h"
+#include "tools/Timer.h"
+
+namespace orxonox
+{
+
+    class _InvaderExport Invader : public Deathmatch
+    {
+        public:
+            Invader(Context* context);
+
+            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 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;
+    };
+}
+
+#endif /* _Invader_H__ */

Added: code/branches/Asteroid_HS17/src/modules/asteroids/AsteroidsShip.cc
===================================================================
--- code/branches/Asteroid_HS17/src/modules/asteroids/AsteroidsShip.cc	                        (rev 0)
+++ code/branches/Asteroid_HS17/src/modules/asteroids/AsteroidsShip.cc	2017-10-23 14:06:09 UTC (rev 11506)
@@ -0,0 +1,57 @@
+#include "AsteroidsShip.h"
+
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "Invader.h"
+#include "InvaderEnemy.h"
+#include "graphics/Camera.h"
+#include "weapons/projectiles/Projectile.h"
+
+namespace orxonox
+{
+    //Constructor
+    RegisterClass(AsteroidsShip);
+
+    AsteroidsShip::AsteroidsShip(Context* context) : SpaceShip(context)
+    {
+        RegisterObject(AsteroidsShip);
+
+        float x = getPosition().x;
+        float y = getPosition().y;
+        float velocityx = 0.0f;
+        float velocityy = 0.0f;
+        this->bBoost_ = false;
+    }
+    //Destructor
+    AsteroidsShip::~AsteroidsShip()
+    {
+        if (this->isInitialized())
+            this->cleanup();
+    }
+
+
+
+    //update coordinates and velocity
+    void AsteroidsShip::tick(float dt)
+    {
+        //Movement computation
+        Vector3 speed = Vector3 (100, 100, 0);
+        Vector3 position = this->getPosition();
+        position += (speed * dt);
+        this->setPosition(position);
+        //roll? muss sich das Raumschiff drehen?
+
+        //Schiessen wenn geschossen wurde
+        // shoot!
+        if (isFireing)
+            ControllableEntity::fire(0);
+        
+        //Leben verloren 
+    }
+    
+    void 
+
+
+
+
+}
\ No newline at end of file

Added: code/branches/Asteroid_HS17/src/modules/asteroids/AsteroidsShip.h
===================================================================
--- code/branches/Asteroid_HS17/src/modules/asteroids/AsteroidsShip.h	                        (rev 0)
+++ code/branches/Asteroid_HS17/src/modules/asteroids/AsteroidsShip.h	2017-10-23 14:06:09 UTC (rev 11506)
@@ -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 DodgeRace.h
+    @brief Gametype.
+    @ingroup DodgeRace
+*/
+
+#ifndef _DodgeRace_H__
+#define _DodgeRace_H__
+
+#include "dodgerace/DodgeRacePrereqs.h"
+
+#include "DodgeRaceCenterPoint.h" // Necessary for WeakPointer??
+//#include "DodgeRaceShip.h"        DO NOT include in Header. Will cause forward declaration issues
+
+//#include "DodgeRaceHUDinfo.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 _DodgeRaceExport DodgeRace : public Deathmatch
+    {
+       public:
+            DodgeRace(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(DodgeRaceCenterPoint* 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;
+
+            DodgeRaceShip* getPlayer();
+            WeakPtr<DodgeRaceShip> player;
+            std::vector<DodgeRaceCube*> cubeList;
+            void toggleShowLevel(){bShowLevel = !bShowLevel;}
+            void addPoints(int numPoints);
+
+            WeakPtr<DodgeRaceCenterPoint> center_;
+            int level;
+            int point;
+            bool b_combo;
+
+            Timer enemySpawnTimer;
+            Timer comboTimer;
+            Timer showLevelTimer;
+
+
+         /*
+
+            //void spawnEnemy();
+
+
+
+
+
+
+
+
+
+
+
+
+        private:
+
+
+
+
+            //Context* context;
+            */
+    };
+}
+
+#endif /* _DodgeRace_H__ */

Added: code/branches/Asteroid_HS17/src/modules/asteroids/AsteroidsStone.cc
===================================================================
--- code/branches/Asteroid_HS17/src/modules/asteroids/AsteroidsStone.cc	                        (rev 0)
+++ code/branches/Asteroid_HS17/src/modules/asteroids/AsteroidsStone.cc	2017-10-23 14:06:09 UTC (rev 11506)
@@ -0,0 +1,89 @@
+/*
+ *   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 InvaderEnemy.h
+    @brief Declaration of the InvaderEnemy class.
+*/
+
+#include "InvaderEnemy.h"
+
+#include "core/CoreIncludes.h"
+#include "Invader.h"
+#include "InvaderShip.h"
+
+namespace orxonox
+{
+    RegisterClass(InvaderEnemy);
+
+    InvaderEnemy::InvaderEnemy(Context* context) : Pawn(context)
+    {
+        RegisterObject(InvaderEnemy);
+        enableCollisionCallback();
+        lifetime = 0;
+    }
+
+    void InvaderEnemy::tick(float dt)
+    {
+        lifetime += dt;
+        // die after 5 seconds.
+        if (lifetime > 5000)
+            removeHealth(2000);
+
+        if (player != nullptr)
+        {
+            float newZ = 2/(pow(std::abs(getPosition().x - player->getPosition().x) * 0.01f, 2) + 1) * (player->getPosition().z - getPosition().z);
+            setVelocity(Vector3(1000.f - level * 100 , 0, newZ));
+        }
+        SUPER(InvaderEnemy, tick, dt);
+    }
+
+    inline bool InvaderEnemy::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint)
+    {
+        if(orxonox_cast<InvaderShip*>(otherObject))
+            removeHealth(2000);
+        return false;
+    }
+
+    Invader* InvaderEnemy::getGame()
+    {
+        if (game == nullptr)
+        {
+            for (Invader* invader : ObjectList<Invader>())
+                game = invader;
+        }
+        return game;
+    }
+
+    void InvaderEnemy::damage(float damage, float healthdamage, float shielddamage, Pawn* originator, const btCollisionShape* cs)
+    {
+        Pawn::damage(damage, healthdamage, shielddamage, originator, cs);
+        if (getGame() && orxonox_cast<InvaderShip*>(originator) != nullptr && getHealth() <= 0)
+            getGame()->addPoints(42);
+    }
+}

Added: code/branches/Asteroid_HS17/src/modules/asteroids/AsteroidsStone.h
===================================================================
--- code/branches/Asteroid_HS17/src/modules/asteroids/AsteroidsStone.h	                        (rev 0)
+++ code/branches/Asteroid_HS17/src/modules/asteroids/AsteroidsStone.h	2017-10-23 14:06:09 UTC (rev 11506)
@@ -0,0 +1,72 @@
+/*
+ *   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 InvaderEnemy.h
+    @brief Declaration of the InvaderEnemy class.
+*/
+
+#ifndef _InvaderEnemy_H__
+#define _InvaderEnemy_H__
+
+#include "invader/InvaderPrereqs.h"
+
+#include "worldentities/pawns/Pawn.h"
+
+namespace orxonox
+{
+    class _InvaderExport InvaderEnemy : public Pawn
+    {
+        public:
+            InvaderEnemy(Context* context);
+
+            virtual void tick(float dt) override;
+            virtual bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) override;
+            virtual void damage(float damage, float healthdamage, float shielddamage, Pawn* originator, const btCollisionShape* cs) override;
+            virtual void setInvaderPlayer(InvaderShip* player){this->player = player;}
+
+            int level;
+        protected:
+            Invader* getGame();
+            WeakPtr<Invader> game;
+            WeakPtr<InvaderShip> player;
+            Camera* camera;
+            bool isFireing;
+            float speed, damping;
+            float lastTimeFront, lastTimeLeft;
+            float lifetime;
+            struct Velocity
+            {
+                float x;
+                float y;
+            } velocity, desiredVelocity;
+
+    };
+}
+
+#endif /* _InvaderEnemy_H__ */

Added: code/branches/Asteroid_HS17/src/modules/asteroids/AsteroidsWeapon.cc
===================================================================
--- code/branches/Asteroid_HS17/src/modules/asteroids/AsteroidsWeapon.cc	                        (rev 0)
+++ code/branches/Asteroid_HS17/src/modules/asteroids/AsteroidsWeapon.cc	2017-10-23 14:06:09 UTC (rev 11506)
@@ -0,0 +1,91 @@
+/*
+ *   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 InvaderWeapon.h
+    @brief Implementation of the InvaderWeapon class.
+*/
+
+#include "InvaderWeapon.h"
+
+#include "core/CoreIncludes.h"
+// #include "core/XMLPort.h"
+// #include "core/command/Executor.h"
+
+#include "graphics/Model.h"
+#include "weaponsystem/Weapon.h"
+#include "weaponsystem/WeaponPack.h"
+#include "weaponsystem/WeaponSystem.h"
+#include "worldentities/WorldEntity.h"
+#include "worldentities/pawns/Pawn.h"
+
+#include "weapons/projectiles/Projectile.h"
+#include "weapons/MuzzleFlash.h"
+
+namespace orxonox
+{
+    RegisterClass(AsteroidsWeapon);
+
+    AsteroidsWeapon::AsteroidsWeapon(Context* context) : HsW01(context)
+    {
+        RegisterObject(AsteroidsWeapon);
+    }
+
+    AsteroidsWeapon::~AsteroidsWeapon()
+    {
+
+    }
+
+    void AsteroidsWeapon::shot()
+    {
+        assert( this->getWeapon() && this->getWeapon()->getWeaponPack() && this->getWeapon()->getWeaponPack()->getWeaponSystem() && this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn() );
+
+        // Create the projectile.projectile
+        projectile = new Projectile(this->getContext());
+        Model* model = new Model(projectile->getContext());
+        model->setMeshSource(mesh_);
+        model->setCastShadows(false);
+        projectile->attach(model);
+        model->setScale(5);
+
+        this->computeMuzzleParameters(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getAimPosition());
+        // only shoot in foreward direction
+        projectile->setOrientation(Quaternion(sqrt(0.5f),0,sqrt(0.5f),0));
+        projectile->setPosition(this->getMuzzlePosition());
+        // only shoot in foreward direction
+        projectile->setVelocity(Vector3(1, 0, 0) * 2000);
+
+        projectile->setShooter(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn());
+        projectile->setDamage(this->getDamage());
+        projectile->setShieldDamage(this->getShieldDamage());
+        projectile->setHealthDamage(this->getHealthDamage());
+
+        // Display the muzzle flash.
+        this->InvaderWeapon::muzzleflash();
+    }
+}

Added: code/branches/Asteroid_HS17/src/modules/asteroids/AsteroidsWeapon.h
===================================================================
--- code/branches/Asteroid_HS17/src/modules/asteroids/AsteroidsWeapon.h	                        (rev 0)
+++ code/branches/Asteroid_HS17/src/modules/asteroids/AsteroidsWeapon.h	2017-10-23 14:06:09 UTC (rev 11506)
@@ -0,0 +1,55 @@
+/*
+ *   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 InvaderWeapon.h
+    @brief Definition of the InvaderWeapon class.
+*/
+
+#ifndef _InvaderWeapon_H__
+#define _InvaderWeapon_H__
+
+#include "invader/InvaderPrereqs.h"
+
+#include "weapons/WeaponsPrereqs.h"
+#include "weapons/weaponmodes/HsW01.h"
+
+namespace orxonox
+{
+    class _InvaderExport InvaderWeapon : public HsW01
+    {
+        public:
+            InvaderWeapon(Context* context);
+            virtual ~InvaderWeapon();
+        protected:
+            virtual void shot() override;
+            WeakPtr<Projectile> projectile;
+    };
+}
+
+#endif /* _InvaderWeapon_H__ */

Added: code/branches/Asteroid_HS17/src/modules/asteroids/CMakeLists.txt
===================================================================
--- code/branches/Asteroid_HS17/src/modules/asteroids/CMakeLists.txt	                        (rev 0)
+++ code/branches/Asteroid_HS17/src/modules/asteroids/CMakeLists.txt	2017-10-23 14:06:09 UTC (rev 11506)
@@ -0,0 +1,22 @@
+SET_SOURCE_FILES(Invader_SRC_FILES
+BUILD_UNIT InvaderBuildUnit.cc
+  Invader.cc
+  InvaderCenterPoint.cc
+  InvaderShip.cc
+  InvaderEnemy.cc
+  InvaderEnemyShooter.cc
+  InvaderWeapon.cc
+  InvaderWeaponEnemy.cc
+  InvaderHUDinfo.cc
+END_BUILD_UNIT
+)
+
+ORXONOX_ADD_LIBRARY(invader
+  PLUGIN
+  FIND_HEADER_FILES
+  LINK_LIBRARIES
+    orxonox
+    overlays
+    weapons
+  SOURCE_FILES ${Invader_SRC_FILES}
+)



More information about the Orxonox-commit mailing list