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

vyang at orxonox.net vyang at orxonox.net
Wed Dec 13 09:21:25 CET 2017


Author: vyang
Date: 2017-12-13 09:21:25 +0100 (Wed, 13 Dec 2017)
New Revision: 11668

Removed:
   code/branches/Asteroid_HS17/data/levels/Asteroid.oxw
Modified:
   code/branches/Asteroid_HS17/data/levels/templates/spaceshipAsteroids2D.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
   code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DStone.cc
   code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DWeapon.cc
Log:
Kommentare hinzugefuegt und Projektile in die richtige Richtung ausgerichtet.


Deleted: code/branches/Asteroid_HS17/data/levels/Asteroid.oxw
===================================================================
--- code/branches/Asteroid_HS17/data/levels/Asteroid.oxw	2017-12-12 19:29:52 UTC (rev 11667)
+++ code/branches/Asteroid_HS17/data/levels/Asteroid.oxw	2017-12-13 08:21:25 UTC (rev 11668)
@@ -1,37 +0,0 @@
- <LevelInfo
- name = "AsteroidsTest"
- description = "A level with absolutely nothing in it."
- tags = "test"
- screenshot = "emptylevel.png"
-/>
-
-<?lua
-  include("stats.oxo")
-  include("HUDTemplates3.oxo")
-  include("templates/lodInformation.oxt")
-  include("templates/HeavyCruiser.oxt")
-?>
-
-<?lua
-  include("templates/spaceship.oxt")
-  include("templates/endurancetest_template.oxt")
-?>
-
-<Level>
-  <templates>
-    <Template link=lodtemplate_default />
-  </templates>
-  <?lua include("includes/notifications.oxi") ?>
-
-  <Scene
-    ambientlight = "0.8, 0.8, 0.8"
-    skybox       = "Orxonox/Starbox"
-  >
-
-    <Light type=directional position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0"/>
-    <SpawnPoint team=0 position="0,0,0" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipAsteroids />
-
-    
-  </Scene>
-</Level>
-

Modified: code/branches/Asteroid_HS17/data/levels/templates/spaceshipAsteroids2D.oxt
===================================================================
--- code/branches/Asteroid_HS17/data/levels/templates/spaceshipAsteroids2D.oxt	2017-12-12 19:29:52 UTC (rev 11667)
+++ code/branches/Asteroid_HS17/data/levels/templates/spaceshipAsteroids2D.oxt	2017-12-13 08:21:25 UTC (rev 11668)
@@ -6,9 +6,9 @@
    spawnparticleduration  = 3
    explosionchunks        = 4
 
-   health            = 1000
-   maxhealth         = 1000
-   initialhealth     = 1000
+   health            = 10
+   maxhealth         = 10
+   initialhealth     = 10
 
    shieldhealth        = 20
    initialshieldhealth = 20

Modified: code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2D.cc
===================================================================
--- code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2D.cc	2017-12-12 19:29:52 UTC (rev 11667)
+++ code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2D.cc	2017-12-13 08:21:25 UTC (rev 11668)
@@ -35,7 +35,11 @@
     TODO: 
         - Implement a counting system for the score
         - HUD can be improved (display health, points, level etc.)
-        - Projectiles still 
+        - Projectiles still fly in a mysterious direction 
+        - Problem: The asteroids spawn randomly on the playing field.
+            During spawn or level up, there is the possibility that they pawn at the position of the ship.
+            ->spawn somewhere with a safty distance/radius
+
 */
 
 #include "Asteroids2D.h"
@@ -53,7 +57,7 @@
         RegisterObject(Asteroids2D);
 
         bEndGame = false;
-        lives = 1000;
+        lives = 3; 
         level = 1;
         point = 0;
         bShowLevel = false;
