[Orxonox-commit 6996] r11617 - in code/branches/Asteroid_HS17: data/levels data/levels/templates src/modules/asteroids2D

vyang at orxonox.net vyang at orxonox.net
Sun Dec 3 18:02:23 CET 2017


Author: vyang
Date: 2017-12-03 18:02:22 +0100 (Sun, 03 Dec 2017)
New Revision: 11617

Modified:
   code/branches/Asteroid_HS17/data/levels/Asteroids2D.oxw
   code/branches/Asteroid_HS17/data/levels/templates/asteroidsAsteroids2D.oxt
   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/Asteroids2DShip.cc
   code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DShip.h
Log:
spawnEnemy und Templates fur die 3 Grossen der Asteroiden geschrieben.

Modified: code/branches/Asteroid_HS17/data/levels/Asteroids2D.oxw
===================================================================
--- code/branches/Asteroid_HS17/data/levels/Asteroids2D.oxw	2017-12-02 17:15:54 UTC (rev 11616)
+++ code/branches/Asteroid_HS17/data/levels/Asteroids2D.oxw	2017-12-03 17:02:22 UTC (rev 11617)
@@ -16,6 +16,7 @@
   include("templates/spaceshipAsteroids2D.oxt")
   include("templates/enemyInvader.oxt")
   include("overlays/Asteroids2DHUD.oxo")
+  include("templates/asteroidsAsteroids2D.oxt)
 ?>
 
 <Level

Modified: code/branches/Asteroid_HS17/data/levels/templates/asteroidsAsteroids2D.oxt
===================================================================
--- code/branches/Asteroid_HS17/data/levels/templates/asteroidsAsteroids2D.oxt	2017-12-02 17:15:54 UTC (rev 11616)
+++ code/branches/Asteroid_HS17/data/levels/templates/asteroidsAsteroids2D.oxt	2017-12-03 17:02:22 UTC (rev 11617)
@@ -0,0 +1,62 @@
+<Template name = stone1>
+  <Asteroids2DStone
+    collisionType = dynamic
+    linearDamping = 0.8
+    angularDamping = 1
+    scale= 10
+    enablecollisiondamage = true
+
+    health            = 10
+    maxhealth         = 10
+    initialhealth     = 10
+  >
+    <attached>
+      <Model mass= 4000 mesh="ast1.mesh" />
+    </attached>
+    <collisionShapes>
+      <SphereCollisionShape radius="10" />
+    </collisionShapes>
+  </Asteroids2DStone>
+</Template>
+
+<Template name = stone2>
+  <Asteroids2DStone
+    collisionType = dynamic
+    linearDamping = 0.8
+    angularDamping = 1
+    scale= 20
+    enablecollisiondamage = true
+
+    health            = 10
+    maxhealth         = 10
+    initialhealth     = 10
+  >
+    <attached>
+      <Model mass= 8000 mesh="ast2.mesh" />
+    </attached>
+    <collisionShapes>
+      <SphereCollisionShape radius="20" />
+    </collisionShapes>
+  </Asteroids2DStone>
+</Template>
+
+<Template name = stone3>
+  <Asteroids2DStone
+    collisionType = dynamic
+    linearDamping = 0.8
+    angularDamping = 1
+    scale= 30
+    enablecollisiondamage = true
+
+    health            = 10
+    maxhealth         = 10
+    initialhealth     = 10
+  >
+    <attached>
+      <Model mass= 16000 mesh="ast3.mesh" />
+    </attached>
+    <collisionShapes>
+      <SphereCollisionShape radius="30" />
+    </collisionShapes>
+  </Asteroids2DStone>
+</Template>
\ No newline at end of file

Modified: code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2D.cc
===================================================================
--- code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2D.cc	2017-12-02 17:15:54 UTC (rev 11616)
+++ code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2D.cc	2017-12-03 17:02:22 UTC (rev 11617)
@@ -26,6 +26,11 @@
  *
  */
 
+/*TODO: Punktesystem aufbauen -> in HUD anzeigen
+        Schwierigkeitsgrad mit jedem levelup erhöhen -> mehr Steine spawnen?
+        spawnStone Methode schreiben
+        templates für die drei Grössen von Asteroiden erstellen
+
 /**
     @file Asteroids2D.cc
     @brief Implementation of the Asteroids2D class.
@@ -56,6 +61,7 @@
         this->numberOfBots_ = 0; //sets number of default bots temporarly to 0
         this->center_ = nullptr;
         this->setHUDTemplate("Asteroids2DHUD");
+        levelupTimer.setTimer(100.0f, true, createExecutor(createFunctor(&Asteroids2D::levelUp, this)));
     }
 
 
@@ -81,11 +87,16 @@
         multiplier *= 2;
         toggleShowLevel();
         showLevelTimer.setTimer(1.0f, false, createExecutor(createFunctor(&Asteroids2D::toggleShowLevel, this)));
+        //Nach jedem Level Up werden mehr Steine gespawnt -> abhängig vom Schwierigkeitsgrad
+        for(int i = 0; i < level*2; i++){
+            spawnStone();
+        }
+
     }
 
     void Asteroids2D::tick(float dt)
     {
-        //Do this only for the first tick, generate stones
+        //Do this only for the first tick, generate 5 stones for the beginning
         if(this->firstTick_)
         {
             for(int i = 0; i < 5; ++i)
@@ -104,8 +115,24 @@
             return;
         Asteroids2DStone* newStone = new Asteroids2DStone(this->center_->getContext());
         newStone->setAsteroids2DPlayer(player);
-        //addtemplate
 
+        switch(newStone->getSize()){
+            case 1:
+                newStone->addTemplate("stone1");
+                break;
+            case 2: 
+                newStone->addTemplate("stone2");
+                break;
+            case 3:
+                newStone->addTemplate("stone3");
+                break;
+            default:
+                orxout(internal_error) << "Asteroids2DStone has invalid size and cannot be created" << endl;
+                break;
+
+        }
+
+
     }
 
     Asteroids2DShip* Asteroids2D::getPlayer()
@@ -122,9 +149,12 @@
 
     void Asteroids2D::costLife()
     {
-        //endGameTimer.setTimer(8.0f, false, createExecutor(createFunctor(&Asteroids2D::end, this)));
-        lives = 0;
+        --lives;
+        if(live <= 0){
+            endGameTimer.setTimer(8.0f, false, createExecutor(createFunctor(&Asteroids2D::end, this)));            
+        }
     };
+    
 
     void Asteroids2D::start()
     {
@@ -151,6 +181,7 @@
         }
     }
 
+    //wird gerufen, falls man einen Asteroiden trifft->Aufruf durch Schiffklasse
     void Asteroids2D::addPoints(int numPoints)
     {
         if (!bEndGame)

Modified: code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2D.h
===================================================================
--- code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2D.h	2017-12-02 17:15:54 UTC (rev 11616)
+++ code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2D.h	2017-12-03 17:02:22 UTC (rev 11617)
@@ -26,6 +26,8 @@
  *
  */
 
+
+
 /**
     @file Asteroids2D.h
     @brief Gametype.
@@ -108,33 +110,11 @@
             int point;
             bool b_combo, firstTick_;
 
-            Timer enemySpawnTimer;
             Timer comboTimer;
             Timer showLevelTimer;
+            Timer levelupTimer;
+            Timer endGameTimer;
 
-
-         /*
-
-            //void spawnEnemy();
-
-
-
-
-
-
-
-
-
-
-
-
-        private:
-
-
-
-
-            //Context* context;
-            */
     };
 }
 

