Changeset 10041
- Timestamp:
- Apr 22, 2014, 5:32:37 PM (11 years ago)
- Location:
- code/branches/pickupsFS14/src
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/pickupsFS14/src/modules/jump/CMakeLists.txt
r10040 r10041 3 3 Jump.cc 4 4 JumpPlatform.cc 5 JumpPlatformStatic.cc 5 6 JumpPlatformHMove.cc 6 7 JumpPlatformVMove.cc -
code/branches/pickupsFS14/src/modules/jump/Jump.cc
r10040 r10041 44 44 #include "JumpCenterpoint.h" 45 45 #include "JumpPlatform.h" 46 #include "JumpPlatformStatic.h" 47 #include "JumpPlatformHMove.h" 48 #include "JumpPlatformVMove.h" 46 49 #include "JumpFigure.h" 47 50 … … 65 68 66 69 this->center_ = 0; 67 this->ball_ = 0;68 70 this->figure_ = 0; 69 71 this->camera = 0; 70 72 71 //this->setHUDTemplate("JumpHUD"); 73 platformList.clear(); 74 75 this->setHUDTemplate("JumpHUD"); 72 76 73 77 // Pre-set the timer, but don't start it yet. … … 99 103 { 100 104 Vector3 figurePosition = figure_->getPosition(); 105 Vector3 figureVelocity = figure_->getVelocity(); 101 106 102 107 if (figurePosition.z > totalScreenShift) 103 108 { 109 screenShiftSinceLastUpdate += figurePosition.z - totalScreenShift; 104 110 totalScreenShift = figurePosition.z; 111 112 // Falls noetig neue Platformen im neuen Bereich einfuegen 113 if (screenShiftSinceLastUpdate > sectionLength) 114 { 115 screenShiftSinceLastUpdate -= sectionLength; 116 addSection(); 117 } 105 118 } 106 119 120 // Spiel verloren wegen Ansturz? 121 if (figurePosition.z < totalScreenShift - center_->getFieldDimension().y && figureVelocity.z < 0) 122 { 123 end(); 124 } 125 126 107 127 if (this->camera != NULL) 108 128 { 109 Vector3 cameraPosition = Vector3(0, totalScreenShift,0);129 Vector3 cameraPosition = Vector3(0, totalScreenShift, 0); 110 130 camera->setPosition(cameraPosition); 111 131 } 112 132 else 113 133 { 114 orxout() << " no camera found" << endl;134 orxout() << "No camera found." << endl; 115 135 //this->camera = this->figure_->getCamera(); 116 136 } 117 137 } 118 119 120 121 122 138 else 139 { 140 //orxout() << "No figure found." << endl; 141 } 142 143 // Platformen, die zu weit unten sind entfernen 144 Vector3 platformPosition; 145 for (std::list<JumpPlatform*>::iterator it = platformList.begin(); it != platformList.end(); it++) 146 { 147 // IDEE: Statt durch alle platformen in der Liste, wie im Tutorial durch alle objekte im Spiel iterieren --> eigene liste unnoetig 148 platformPosition = (**it).getPosition(); 149 if (platformPosition.z < totalScreenShift - center_->getFieldDimension().y) 150 { 151 // Entferne Platform 152 orxout() << "position = " << (**it).getPosition().y << endl; 153 center_->detach(*it); 154 it = platformList.erase(it); 155 } 156 } 123 157 } 124 158 … … 135 169 void Jump::cleanup() 136 170 { 137 if (this->ball_ != NULL) // Destroy the ball, if present.171 /*if (this->ball_ != NULL) // Destroy the ball, if present. 138 172 { 139 173 this->ball_->destroy(); 140 174 this->ball_ = 0; 141 } 175 }*/ 142 176 143 177 // Destroy both bats, if present. … … 158 192 if (this->center_ != NULL) // There needs to be a JumpCenterpoint, i.e. the area the game takes place. 159 193 { 160 if (this->ball_ == NULL) // If there is no ball, create a new ball. 161 { 162 this->ball_ = new JumpPlatform(this->center_->getContext()); 163 // Apply the template for the ball specified by the centerpoint. 164 this->ball_->addTemplate(this->center_->getBalltemplate()); 165 } 194 166 195 167 196 // Attach the ball to the centerpoint and set the parameters as specified in the centerpoint, the ball is attached to. 168 this->center_->attach(this->ball_);197 /*this->center_->attach(this->ball_); 169 198 this->ball_->setPosition(0, 0, 0); 170 199 this->ball_->setFieldDimension(this->center_->getFieldDimension()); 200 201 // Set the bats for the ball. 202 this->ball_->setFigure(this->figure_); 203 */ 171 204 172 205 // If one of the bats is missing, create it. Apply the template for the bats as specified in the centerpoint. … … 185 218 this->figure_->setLength(this->center_->getBatLength()); 186 219 187 // Set the bats for the ball. 188 this->ball_->setFigure(this->figure_); 220 189 221 } 190 222 else // If no centerpoint was specified, an error is thrown and the level is exited. … … 214 246 215 247 totalScreenShift = 0.0; 248 screenShiftSinceLastUpdate = 0.0; 249 sectionNumber = 0; 250 sectionLength = 100.0; 251 252 addStartSection(); 253 addSection(); 254 addSection(); 216 255 } 217 256 … … 354 393 } 355 394 395 void Jump::addPlatform(JumpPlatform* newPlatform, float xPosition, float zPosition) 396 { 397 if (newPlatform != NULL) 398 { 399 newPlatform->setPosition(Vector3(xPosition, 0.0, zPosition)); 400 newPlatform->setFieldDimension(center_->getFieldDimension()); 401 newPlatform->setFigure(this->figure_); 402 center_->attach(newPlatform); 403 platformList.push_front(newPlatform); 404 } 405 } 406 407 void Jump::addStartSection() 408 { 409 JumpPlatform* newPlatform; 410 411 for (float xPosition = -center_->getFieldDimension().x; xPosition <= center_->getFieldDimension().x; xPosition += 12.0) 412 { 413 newPlatform = new JumpPlatformStatic(center_->getContext()); 414 addPlatform(newPlatform, xPosition, -0.05*sectionLength); 415 } 416 } 417 418 void Jump::addSection() 419 { 420 float fieldWidth = center_->getFieldDimension().x; 421 float fieldHeight = center_->getFieldDimension().y; 422 423 float sectionBegin = sectionNumber * sectionLength; 424 float sectionEnd = (1.0 + sectionNumber) * sectionLength; 425 426 JumpPlatformStatic* newPlatformStatic; 427 JumpPlatformHMove* newPlatformHMove; 428 JumpPlatformVMove* newPlatformVMove; 429 430 switch (rand()%3) 431 { 432 case 0: 433 for (int i = 0; i < 10; ++i) 434 { 435 newPlatformStatic = new JumpPlatformStatic(center_->getContext()); 436 addPlatform(newPlatformStatic, randomXPosition(), sectionBegin + i*sectionLength/10); 437 } 438 break; 439 case 1: 440 for (int i = 0; i < 10; ++i) 441 { 442 newPlatformHMove = new JumpPlatformHMove(center_->getContext()); 443 newPlatformHMove->setProperties(-fieldWidth, fieldWidth, 30.0); 444 addPlatform(newPlatformHMove, randomXPosition(), sectionBegin + i*sectionLength/10); 445 } 446 447 break; 448 case 2: 449 for (int i = 0; i < 10; ++i) 450 { 451 newPlatformVMove = new JumpPlatformVMove(center_->getContext()); 452 newPlatformVMove->setProperties(sectionBegin, sectionEnd, 20.0); 453 addPlatform(newPlatformVMove, -fieldWidth + i*fieldWidth*2/10, randomYPosition(sectionBegin, sectionEnd)); 454 } 455 break; 456 } 457 orxout() << "new section added with number "<< sectionNumber << endl; 458 459 ++ sectionNumber; 460 } 461 462 float Jump::randomXPosition() 463 { 464 return (float)(rand()%(2*(int)center_->getFieldDimension().x)) - center_->getFieldDimension().x; 465 } 466 467 float Jump::randomYPosition(float lowerBoundary, float upperBoundary) 468 { 469 return (float)(rand()%(int)(upperBoundary - lowerBoundary)) + lowerBoundary; 470 } 471 472 int Jump::getScore(PlayerInfo* player) const 473 { 474 return sectionNumber - 2; 475 } 476 356 477 } -
code/branches/pickupsFS14/src/modules/jump/Jump.h
r10040 r10041 44 44 #include "JumpCenterpoint.h" 45 45 46 #include <list> 47 46 48 namespace orxonox 47 49 { … … 78 80 virtual void playerScored(PlayerInfo* player, int score = 1); //!< Is called when the player scored. 79 81 82 virtual void addPlatform(JumpPlatform* newPlatform, float xPosition, float zPosition); 83 virtual void addStartSection(); 84 virtual void addSection(); 85 virtual float randomXPosition(); 86 virtual float randomYPosition(float lowerBoundary, float upperBoundary); 87 88 int getScore(PlayerInfo* player) const; 89 80 90 /** 81 91 @brief Set the JumpCenterpoint (the playing field). … … 95 105 96 106 WeakPtr<JumpCenterpoint> center_; //!< The playing field. 97 WeakPtr<JumpPlatform> ball_; //!< The Jump ball.107 //WeakPtr<JumpPlatform> ball_; //!< The Jump ball. 98 108 WeakPtr<JumpFigure> figure_; //!< The two bats. 99 109 WeakPtr<Camera> camera; … … 102 112 103 113 float totalScreenShift; 114 float screenShiftSinceLastUpdate; 115 float sectionLength; 116 int sectionNumber; 117 std::list<JumpPlatform*> platformList; 104 118 }; 105 119 } -
code/branches/pickupsFS14/src/modules/jump/JumpPlatform.cc
r10040 r10041 36 36 #include "core/CoreIncludes.h" 37 37 #include "core/GameMode.h" 38 38 #include "graphics/Model.h" 39 39 #include "gametypes/Gametype.h" 40 40 … … 86 86 this->setVelocity(Vector3(0,0,0)); 87 87 this->setAcceleration(Vector3(0,0,0)); 88 89 model = NULL; 88 90 } 89 91 … … 94 96 JumpPlatform::~JumpPlatform() 95 97 { 96 if (this->isInitialized())98 /*if (this->isInitialized()) 97 99 { 98 100 if (this->bDeleteBats_) … … 100 102 101 103 delete[] this->batID_; 102 } 104 }*/ 103 105 } 104 106 … … 137 139 138 140 Vector3 platformPosition = this->getPosition(); 139 Vector3 platformVelocity = this->getVelocity();140 141 141 142 if (figure_ != NULL) … … 149 150 } 150 151 } 152 153 151 154 152 155 -
code/branches/pickupsFS14/src/modules/jump/JumpPlatform.h
r10040 r10041 111 111 WorldSound* defScoreSound_; 112 112 WorldSound* defBatSound_; 113 Model* model; 113 114 WorldSound* defBoundarySound_; 114 115 }; -
code/branches/pickupsFS14/src/modules/jump/JumpPrereqs.h
r10040 r10041 70 70 class Jump; 71 71 class JumpPlatform; 72 class JumpPlatformStatic; 72 73 class JumpPlatformHMove; 74 class JumpPlatformVMove; 73 75 class JumpFigure; 74 76 class JumpCenterpoint; -
code/branches/pickupsFS14/src/orxonox/worldentities/WorldEntity.h
r9667 r10041 164 164 { this->scale3D(Vector3(x, y, z)); } 165 165 inline void scale(float scale) 166 166 167 { this->scale3D(scale, scale, scale); } 167 168 168 virtual void changedScale() {} 169 169
Note: See TracChangeset
for help on using the changeset viewer.