Changeset 12128 for code/branches/OrxoKart_HS18/src/modules/orxokart
- Timestamp:
- Nov 28, 2018, 12:06:14 PM (6 years ago)
- Location:
- code/branches/OrxoKart_HS18/src/modules/orxokart
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/OrxoKart_HS18/src/modules/orxokart/OrxoKart.cc
r12116 r12128 48 48 49 49 this->origin_ = nullptr; 50 this-> numberOfFlags_ = 1;50 this->raceFinished = false; 51 51 this->firstTick_ = true; 52 52 … … 108 108 int *levelcodeArray = level==1 ? map_1 : map_2; 109 109 110 111 112 //OrxoKartTile* tile = new OrxoKartTile(origin_->getContext()); 113 //tile->init(0*s, 4*s, s, 20, 2); 114 115 110 116 // int z = 0; 111 117 //Generate floor according to levelcode … … 114 120 if (int type = levelcodeArray[i*n + j]) { 115 121 OrxoKartTile* tile = new OrxoKartTile(origin_->getContext()); 116 tile->init((n-1-i)*s, j*s, s, type);122 tile->init((n-1-i)*s, j*s, s, 0, type); 117 123 // tiles.push_back(tile); 118 124 //++z; 119 125 if (level == 1) { 120 126 //map 1 121 if ( i == 10&& j == 4 )127 if ( i == 9 && j == 4 ) 122 128 wayPoints.at(0) = tile; 123 129 124 if ( i == 0 && j == 0)130 if ( i == 0 && j == 1) 125 131 wayPoints.at(1) = tile; 126 132 if ( i == 10 && j == 7) … … 129 135 else if (level == 2) { 130 136 //map 2 131 if ( i == 2 4&& j == 11 )137 if ( i == 23 && j == 11 ) 132 138 wayPoints.at(0) = tile; 133 139 134 if ( i == 0 && j == 0)140 if ( i == 0 && j == 1) 135 141 wayPoints.at(1) = tile; 136 142 if ( i == 24 && j == 17) … … 151 157 152 158 } //firsttick end 153 /* 154 for (std::vector<OrxoKartTile*>::iterator it = tiles.begin(); it != tiles.end(); ++it ) { 155 if ((*it)->getCollided()) 156 tiles.erase(it); 157 } 158 if (tiles.empty()) 159 numberOfFlags_ = 0; 160 */ 159 161 160 if (wayPointCounter >= 3) 162 numberOfFlags_ = 0; 161 raceFinished = true; 162 163 163 else if (wayPointCounter < 3 && wayPointCounter >= 0 && wayPoints.at(wayPointCounter) != nullptr) { 164 164 if (wayPoints.at(wayPointCounter)->getCollided()) { … … 183 183 player->setPosition(Vector3(s*0, 20, s*8)); 184 184 if (level == 2) 185 player->setPosition(Vector3(s*0, 20, s*1 9));185 player->setPosition(Vector3(s*0, 20, s*18)); 186 186 player->setOrientation(Quaternion(1, 0, 0, 0)); // 0, 0, 0 187 187 player->setVelocity(Vector3(0,0,0)); … … 190 190 wayPointCounter = 0; 191 191 192 193 // flag_->destroyLater();194 // flags_.erase (flags_.begin()+i);195 //numberOfFlags_ = 0;196 192 } 197 193 -
code/branches/OrxoKart_HS18/src/modules/orxokart/OrxoKart.h
r12116 r12128 55 55 { this->origin_ = origin; } 56 56 57 inline int get NumberOfFlags() const58 { return this-> numberOfFlags_; }57 inline int getRaceFinished() const 58 { return this->raceFinished; } 59 59 60 60 private: … … 65 65 std::vector<OrxoKartTile*> wayPoints; 66 66 int wayPointCounter = 0; 67 int numberOfFlags_;67 bool raceFinished; 68 68 bool firstTick_; 69 69 -
code/branches/OrxoKart_HS18/src/modules/orxokart/OrxoKartTile.cc
r12111 r12128 81 81 type of tile. 1 for normal tile, 2 for Start/End tile 82 82 */ 83 void OrxoKartTile::init(int x, int z, int s, int type)83 void OrxoKartTile::init(int x, int z, int s, float r, int type) 84 84 { 85 85 // floor design according to its type … … 93 93 model_->setScale3D(Vector3(s*1.0f, 8.0f, s*1.0f)); 94 94 model_->setPosition(Vector3(x*1.0f, 0.0f, z*1.0f)); 95 model_->pitch(Degree(r)); 95 96 96 97 this->attach(model_); … … 101 102 cs_->setHalfExtents(Vector3(s/2.0f, 1.0f, s/2.0f)); 102 103 cs_->setPosition(Vector3(x*1.0f, -1.0f, z*1.0f)); 104 cs_->pitch(Degree(r)); 103 105 104 106 this->attachCollisionShape(cs_); -
code/branches/OrxoKart_HS18/src/modules/orxokart/OrxoKartTile.h
r12111 r12128 50 50 virtual ~OrxoKartTile(); 51 51 52 void init(int x, int z, int s, int type);52 void init(int x, int z, int s, float r, int type); 53 53 54 54 virtual bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) override; -
code/branches/OrxoKart_HS18/src/modules/orxokart/TimeHUD.cc
r12108 r12128 32 32 33 33 #include "TimeHUD.h" 34 35 #include <iostream> 36 #include <fstream> 37 #include "Highscore.h" 34 38 35 39 #include "core/CoreIncludes.h" … … 82 86 { 83 87 this->setCaption(getTimeString(this->time_)); 84 if (this->orxokartGame_->get NumberOfFlags() == 0)88 if (this->orxokartGame_->getRaceFinished()) { 85 89 setRunning(false); 90 if (!score_set) { 91 std::ofstream highscoreFile; 92 highscoreFile.open("orxokart_highscores.txt", std::ios::app); 93 highscoreFile << "Name: " << getTimeString(this->time_) << std::endl; 94 highscoreFile.close(); 95 score_set = true; 96 } 97 } 86 98 } 87 99 -
code/branches/OrxoKart_HS18/src/modules/orxokart/TimeHUD.h
r12074 r12128 34 34 35 35 #include "OrxoKartPrereqs.h" 36 #include <iostream> 37 #include <fstream> 36 38 37 39 #include "tools/interfaces/Tickable.h" … … 61 63 float time_; 62 64 bool running_; 65 bool score_set = false; 63 66 }; 64 67 }
Note: See TracChangeset
for help on using the changeset viewer.