[Orxonox-commit 7522] r12128 - in code/branches/OrxoKart_HS18: data/levels src/modules/orxokart

ottka at orxonox.net ottka at orxonox.net
Wed Nov 28 12:06:14 CET 2018


Author: ottka
Date: 2018-11-28 12:06:14 +0100 (Wed, 28 Nov 2018)
New Revision: 12128

Modified:
   code/branches/OrxoKart_HS18/data/levels/OrxoKart1.oxw
   code/branches/OrxoKart_HS18/src/modules/orxokart/OrxoKart.cc
   code/branches/OrxoKart_HS18/src/modules/orxokart/OrxoKart.h
   code/branches/OrxoKart_HS18/src/modules/orxokart/OrxoKartTile.cc
   code/branches/OrxoKart_HS18/src/modules/orxokart/OrxoKartTile.h
   code/branches/OrxoKart_HS18/src/modules/orxokart/TimeHUD.cc
   code/branches/OrxoKart_HS18/src/modules/orxokart/TimeHUD.h
Log:
Make two levels and more

Modified: code/branches/OrxoKart_HS18/data/levels/OrxoKart1.oxw
===================================================================
--- code/branches/OrxoKart_HS18/data/levels/OrxoKart1.oxw	2018-11-28 10:57:48 UTC (rev 12127)
+++ code/branches/OrxoKart_HS18/data/levels/OrxoKart1.oxw	2018-11-28 11:06:14 UTC (rev 12128)
@@ -1,6 +1,6 @@
 <LevelInfo
- name = "OrxoKart"
- description = "Level for Minigame OrxoKart"
+ name = "OrxoKart Level 1"
+ description = "Level 1 of Minigame OrxoKart"
  tags = "minigame"
  screenshot = "emptylevel.png"
 />
@@ -19,9 +19,10 @@
 <?lua
 --number of tiles
 N = 11
--- or 25
 --scaling factor
 S = 80
+--level
+L = 1
 
 MAP_ORIGIN = "0,0,0"
 ?>
@@ -47,11 +48,13 @@
         <OrxoKartOrigin
           numCells="<?lua print(N)?>"
           cellSize="<?lua print(S)?>"
-          level=1
+          level="<?lua print(L)?>"
         />
       </attached> 
 
       <collisionShapes>
+        
+        
         <!-- in case of additional collisionShapes besides the floor -->
       </collisionShapes>
 

Modified: code/branches/OrxoKart_HS18/src/modules/orxokart/OrxoKart.cc
===================================================================
--- code/branches/OrxoKart_HS18/src/modules/orxokart/OrxoKart.cc	2018-11-28 10:57:48 UTC (rev 12127)
+++ code/branches/OrxoKart_HS18/src/modules/orxokart/OrxoKart.cc	2018-11-28 11:06:14 UTC (rev 12128)
@@ -47,7 +47,7 @@
         RegisterObject(OrxoKart);
 
         this->origin_ = nullptr;
-        this->numberOfFlags_ = 1;
+        this->raceFinished = false;
         this->firstTick_ = true;
 
         this->setHUDTemplate("OrxoKartHUD");
@@ -107,6 +107,12 @@
 
             int *levelcodeArray =  level==1 ? map_1 : map_2;
 