@@ -74,7 +78,7 @@
         if (getPlayer() != nullptr)
         {
 
-            //kann schoener gemacht werden
+            //Do something that indicates a level up
             for (int i = 0; i < 7; i++)
             {
                 WeakPtr<ExplosionPart> chunk5 = new ExplosionPart(this->center_->getContext());
@@ -93,7 +97,7 @@
         showLevelTimer.setTimer(1.0f, false, createExecutor(createFunctor(&Asteroids2D::toggleShowLevel, this)));
 
 
-        //After level up -> spawn stones
+        //After level up -> spawn stones. Modify for different difficulty level
         for(int i = 0; i < level*2; i++){
             spawnStone();
         }
@@ -110,7 +114,7 @@
             {
                 spawnStone();
             }
-
+            //after first tick, firstTick_ will remain false
             this->firstTick_ = false;
         }
         
@@ -120,10 +124,11 @@
     void Asteroids2D::spawnStone()
     {
 
-        //stones are created with a size
+        //stones are created with a size -> second constructor in Asteroids2DStone class
         Asteroids2DStone* newStone = new Asteroids2DStone(this->center_->getContext());
         newStone->setAsteroids2DPlayer(player);
 
+        //look at templates in data/levels/templates/asteroidsAsteroids2D.oxt
         switch(newStone->getSize()){
             case 1:
                 newStone->addTemplate("stone1");
@@ -164,7 +169,7 @@
     //The first function that will be called
     void Asteroids2D::start()
     {
-        orxout() << "start" << endl;
+        //orxout() << "start" << endl;
 
         // Set variable to temporarily force the player to spawn.
         this->bForceSpawn_ = false;
@@ -187,7 +192,7 @@
         }
     }
 
-    //wird gerufen, falls man einen Asteroiden trifft->Aufruf durch Schiffklasse
+    //This function will be called from the ship or the stone class (if the stone was hit)
     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-12 19:29:52 UTC (rev 11667)
+++ code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2D.h	2017-12-13 08:21:25 UTC (rev 11668)
@@ -76,6 +76,7 @@
             virtual void start() override;
             virtual void end() override;
 
+            //updates the game every few ns
             virtual void tick(float dt) override;
 
             virtual void playerPreSpawn(PlayerInfo* player) override;
@@ -98,6 +99,8 @@
 
             // checks if multiplier should be reset.
             void costLife();
+
+            //Returns player (ship) of the game
             Asteroids2DShip* getPlayer();
 
             bool bEndGame;

Modified: code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DShip.cc
===================================================================
--- code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DShip.cc	2017-12-12 19:29:52 UTC (rev 11667)
+++ code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DShip.cc	2017-12-13 08:21:25 UTC (rev 11668)
@@ -28,7 +28,6 @@
 
 /*  TODO: 
 
-/**
     @file Asteroids2DShip.cc
     @brief Implementation of the Asteroids2DShip class.
 */
@@ -45,9 +44,7 @@
     {
         RegisterObject(Asteroids2DShip);
 
-        speed = 830;
         isFireing = false;
-        damping = 10;
         this->width = 1043;
         this->height = 646;
 

Modified: code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DShip.h
===================================================================
--- code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DShip.h	2017-12-12 19:29:52 UTC (rev 11667)
+++ code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DShip.h	2017-12-13 08:21:25 UTC (rev 11668)
@@ -62,15 +62,21 @@
             //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.
-            virtual void boost(bool boost) override;
+            virtual void boost(bool boost) override; //Override, so that the ship does not shake
             virtual void updateLevel();
 
             virtual inline bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) override;
 
-            float speed, damping;
             bool isFireing;
+            
+            /*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;

Modified: code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DStone.cc
===================================================================
--- code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DStone.cc	2017-12-12 19:29:52 UTC (rev 11667)
+++ code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DStone.cc	2017-12-13 08:21:25 UTC (rev 11668)
@@ -110,10 +110,8 @@
 
     inline bool Asteroids2DStone::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint)
     {
-        orxout() << "AsteroidStone getroffen" << endl;
         if(orxonox_cast<Asteroids2DShip*>(otherObject))
         {
-            orxout() << "getroffen von Ship" << endl;
             split();
         }
         return false;
@@ -139,7 +137,7 @@
 
     void Asteroids2DStone::split()
     {
-        orxout() << "split" << endl;
+        //orxout() << "split" << endl;
         if(size == 3)
         {
             Asteroids2DStone* newStone1 = new Asteroids2DStone(this->getContext(), 2, this->getPosition());

Modified: code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DWeapon.cc
===================================================================
--- code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DWeapon.cc	2017-12-12 19:29:52 UTC (rev 11667)
+++ code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DWeapon.cc	2017-12-13 08:21:25 UTC (rev 11668)
@@ -92,12 +92,11 @@
 
         this->computeMuzzleParameters(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getAimPosition());
 
-        //projectile->setOrientation(this->getGame()->getPlayer()->getOrientation());
-        projectile->setPosition(this->getMuzzlePosition());
+        projectile->setOrientation(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getOrientation());
+        projectile->setPosition(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getPosition());
 
-
         //auf 2D Ebene druecken
-        Vector3 muzzle2D = this->getMuzzleDirection();
+        Vector3 muzzle2D = this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getOrientation()* WorldEntity::FRONT;
         muzzle2D.y = 0; 
 
         projectile->setVelocity(muzzle2D * this->speed_);



More information about the Orxonox-commit mailing list