[Orxonox-commit 6995] r11616 - in code/branches/Asteroid_HS17: data/levels src/modules/asteroids2D

vyang at orxonox.net vyang at orxonox.net
Sat Dec 2 18:15:54 CET 2017


Author: vyang
Date: 2017-12-02 18:15:54 +0100 (Sat, 02 Dec 2017)
New Revision: 11616

Added:
   code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DStone.cc
   code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DStone.h
Removed:
   code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DCube.cc
   code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DCube.h
Modified:
   code/branches/Asteroid_HS17/data/levels/Asteroids2D.oxw
   code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2D.cc
   code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2D.h
   code/branches/Asteroid_HS17/src/modules/asteroids2D/CMakeLists.txt
Log:
Asteroids2DStones erstellt, lassen sich ins Level laden, random spawn wenn position nicht als Attribut im XML File angegeben wird. Random Geschwindigkeit funktioniert noch nicht -> vllt Einstellungen in Pawn bzw MovableEntity?, Gametype ein wenig aufgeraemt -> am Anfang fuenf Asteroiden mit random Geschwindigkeit und Position spawnen

Modified: code/branches/Asteroid_HS17/data/levels/Asteroids2D.oxw
===================================================================
--- code/branches/Asteroid_HS17/data/levels/Asteroids2D.oxw	2017-12-01 19:40:42 UTC (rev 11615)
+++ code/branches/Asteroid_HS17/data/levels/Asteroids2D.oxw	2017-12-02 17:15:54 UTC (rev 11616)
@@ -47,7 +47,7 @@
     <!--<Model mesh="axes.mesh" scale=10 position="0,0,0" /> -->
 
 
-    <?lua
+    <!--<?lua
       for i = 1, 250, 1
       do
       j = math.random()
@@ -72,9 +72,24 @@
 
     <?lua
       end
-    ?>
+    ?>-->
 
 
+    <Asteroids2DStone
+      collisionType = dynamic
+      linearDamping = 0.8
+      angularDamping = 1
+      scale= 10
+      enablecollisiondamage = true
+    >
+      <attached>
+        <Model mass= 8000 mesh="ast1.mesh" />
+      </attached>
+      <collisionShapes>
+        <SphereCollisionShape radius="10" />
+      </collisionShapes>
+    </Asteroids2DStone>
+
     <Asteroids2DCenterPoint name=asteroids2Dcenter />
   
     

Modified: code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2D.cc
===================================================================
--- code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2D.cc	2017-12-01 19:40:42 UTC (rev 11615)
+++ code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2D.cc	2017-12-02 17:15:54 UTC (rev 11616)
@@ -33,6 +33,7 @@
 
 #include "Asteroids2D.h"
 #include "Asteroids2DShip.h" // Necessary for getPlayer function. Do NOT include this in Header!
+#include "Asteroids2DStone.h"
 #include "core/CoreIncludes.h"
 #include "Highscore.h"
 
@@ -45,15 +46,13 @@
         RegisterObject(Asteroids2D);
 
         bEndGame = false;
-        lives = 1;
+        lives = 3;
         level = 1;
         point = 0;
         bShowLevel = false;
         multiplier = 1;
         b_combo = false;
-        counter = 5000;
-        pattern = 1;
-        lastPosition = 0;
+        firstTick_ = true;
         this->numberOfBots_ = 0; //sets number of default bots temporarly to 0
         this->center_ = nullptr;
         this->setHUDTemplate("Asteroids2DHUD");
@@ -86,10 +85,29 @@
 
     void Asteroids2D::tick(float dt)
     {
+        //Do this only for the first tick, generate stones
+        if(this->firstTick_)
+        {
+            for(int i = 0; i < 5; ++i)
+            {
+                spawnStone();
+            }
+            this->firstTick_ = false;
+        }
         
         SUPER(Asteroids2D, tick, dt);
     }
 
