[Orxonox-commit 6944] r11565 - code/branches/FlappyOrx_HS17/src/modules/flappyorx

pascscha at orxonox.net pascscha at orxonox.net
Mon Nov 20 13:35:53 CET 2017


Author: pascscha
Date: 2017-11-20 13:35:53 +0100 (Mon, 20 Nov 2017)
New Revision: 11565

Modified:
   code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrx.cc
   code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrx.h
   code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxHUDinfo.cc
   code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxShip.cc
   code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxShip.h
Log:
death message initiated2

Modified: code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrx.cc
===================================================================
--- code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrx.cc	2017-11-20 12:27:33 UTC (rev 11564)
+++ code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrx.cc	2017-11-20 12:35:53 UTC (rev 11565)
@@ -66,6 +66,8 @@
         level = 0;
         point = 0;
         bShowLevel = false;
+        sDeathMessage = "hallihallo";
+        bIsDead = true;
         multiplier = 1;
         b_combo = false;
         this->spawnDistance=200;
@@ -76,14 +78,9 @@
     void FlappyOrx::updatePlayerPos(int x){
 
         if(this->tubes.size()==0||x-tubes.back()+tubeOffsetX>spawnDistance){
-            orxout()<<"true: ";
             spawnTube();
             this->tubes.push(x+tubeOffsetX);
         }
-        else{
-            orxout()<<"false:";
-        }
-        orxout()<<"x("<<x<<")- tubes.back()("<<tubes.back()<<") + tubeOffsetX("<<tubeOffsetX<<") > spawnDistance("<<spawnDistance<<")"<<std::endl;
         if(this->tubes.size()!=0&&x>this->tubes.front()){
             this->tubes.pop();
             levelUp();
@@ -165,8 +162,6 @@
     }
 
     void FlappyOrx::createAsteroid(Circle &c){
-        orxout() << "created Asteroid at x="<<c.x<<" y="<<c.y << std::endl;
-
         MovableEntity* newAsteroid = new MovableEntity(this->center_->getContext());
 
 
@@ -199,11 +194,11 @@
     };
 
     bool FlappyOrx::isDead(){
-        return true;
+        return bIsDead;
     }
 
     std::string FlappyOrx::getDeathMessage(){
-        return "hello world";
+        return sDeathMessage;
     }
 
     void FlappyOrx::comboControll()
@@ -240,11 +235,12 @@
     }
 
     void FlappyOrx::death(){
+        bIsDead = true;
+        sDeathMessage = "GameOver";
         if (Highscore::exists()){
                     int score = this->getPoints();
                     if(score > Highscore::getInstance().getHighestScoreOfGame("Flappy Orx")) 
                         Highscore::getInstance().storeHighscore("Flappy Orx",score);
-
         }
         point = -1;
         level=-1;

Modified: code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrx.h
===================================================================
--- code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrx.h	2017-11-20 12:27:33 UTC (rev 11564)
+++ code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrx.h	2017-11-20 12:35:53 UTC (rev 11565)
@@ -95,6 +95,8 @@
             int multiplier;
             bool bEndGame;
             bool bShowLevel;
+            bool bIsDead;
+            std::string sDeathMessage;
             std::queue<int> tubes;
             std::queue<MovableEntity*> asteroids;
             int spawnDistance;

Modified: code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxHUDinfo.cc
===================================================================
--- code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxHUDinfo.cc	2017-11-20 12:27:33 UTC (rev 11564)
+++ code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxHUDinfo.cc	2017-11-20 12:35:53 UTC (rev 11565)
@@ -65,33 +65,27 @@
 
         if (this->FlappyOrxGame)
         {
-            // if (this->bShowLives_)  //preperation for easy mode
-            // {
-            //     const std::string& lives = multi_cast<std::string>(this->InvaderGame->getLives());
-            //     this->setCaption(lives);
-            // }
-            if(this->bShowPoints_)
-            {
-                const std::string& points = multi_cast<std::string>(this->FlappyOrxGame->getPoints());
-                if (not this->FlappyOrxGame->isDead())
-                {
+            if(not this->FlappyOrxGame->isDead()){
+                if(this->bShowPoints_){
+                    const std::string& points = multi_cast<std::string>(this->FlappyOrxGame->getPoints());
                     setTextSize(0.04);
                     setPosition(Vector2(0.14, 0.02));
                     this->setColour(ColourValue(1, 1, 1, 1));
                     this->setCaption(points);
                 }
+                else if(this->bShowGameOver_){
+                    setTextSize(0);
+                }
             }
-            if(this->bShowGameOver_){
-                if(this->FlappyOrxGame->isDead()){
+            else{
+                if(this->bShowGameOver_){
                     std::string message = this->FlappyOrxGame->getDeathMessage();
-                    setTextSize(0.4);
+                    setTextSize(0.1);
                     setPosition(Vector2(.5, .5));
                     this->setCaption(message);
                     this->setColour(ColourValue(1, 0, 0, 1));
                 }
-
-            }
-           
+            }   
         }
     }
 

Modified: code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxShip.cc
===================================================================
--- code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxShip.cc	2017-11-20 12:27:33 UTC (rev 11564)
+++ code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxShip.cc	2017-11-20 12:35:53 UTC (rev 11565)
@@ -51,6 +51,7 @@
         this->UpwardThrust = 1;
         this->speed = 1;
         this->gravity = 1;
+        isDead = true;
         
     }
 
@@ -67,7 +68,7 @@
     {
         SUPER(FlappyOrxShip, tick, dt);
         //Execute movement
-        if (this->hasLocalController())
+        if (this->hasLocalController()&&not isDead)
         {
             if(getHealth()<0){
                 setHealth(1);
@@ -126,6 +127,10 @@
     void FlappyOrxShip::moveRightLeft(const Vector2& value){}
 
     void FlappyOrxShip::boost(bool boost){
+        if(isDead){
+            isDead = false;
+            getGame()->bIsDead = false;
+        }
         isFlapping=boost;
     }
 

Modified: code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxShip.h
===================================================================
--- code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxShip.h	2017-11-20 12:27:33 UTC (rev 11564)
+++ code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxShip.h	2017-11-20 12:35:53 UTC (rev 11565)
@@ -82,6 +82,7 @@
             WeakPtr<FlappyOrx> game;
             Camera* camera;
             bool isFlapping;
+            bool isDead;
             float speed, UpwardThrust, gravity;
             struct Velocity
             {



More information about the Orxonox-commit mailing list