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

vyang at orxonox.net vyang at orxonox.net
Thu Nov 30 18:34:56 CET 2017


Author: vyang
Date: 2017-11-30 18:34:56 +0100 (Thu, 30 Nov 2017)
New Revision: 11613

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/Asteroids2DCenterPoint.cc
   code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DShip.cc
   code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DShip.h
Log:
Geschwindigkeit im Level angepasst, Raumschiff kann das Spielfeld nicht mehr verlassen. TO DO: Rausfinden wie Rotation funktioniert -> in Asteroid2DShip Funktionen Yaw, Pitch, Roll ueberladen oder im Levelfile anpassen.

Modified: code/branches/Asteroid_HS17/data/levels/templates/spaceshipAsteroids2D.oxt
===================================================================
--- code/branches/Asteroid_HS17/data/levels/templates/spaceshipAsteroids2D.oxt	2017-11-30 14:35:25 UTC (rev 11612)
+++ code/branches/Asteroid_HS17/data/levels/templates/spaceshipAsteroids2D.oxt	2017-11-30 17:34:56 UTC (rev 11613)
@@ -19,7 +19,7 @@
 
    primaryThrust     = 150
    auxilaryThrust    = 30
-   rotationThrust    = 50
+   rotationThrust    = 500
 
    lift = 1;
    stallSpeed = 220;
@@ -34,7 +34,7 @@
 
    collisionType     = "dynamic"
    mass              = 4200000
-   linearDamping     = 0.9999999
+   linearDamping     = 0.9
    angularDamping    = 0.9999999
 
    collisiondamage = 100
@@ -97,9 +97,9 @@
    boostfactor    = 2.2
 
    speedfront     = 200
-   speedback      =  70
-   speedleftright =  70
-   speedupdown    =  70
+   speedback      = 200
+   speedleftright =  100
+   speedupdown    =  100
 
    defEngineSndNormal = "sounds/Engine_low.ogg"
    defEngineSndBoost = "sounds/Engine_high.ogg"
@@ -106,9 +106,9 @@
 
    accelerationfront     = 700
    accelerationbrake     = 700
-   accelerationback      =  125
-   accelerationleftright =  125
-   accelerationupdown    =  125
+   accelerationback      = 700
+   accelerationleftright =  500
+   accelerationupdown    =  500
   >
     <EffectContainer condition="idle">
       <WorldSound mainstate="activity" source="sounds/Engine_idle.ogg" looping=1 active=false/>

Modified: code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2D.cc
===================================================================
--- code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2D.cc	2017-11-30 14:35:25 UTC (rev 11612)
+++ code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2D.cc	2017-11-30 17:34:56 UTC (rev 11613)
@@ -54,13 +54,13 @@
         counter = 5000;
         pattern = 1;
         lastPosition = 0;
-        // spawn enemy every 3.5 seconds
-        //enemySpawnTimer.setTimer(3.5f, true, createExecutor(createFunctor(&Asteroids2D::spawnEnemy, this)));
         this->numberOfBots_ = 0; //sets number of default bots temporarly to 0
         this->center_ = nullptr;
         this->setHUDTemplate("Asteroids2DHUD");
     }
 
+
+
     void Asteroids2D::levelUp()
     {
         level++;

Modified: code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2D.h
===================================================================
--- code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2D.h	2017-11-30 14:35:25 UTC (rev 11612)
+++ code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2D.h	2017-11-30 17:34:56 UTC (rev 11613)
@@ -88,6 +88,7 @@
             // checks if multiplier should be reset.
             void costLife();
 
+
             bool bEndGame;
             bool bShowLevel;
             int lives;

Modified: code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DCenterPoint.cc
===================================================================
--- code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DCenterPoint.cc	2017-11-30 14:35:25 UTC (rev 11612)
+++ code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DCenterPoint.cc	2017-11-30 17:34:56 UTC (rev 11613)
@@ -47,8 +47,8 @@
         RegisterObject(Asteroids2DCenterPoint);
 
         this->checkGametype();
-        this->width_ = 200;
-        this->height_ = 120;
+        this->width_ = 1043;
+        this->height_ = 646;
     }
     /**
     @brief

Modified: code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DShip.cc
===================================================================
--- code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DShip.cc	2017-11-30 14:35:25 UTC (rev 11612)
+++ code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DShip.cc	2017-11-30 17:34:56 UTC (rev 11613)
@@ -45,16 +45,41 @@
         speed = 830;
         isFireing = false;
         damping = 10;
+        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)));
     }
 
+    //Use this function to display your position on the field -> to determine field width and height
+    void Asteroids2DShip::showposition()
+    {
+        Vector3 pos = this->getPosition();
+        orxout() << "x = "<< pos.x << " y = " << pos.y << " z = "<< pos.z << endl; 
+    }
+
     void Asteroids2DShip::tick(float dt)
     {
         SUPER(Asteroids2DShip, tick, dt);
+        Vector3 pos = this->getPosition();
+
+        //haelt ship innerhalb des Kamerafensters, kommt oben bzw seitlich wieder raus. Man spawnt in (0,0)
+        if(pos.x > width/2)   pos.x = -width/2;
+        if(pos.x < -width/2)  pos.x = width/2;
+        if(pos.z > height/2)  pos.z = -height/2;
+        if(pos.z < -height/2) pos.z = height/2;
+
+        //2D movement, position should always = 0 on y-axis
+        if(pos.y!=0) pos.y = 0;
+        this->setPosition(pos);
+
+        //update level
+
+        //shoot?
     }
 
     void Asteroids2DShip::updateLevel()

Modified: code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DShip.h
===================================================================
--- code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DShip.h	2017-11-30 14:35:25 UTC (rev 11612)
+++ code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DShip.h	2017-11-30 17:34:56 UTC (rev 11613)
@@ -44,6 +44,9 @@
 #include "Asteroids2D.h" // Is necessary for getGame function
 //#include "Asteroids2DCenterPoint.h"
 
+#include "tools/Timer.h"
+
+
 namespace orxonox
 {
     class _Asteroids2DExport Asteroids2DShip : public SpaceShip
@@ -60,13 +63,13 @@
             // 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{};
+            //no rotation in x and z direction!
+            virtual void rotateYaw(const Vector2& value) override{}; // Rotate in yaw direction.
+            virtual void rotatePitch(const Vector2& value) override{}; // Rotate in pitch direction.
+            virtual void rotateRoll(const Vector2& value) override{}; // Rotate in roll direction.
 
-            //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;
@@ -73,6 +76,7 @@
 
             float speed, damping, posforeward;
             bool isFireing;
+            void showposition();
 
         protected:
             virtual void death() override;
@@ -79,6 +83,7 @@
 
         private:
             Asteroids2D* getGame();
+            float width, height;
             WeakPtr<Asteroids2D> game;
             WeakPtr<WorldEntity> lastEntity;
             float lastTimeFront, lastTimeLeft, lastTime;
@@ -88,6 +93,7 @@
                 float y;
             } velocity, desiredVelocity;
 
+            Timer timer;
     };
 }
 



More information about the Orxonox-commit mailing list