+    void Asteroids2D::spawnStone()
+    {
+        if (getPlayer() == nullptr)
+            return;
+        Asteroids2DStone* newStone = new Asteroids2DStone(this->center_->getContext());
+        newStone->setAsteroids2DPlayer(player);
+        //addtemplate
+
+    }
+
     Asteroids2DShip* Asteroids2D::getPlayer()
     {
         if (player == nullptr)
@@ -150,8 +168,8 @@
         // Instead startMainMenu, this won't crash.
         if (Highscore::exists()){
                     int score = this->getPoints();
-                    if(score > Highscore::getInstance().getHighestScoreOfGame("Dodge Race")) 
-                        Highscore::getInstance().storeHighscore("Dodge Race",score);
+                    if(score > Highscore::getInstance().getHighestScoreOfGame("Asteroids2D")) 
+                        Highscore::getInstance().storeHighscore("Asteroids2D",score);
 
           }
         GSLevel::startMainMenu();

Modified: code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2D.h
===================================================================
--- code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2D.h	2017-12-01 19:40:42 UTC (rev 11615)
+++ code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2D.h	2017-12-02 17:15:54 UTC (rev 11616)
@@ -81,6 +81,7 @@
             int getPoints(){return this->point;}
             int getMultiplier(){return this->multiplier;}
 
+            void spawnStone();
             void setCenterpoint(Asteroids2DCenterPoint* center)
                        { this->center_ = center; }
             virtual void addBots(unsigned int amount) override{} //<! overwrite function in order to bypass the addbots command
@@ -93,10 +94,6 @@
             bool bShowLevel;
             int lives;
             int multiplier;
-            float counter;
-            int pattern;
-            float currentPosition;
-            float lastPosition;
 
        private:
             Timer endGameTimer;
@@ -103,7 +100,6 @@
 
             Asteroids2DShip* getPlayer();
             WeakPtr<Asteroids2DShip> player;
-            std::vector<Asteroids2DCube*> cubeList;
             void toggleShowLevel(){bShowLevel = !bShowLevel;}
             void addPoints(int numPoints);
 
@@ -110,7 +106,7 @@
             WeakPtr<Asteroids2DCenterPoint> center_;
             int level;
             int point;
-            bool b_combo;
+            bool b_combo, firstTick_;
 
             Timer enemySpawnTimer;
             Timer comboTimer;

Deleted: code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DCube.cc
===================================================================
--- code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DCube.cc	2017-12-01 19:40:42 UTC (rev 11615)
+++ code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DCube.cc	2017-12-02 17:15:54 UTC (rev 11616)
@@ -1,60 +0,0 @@
-/*   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:
- *      Samuel Riedel
- *   Co-authors:
- *      ...
- *
- */
-
-/**
-    @file Asteroids2D.cc
-    @brief Implementation of the Asteroids2D class.
-*/
-
-#include "Asteroids2DCube.h"
-#include "Asteroids2D.h"
-#include "core/CoreIncludes.h"
-#include "util/Math.h"
-
-namespace orxonox
-{
-    RegisterClass(Asteroids2DCube);
-
-    Asteroids2DCube::Asteroids2DCube(Context* context) : Pawn(context)
-    {
-        RegisterObject(Asteroids2DCube);
-        this->size = 1;
-        this->width = 1043;
-        this->height = 646;
-        //this->setPosition();
-        //this->setVelocity(Vector3 )
-    }
-
-    void Asteroids2DCube::tick(float dt)
-    {
-    	SUPER(Asteroids2DCube, tick, dt);
-    	
-
-    }
-
-
-}

Deleted: code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DCube.h
===================================================================
--- code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DCube.h	2017-12-01 19:40:42 UTC (rev 11615)
+++ code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DCube.h	2017-12-02 17:15:54 UTC (rev 11616)
@@ -1,57 +0,0 @@
-/*
- *   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:
- *      Samuel Riedel
- *   Co-authors:
- *      ...
- *
- */
-
-/**
-    @file Asteroids2D.h
-    @brief Gametype.
-    @ingroup Asteroids2D
-*/
-
-#ifndef _Asteroids2DCube_H__
-#define _Asteroids2DCube_H__
-
-#include "asteroids2D/Asteroids2DPrereqs.h"
-
-#include "worldentities/pawns/Pawn.h"
-
-
-namespace orxonox
-{
-    class _Asteroids2DExport Asteroids2DCube : public Pawn
-    {
-       public:
-            Asteroids2DCube(Context* context);
-            virtual void tick(float dt) override;
-
-       private:
-       		int size;				// three sizes, 3-> two 2s, 2-> two 1s, 1-> die
-       		float width, height;	//field
-    };
-}
-
-#endif /* _Asteroids2DCube_H__ */

Added: code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DStone.cc
===================================================================
--- code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DStone.cc	                        (rev 0)
+++ code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DStone.cc	2017-12-02 17:15:54 UTC (rev 11616)
@@ -0,0 +1,102 @@
+/*   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:
+ *      Samuel Riedel
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file Asteroids2DStone.cc
+    @brief Implementation of the Asteroids2DStone class.
+*/
+
+#include "Asteroids2DStone.h"
+#include "Asteroids2D.h"
+#include "Asteroids2DShip.h"
+#include "core/CoreIncludes.h"
+#include "util/Math.h"
+
+namespace orxonox
+{
+    RegisterClass(Asteroids2DStone);
+
+    Asteroids2DStone::Asteroids2DStone(Context* context) : Pawn(context)
+    {
+        RegisterObject(Asteroids2DStone);
+        this->size = 1;
+        this->width = 1043;
+        this->height = 646;
+        this->setPosition(randomPosition(this->width, this->height));
+        this->setVelocity(randomVelocity(MAX_SPEED));
+    }
+
+    Vector3 Asteroids2DStone::randomPosition(float maxwidth, float maxheight)
+    {
+        Vector3 pos;
+        pos.x = rnd(-maxwidth/2, maxwidth/2);
+        pos.y = 0;
+        pos.z = rnd(-maxheight/2, maxheight/2);
+        return pos;
+    }
+
+    Vector3 Asteroids2DStone::randomVelocity(float maxspeed)
+    {
+        Vector3 vel;
+        vel.x = rnd(maxspeed);
+        vel.y = 0;
+        vel.z = rnd(maxspeed);
+        return vel;
+    }
+
+
+    void Asteroids2DStone::tick(float dt)
+    {
+    	SUPER(Asteroids2DStone, tick, dt);
+        Vector3 pos = this->getPosition();
+        if(pos.x >= width/2 || pos.x <= -width/2 || pos.z >= height/2 || pos.z <= -height/2)
+        {
+            Quaternion orientation = this->getOrientation();
+            orientation.w -= 180;
+            this->setOrientation(Vector3::UNIT_Y, Degree(orientation.w));
+        }
+
+    }
+
+
+    //Overload kill function to generate 2 asteriods
+    /*void Asteroids2DStone::kill()
+    {
+        this->damage(this->health)
+        if(this->size < 1)
+        {
+            this->death();
+        }else{
+            size -= 1;
+
+        }
+
+
+    }*/
+
+
+}

Added: code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DStone.h
===================================================================
--- code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DStone.h	                        (rev 0)
+++ code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DStone.h	2017-12-02 17:15:54 UTC (rev 11616)
@@ -0,0 +1,63 @@
+/*
+ *   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:
+ *      ...
+ *    TO DO: 
+ *
+ */
+
+/**
+    @file Asteroids2D.h
+    @brief Gametype.
+    @ingroup Asteroids2D
+*/
+
+#ifndef _Asteroids2DStone_H__
+#define _Asteroids2DStone_H__
+
+#include "asteroids2D/Asteroids2DPrereqs.h"
+
+#include "worldentities/pawns/Pawn.h"
+
+
+namespace orxonox
+{
+    class _Asteroids2DExport Asteroids2DStone : public Pawn
+    {
+       public:
+            Asteroids2DStone(Context* context);
+            virtual void tick(float dt) override;
+            Vector3 randomPosition (float maxwidth, float maxheight);
+            Vector3 randomVelocity(float maxspeed);
+            void setAsteroids2DPlayer(Asteroids2DShip* player){this->player = player;};
+
+       private:
+          WeakPtr<Asteroids2DShip> player;          
+       		int size;				// three sizes, 3-> two 2s, 2-> two 1s, 1-> die
+       		float width, height;	//field
+          float MAX_SPEED = 500;
+    };
+}
+
+#endif /* _Asteroids2DStone_H__ */

Modified: code/branches/Asteroid_HS17/src/modules/asteroids2D/CMakeLists.txt
===================================================================
--- code/branches/Asteroid_HS17/src/modules/asteroids2D/CMakeLists.txt	2017-12-01 19:40:42 UTC (rev 11615)
+++ code/branches/Asteroid_HS17/src/modules/asteroids2D/CMakeLists.txt	2017-12-02 17:15:54 UTC (rev 11616)
@@ -2,7 +2,7 @@
 Asteroids2D.cc
 Asteroids2DCenterPoint.cc
 Asteroids2DShip.cc
-Asteroids2DCube.cc
+Asteroids2DStone.cc
 Asteroids2DHUDinfo.cc
 )
 



More information about the Orxonox-commit mailing list