+
+
+            //OrxoKartTile* tile = new OrxoKartTile(origin_->getContext());
+            //tile->init(0*s, 4*s, s, 20, 2);
+
+
             // int z = 0;
             //Generate floor according to levelcode
             for(int i=0; i<n; i++){
@@ -113,15 +119,15 @@
                 for(int j=0; j<n; j++){
                     if (int type = levelcodeArray[i*n + j]) {
                         OrxoKartTile* tile = new OrxoKartTile(origin_->getContext());
-                        tile->init((n-1-i)*s, j*s, s, type);
+                        tile->init((n-1-i)*s, j*s, s, 0, type);
                         // tiles.push_back(tile);
                         //++z;
                         if (level == 1) {
                             //map 1 
-                            if ( i == 10 && j == 4 )
+                            if ( i == 9 && j == 4 )
                                 wayPoints.at(0) = tile;
 
-                            if ( i == 0 && j == 0) 
+                            if ( i == 0 && j == 1) 
                                 wayPoints.at(1) = tile;
                             if ( i == 10 && j == 7)
                                 wayPoints.at(2) = tile;
@@ -128,10 +134,10 @@
                         }
                         else if (level == 2) {
                             //map 2
-                            if ( i == 24 && j == 11 )
+                            if ( i == 23 && j == 11 )
                                 wayPoints.at(0) = tile;
 
-                            if ( i == 0 && j == 0) 
+                            if ( i == 0 && j == 1) 
                                 wayPoints.at(1) = tile;
                             if ( i == 24 && j == 17)
                                 wayPoints.at(2) = tile;
@@ -150,16 +156,10 @@
             
 
         } //firsttick end
-        /*
-        for (std::vector<OrxoKartTile*>::iterator it = tiles.begin(); it != tiles.end(); ++it ) {
-            if ((*it)->getCollided())
-                tiles.erase(it);
-        }
-        if (tiles.empty())
-            numberOfFlags_ = 0;
-        */
+        
         if (wayPointCounter >= 3)
-            numberOfFlags_ = 0;
+            raceFinished = true;
+
         else if (wayPointCounter < 3 && wayPointCounter >= 0 && wayPoints.at(wayPointCounter) != nullptr) {
             if (wayPoints.at(wayPointCounter)->getCollided()) {
                 for (int i = 0; i < 3; ++i) {
@@ -182,7 +182,7 @@
             if (level == 1)
                 player->setPosition(Vector3(s*0, 20, s*8));
             if (level == 2)
-                player->setPosition(Vector3(s*0, 20, s*19));
+                player->setPosition(Vector3(s*0, 20, s*18));
             player->setOrientation(Quaternion(1, 0, 0, 0));   // 0, 0, 0
             player->setVelocity(Vector3(0,0,0));
             player->setAcceleration(Vector3(0,0,0));
@@ -189,10 +189,6 @@
             flag_->setCollided(false); 
             wayPointCounter = 0;
 
-
-            // flag_->destroyLater();
-           // flags_.erase (flags_.begin()+i);
-            //numberOfFlags_ = 0;
         }
         
     }

Modified: code/branches/OrxoKart_HS18/src/modules/orxokart/OrxoKart.h
===================================================================
--- code/branches/OrxoKart_HS18/src/modules/orxokart/OrxoKart.h	2018-11-28 10:57:48 UTC (rev 12127)
+++ code/branches/OrxoKart_HS18/src/modules/orxokart/OrxoKart.h	2018-11-28 11:06:14 UTC (rev 12128)
@@ -54,8 +54,8 @@
             void setOrigin(OrxoKartOrigin* origin)
                 { this->origin_ = origin; }
 
-            inline int getNumberOfFlags() const
-                { return this->numberOfFlags_; }
+            inline int getRaceFinished() const
+                { return this->raceFinished; }
 
         private:
             WeakPtr<OrxoKartOrigin> origin_;
@@ -64,7 +64,7 @@
             int numberOfWP;
             std::vector<OrxoKartTile*> wayPoints;
             int wayPointCounter = 0;
-            int numberOfFlags_;
+            bool raceFinished;
             bool firstTick_;
 
             int s;

Modified: code/branches/OrxoKart_HS18/src/modules/orxokart/OrxoKartTile.cc
===================================================================
--- code/branches/OrxoKart_HS18/src/modules/orxokart/OrxoKartTile.cc	2018-11-28 10:57:48 UTC (rev 12127)
+++ code/branches/OrxoKart_HS18/src/modules/orxokart/OrxoKartTile.cc	2018-11-28 11:06:14 UTC (rev 12128)
@@ -80,7 +80,7 @@
     @param type
         type of tile. 1 for normal tile, 2 for Start/End tile      
     */
-    void OrxoKartTile::init(int x, int z, int s, int type)
+    void OrxoKartTile::init(int x, int z, int s, float r, int type)
     {
         // floor design according to its type
         model_ = new Model(this->getContext());
@@ -92,6 +92,7 @@
         }
         model_->setScale3D(Vector3(s*1.0f, 8.0f, s*1.0f));
         model_->setPosition(Vector3(x*1.0f, 0.0f, z*1.0f));
+        model_->pitch(Degree(r));
 
         this->attach(model_);
 
@@ -100,6 +101,7 @@
         cs_ = new BoxCollisionShape(this->getContext());
         cs_->setHalfExtents(Vector3(s/2.0f, 1.0f, s/2.0f));
         cs_->setPosition(Vector3(x*1.0f, -1.0f, z*1.0f));
+        cs_->pitch(Degree(r));
 
         this->attachCollisionShape(cs_);
     }

Modified: code/branches/OrxoKart_HS18/src/modules/orxokart/OrxoKartTile.h
===================================================================
--- code/branches/OrxoKart_HS18/src/modules/orxokart/OrxoKartTile.h	2018-11-28 10:57:48 UTC (rev 12127)
+++ code/branches/OrxoKart_HS18/src/modules/orxokart/OrxoKartTile.h	2018-11-28 11:06:14 UTC (rev 12128)
@@ -49,7 +49,7 @@
             OrxoKartTile(Context* context);
             virtual ~OrxoKartTile();
 
-            void init(int x, int z, int s, int type);
+            void init(int x, int z, int s, float r, int type);
 
             virtual bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) override;
 

Modified: code/branches/OrxoKart_HS18/src/modules/orxokart/TimeHUD.cc
===================================================================
--- code/branches/OrxoKart_HS18/src/modules/orxokart/TimeHUD.cc	2018-11-28 10:57:48 UTC (rev 12127)
+++ code/branches/OrxoKart_HS18/src/modules/orxokart/TimeHUD.cc	2018-11-28 11:06:14 UTC (rev 12128)
@@ -32,6 +32,10 @@
 
 #include "TimeHUD.h"
 
+#include <iostream>
+#include <fstream>
+#include "Highscore.h"
+
 #include "core/CoreIncludes.h"
 #include "util/Convert.h"
 #include "OrxoKart.h"
@@ -81,8 +85,16 @@
         if (this->orxokartGame_)
         {
             this->setCaption(getTimeString(this->time_));
-            if (this->orxokartGame_->getNumberOfFlags() == 0)
+            if (this->orxokartGame_->getRaceFinished()) {
                 setRunning(false);
+                if (!score_set) {
+                    std::ofstream highscoreFile;
+                    highscoreFile.open("orxokart_highscores.txt", std::ios::app);
+                    highscoreFile << "Name: " << getTimeString(this->time_) << std::endl;
+                    highscoreFile.close();
+                    score_set = true;
+                }
+            }
         }
         
     }

Modified: code/branches/OrxoKart_HS18/src/modules/orxokart/TimeHUD.h
===================================================================
--- code/branches/OrxoKart_HS18/src/modules/orxokart/TimeHUD.h	2018-11-28 10:57:48 UTC (rev 12127)
+++ code/branches/OrxoKart_HS18/src/modules/orxokart/TimeHUD.h	2018-11-28 11:06:14 UTC (rev 12128)
@@ -33,6 +33,8 @@
 #define _TimeHUD_H__
 
 #include "OrxoKartPrereqs.h"
+#include <iostream>
+#include <fstream>
 
 #include "tools/interfaces/Tickable.h"
 #include "overlays/OverlayText.h"
@@ -60,6 +62,7 @@
             OrxoKart* orxokartGame_;
             float time_;
             bool running_;
+            bool score_set = false;
     };
 }
 #endif /* _TimeHUD_H__ */



More information about the Orxonox-commit mailing list