Modified: code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DShip.cc
===================================================================
--- code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DShip.cc	2017-12-02 17:15:54 UTC (rev 11616)
+++ code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DShip.cc	2017-12-03 17:02:22 UTC (rev 11617)
@@ -26,6 +26,10 @@
  *
  */
 
+/*TODO: orientation/direction of the ship must be defined
+        implement shoot function ->or switch it on?
+        switch off boosting particles in the back of the ship
+
 /**
     @file Asteroids2DShip.cc
     @brief Implementation of the Asteroids2DShip class.
@@ -48,10 +52,6 @@
         this->width = 1043;
         this->height = 646;
 
-        // not sure if has to be zero?
-        lastTimeFront = 0;
-        lastTimeLeft = 0;
-        lastTime = 0;
         timer.setTimer(3.5f, true, createExecutor(createFunctor(&Asteroids2DShip::showposition, this)));
     }
 
@@ -84,7 +84,6 @@
 
     void Asteroids2DShip::updateLevel()
     {
-        lastTime = 0;
         if (getGame())
             getGame()->levelUp();
     }

Modified: code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DShip.h
===================================================================
--- code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DShip.h	2017-12-02 17:15:54 UTC (rev 11616)
+++ code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DShip.h	2017-12-03 17:02:22 UTC (rev 11617)
@@ -86,7 +86,6 @@
             float width, height;
             WeakPtr<Asteroids2D> game;
             WeakPtr<WorldEntity> lastEntity;
-            float lastTimeFront, lastTimeLeft, lastTime;
             struct Velocity
             {
                 float x;



More information about the Orxonox-commit mailing list