Changeset 10111 for code/branches/pickupsFS14/src/modules/jump/Jump.cc
- Timestamp:
- Nov 5, 2014, 4:06:09 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/pickupsFS14/src/modules/jump/Jump.cc
r10074 r10111 21 21 * 22 22 * Author: 23 * Fabi an 'x3n' Landau23 * Fabien Vultier 24 24 * Co-authors: 25 25 * ... … … 29 29 /** 30 30 @file Jump.cc 31 @brief Implementation of the Jump class.31 @brief This is the gametype for the awesome minigame. Here the level is randomly created, the camera is shifted, ... 32 32 */ 33 33 34 34 #include "Jump.h" 35 36 35 #include "core/CoreIncludes.h" 37 36 #include "core/EventIncludes.h" 38 37 #include "core/command/Executor.h" 39 38 #include "core/config/ConfigValueIncludes.h" 40 41 39 #include "gamestates/GSLevel.h" 42 40 #include "chat/ChatManager.h" 43 44 41 #include "JumpCenterpoint.h" 45 42 #include "JumpPlatform.h" … … 59 56 #include "JumpBoots.h" 60 57 #include "JumpShield.h" 61 62 58 #include "infos/PlayerInfo.h" 63 59 64 60 namespace orxonox 65 61 { 66 // Events to allow to react to scoring of a player, in the level-file.67 CreateEventName(JumpCenterpoint, right);68 CreateEventName(JumpCenterpoint, left);69 70 62 RegisterUnloadableClass(Jump); 71 63 72 /**73 @brief74 Constructor. Registers and initializes the object.75 */76 64 Jump::Jump(Context* context) : Deathmatch(context) 77 65 { … … 81 69 figure_ = 0; 82 70 camera = 0; 83 84 71 setHUDTemplate("JumpHUD"); 85 72 86 scoreLimit_ = 10;87 73 setConfigValues(); 88 74 } 89 75 90 /**91 @brief92 Destructor. Cleans up, if initialized.93 */94 76 Jump::~Jump() 95 77 { … … 103 85 { 104 86 SUPER(Jump, tick, dt); 87 105 88 if (figure_ != NULL) 106 89 { … … 108 91 Vector3 figureVelocity = figure_->getVelocity(); 109 92 110 float boundary = totalScreenShift +center_->getCameraOffset();93 float boundary = totalScreenShift_+center_->getCameraOffset(); 111 94 112 95 if (figurePosition.z > boundary) 113 96 { 114 screenShiftSinceLastUpdate += figurePosition.z - boundary;115 totalScreenShift = figurePosition.z - center_->getCameraOffset();116 117 // Falls noetig neue Platformen im neuen Bereich einfuegen118 if (screenShiftSinceLastUpdate > center_->getSectionLength())97 screenShiftSinceLastUpdate_ += figurePosition.z - boundary; 98 totalScreenShift_ = figurePosition.z - center_->getCameraOffset(); 99 100 // Create new platforms if needed 101 if (screenShiftSinceLastUpdate_ > center_->getSectionLength()) 119 102 { 120 screenShiftSinceLastUpdate -= center_->getSectionLength(); 121 if (sectionNumber_ > 2 && sectionNumber_%4 == 0 && rand()%2 == 0) 103 if (sectionNumber_ > 2 && sectionNumber_%4 == 0 && rand()%2 == 0 && figure_->propellerActive_ == false && figure_->rocketActive_ == false && addAdventure(adventureNumber_) == true) 122 104 { 123 if (addAdventure(adventureNumber_) == false) 124 { 125 addSection(); 126 } 127 else 128 { 129 ++ adventureNumber_; 130 } 105 screenShiftSinceLastUpdate_ -= 2*center_->getSectionLength(); 106 ++ adventureNumber_; 131 107 } 132 108 else 133 109 { 110 screenShiftSinceLastUpdate_ -= center_->getSectionLength(); 134 111 addSection(); 135 112 } … … 137 114 } 138 115 139 // Spiel verloren wegen Ansturz? 140 if (figurePosition.z < totalScreenShift - center_->getFieldDimension().y + platformHeight_ && figureVelocity.z < 0) 116 if (figurePosition.z < totalScreenShift_ - center_->getFieldDimension().y + platformHeight_ && figureVelocity.z < 0) 141 117 { 142 end();118 figure_->dead_ = true; 143 119 } 144 120 145 // Schiessen 146 147 if (figure_->fireSignal) 121 if (figure_->fireSignal_ == true) 148 122 { 149 figure_->fireSignal = false; 150 addProjectile(figurePosition.x, figurePosition.z + figure_->getPropellerPos()); 123 if (figure_->dead_ == true) 124 { 125 end(); 126 } 127 else 128 { 129 figure_->fireSignal_ = false; 130 addProjectile(figurePosition.x, figurePosition.z + figure_->getPropellerPos()); 131 } 151 132 } 152 133 … … 154 135 if (camera != NULL) 155 136 { 156 Vector3 cameraPosition = Vector3(0, totalScreenShift , 0);137 Vector3 cameraPosition = Vector3(0, totalScreenShift_, 0); 157 138 camera->setPosition(cameraPosition); 158 139 } … … 160 141 { 161 142 orxout() << "No camera found." << endl; 162 //camera = figure_->getCamera();163 143 } 164 144 } 165 else 166 { 167 //orxout() << "No figure found." << endl; 168 } 169 170 // Platformen, die zu weit unten sind entfernen 145 171 146 ObjectList<JumpPlatform>::iterator beginPlatform = ObjectList<JumpPlatform>::begin(); 172 147 ObjectList<JumpPlatform>::iterator endPlatform = ObjectList<JumpPlatform>::end(); … … 177 152 { 178 153 platformPosition = itPlatform->getPosition(); 179 if (platformPosition.z < totalScreenShift - center_->getFieldDimension().y)154 if (platformPosition.z < totalScreenShift_ - center_->getFieldDimension().y) 180 155 { 181 156 ObjectList<JumpPlatform>::iterator temp = itPlatform; … … 190 165 } 191 166 192 // DAS GEHT NICHT!!! it++ funktioniert nicht, falls eine Platform geloescht wurde -> Segmentation Error 193 /* 194 for (ObjectList<JumpPlatformDisappear>::iterator it = ObjectList<JumpPlatformDisappear>::begin(); orxout() << "E" << endl, it != ObjectList<JumpPlatformDisappear>::end(); orxout() << "F" << endl, ++it) 195 { 196 if (!it->isActive()) 197 { 198 // Entferne Platform 199 center_->detach(*it); 200 it->destroy(); 201 } 202 } 203 */ 204 205 // Deaktivierte Platformen entfernen 167 // Deleted deactivated platforms 206 168 ObjectList<JumpPlatformDisappear>::iterator beginDisappear = ObjectList<JumpPlatformDisappear>::begin(); 207 169 ObjectList<JumpPlatformDisappear>::iterator endDisappear = ObjectList<JumpPlatformDisappear>::end(); … … 223 185 } 224 186 225 // Abgelaufene Timer-Platformen entfernen226 187 ObjectList<JumpPlatformTimer>::iterator beginTimer = ObjectList<JumpPlatformTimer>::begin(); 227 188 ObjectList<JumpPlatformTimer>::iterator endTimer = ObjectList<JumpPlatformTimer>::end(); … … 243 204 } 244 205 245 // Projektile, die zu weit oben sind entfernen246 206 ObjectList<JumpProjectile>::iterator beginProjectile = ObjectList<JumpProjectile>::begin(); 247 207 ObjectList<JumpProjectile>::iterator endProjectile = ObjectList<JumpProjectile>::end(); … … 252 212 { 253 213 projectilePosition = itProjectile->getPosition(); 254 if (projectilePosition.z > totalScreenShift + 5*center_->getFieldDimension().y)214 if (projectilePosition.z > totalScreenShift_ + 5*center_->getFieldDimension().y) 255 215 { 256 216 ObjectList<JumpProjectile>::iterator temp = itProjectile; … … 265 225 } 266 226 267 // Gegner, die zu weit unten oder abgeschossen sind entfernen268 227 ObjectList<JumpEnemy>::iterator beginEnemy = ObjectList<JumpEnemy>::begin(); 269 228 ObjectList<JumpEnemy>::iterator endEnemy = ObjectList<JumpEnemy>::end(); … … 274 233 { 275 234 enemyPosition = itEnemy->getPosition(); 276 if (enemyPosition.z < totalScreenShift - center_->getFieldDimension().y || itEnemy->dead_ == true)235 if (enemyPosition.z < totalScreenShift_ - center_->getFieldDimension().y || itEnemy->dead_ == true) 277 236 { 278 237 ObjectList<JumpEnemy>::iterator temp = itEnemy; … … 287 246 } 288 247 289 // Items, die zu weit unten sind entfernen290 248 ObjectList<JumpItem>::iterator beginItem = ObjectList<JumpItem>::begin(); 291 249 ObjectList<JumpItem>::iterator endItem = ObjectList<JumpItem>::end(); … … 299 257 WorldEntity* parent = itItem->getParent(); 300 258 301 if (itItem->attachedToFigure_ == false && itemPosition.z < totalScreenShift - center_->getFieldDimension().y && parent == center_)259 if (itItem->attachedToFigure_ == false && itemPosition.z < totalScreenShift_ - center_->getFieldDimension().y && parent == center_) 302 260 { 303 261 ObjectList<JumpItem>::iterator temp = itItem; … … 313 271 } 314 272 315 void Jump::setConfigValues()316 {317 SetConfigValue(scoreLimit_, 10).description("The player first reaching those points wins.");318 }319 320 /**321 @brief322 Cleans up the Gametype by destroying the ball and the bats.323 */324 273 void Jump::cleanup() 325 274 { 326 if (figure_ != NULL)327 {328 //this->figure_->destroy();329 //this->figure_ = 0;330 }331 275 camera = 0; 332 276 } … … 354 298 } 355 299 356 // Set variable to temporarily force the player to spawn.357 bool temp = bForceSpawn_;358 bForceSpawn_ = true;359 360 300 // Call start for the parent class. 361 301 Deathmatch::start(); 362 363 // Reset the variable.364 bForceSpawn_ = temp;365 302 366 303 if (figure_ != NULL) … … 369 306 } 370 307 371 totalScreenShift = 0.0;372 screenShiftSinceLastUpdate = 0.0;308 totalScreenShift_ = 0.0; 309 screenShiftSinceLastUpdate_ = 0.0; 373 310 sectionNumber_ = 0; 374 311 adventureNumber_ = 0; … … 379 316 } 380 317 381 /**382 @brief383 Ends the Jump minigame.384 */385 318 void Jump::end() 386 319 { … … 388 321 GSLevel::startMainMenu(); 389 322 390 // Call end for the parent class.391 323 Deathmatch::end(); 392 324 } 393 325 394 /**395 @brief396 Spawns the input player.397 @param player398 The player to be spawned.399 */400 326 void Jump::spawnPlayer(PlayerInfo* player) 401 327 { 402 328 assert(player); 403 329 404 // If the first (left) bat has no player. 405 if (this->figure_->getPlayer() == NULL) 330 if (figure_->getPlayer() == NULL) 406 331 { 407 player->startControl( this->figure_);408 this->players_[player].state_ = PlayerState::Alive;332 player->startControl(figure_); 333 players_[player].state_ = PlayerState::Alive; 409 334 } 410 335 } 411 336 412 /**413 @brief414 Is called when the player scored.415 */416 void Jump::playerScored(PlayerInfo* player, int score)417 {418 419 }420 421 /**422 @brief423 Starts the ball with some default speed.424 */425 void Jump::startBall()426 {427 428 }429 430 /**431 @brief432 Get the left player.433 @return434 Returns a pointer to the player playing on the left. If there is no left player, NULL is returned.435 */436 337 PlayerInfo* Jump::getPlayer() const 437 338 { … … 494 395 JumpPlatformTimer* Jump::addPlatformTimer(float xPosition, float zPosition, float time, float variance) 495 396 { 496 float additionalTime = (float)(rand()%100)/ (100*variance) - variance/2;397 float additionalTime = (float)(rand()%100)/100.0*variance - variance/2.0; 497 398 498 399 JumpPlatformTimer* newPlatform = new JumpPlatformTimer(center_->getContext()); … … 752 653 } 753 654 else if (rand()%2 == 0 && sectionNumber_ > 3) 754 switch(rand()%4) 755 { 756 case 0: 757 itemType = ITEM_PROPELLER; 758 break; 759 case 1: 760 itemType = ITEM_ROCKET; 761 break; 762 case 2: 763 itemType = ITEM_BOOTS; 764 break; 765 case 3: 766 itemType = ITEM_SHIELD; 767 break; 768 default: 769 break; 770 } 655 { 656 switch(rand()%4) 657 { 658 case 0: 659 itemType = ITEM_PROPELLER; 660 break; 661 case 1: 662 itemType = ITEM_ROCKET; 663 break; 664 case 2: 665 itemType = ITEM_BOOTS; 666 break; 667 case 3: 668 itemType = ITEM_SHIELD; 669 break; 670 default: 671 break; 672 } 673 } 771 674 772 675 switch((sectionNumber_ > 28) ? rand()%29 : rand()%(sectionNumber_+1)) … … 894 797 } 895 798 896 // Fill Matrix with selected platform types799 // Fill matrix with selected platform types 897 800 for (int i = 0; i < numI; ++ i) 898 801 { 899 802 for (int j = 0; j < numJ; ++ j) 900 803 { 901 if (rand()% (sectionNumber_+1)== 0)804 if (rand()%3 == 0) 902 805 { 903 806 matrix[i][j].type = platformtype1; … … 911 814 } 912 815 913 // Delete some platforms or replace them with fake platforms 914 if (platformtype1 == platformtype2 && sectionNumber_ > 10) 816 if (platformtype1 == platformtype2 && sectionNumber_ > 10 && rand()%2 == 0) 915 817 { 916 int j = rand()%numJ; 917 if (rand()%2 == 0) 918 { 919 for (int i = 0; i <= j; ++ i) 920 { 921 matrix[rand()%numI][rand()%numJ].type = PLATFORM_EMPTY; 922 } 923 } 924 else 925 { 926 for (int i = 0; i <= j; ++ i) 927 { 928 matrix[rand()%numI][rand()%numJ].type = PLATFORM_FAKE; 929 } 930 } 818 matrix[rand()%numI][rand()%numJ].type = PLATFORM_EMPTY; 819 matrix[rand()%numI][rand()%numJ].type = PLATFORM_EMPTY; 820 } 821 822 // Delete some planned platforms or replace them with fake platforms 823 if (sectionNumber_ > 5) 824 { 825 if (rand()%2 == 0) 826 { 827 matrix[rand()%numI][rand()%numJ].type = PLATFORM_EMPTY; 828 } 829 else 830 { 831 matrix[rand()%numI][rand()%numJ].type = PLATFORM_FAKE; 832 } 833 } 834 else if (sectionNumber_ > 10) 835 { 836 if (rand()%2 == 0) 837 { 838 matrix[rand()%numI][rand()%numJ].type = PLATFORM_EMPTY; 839 } 840 else 841 { 842 matrix[rand()%numI][rand()%numJ].type = PLATFORM_FAKE; 843 } 844 if (rand()%2 == 0) 845 { 846 matrix[rand()%numI][rand()%numJ].type = PLATFORM_EMPTY; 847 } 848 else 849 { 850 matrix[rand()%numI][rand()%numJ].type = PLATFORM_FAKE; 851 } 852 } 853 else if (sectionNumber_ > 15) 854 { 855 if (rand()%2 == 0) 856 { 857 matrix[rand()%numI][rand()%numJ].type = PLATFORM_EMPTY; 858 } 859 else 860 { 861 matrix[rand()%numI][rand()%numJ].type = PLATFORM_FAKE; 862 } 863 if (rand()%2 == 0) 864 { 865 matrix[rand()%numI][rand()%numJ].type = PLATFORM_EMPTY; 866 } 867 else 868 { 869 matrix[rand()%numI][rand()%numJ].type = PLATFORM_FAKE; 870 } 871 if (rand()%2 == 0) 872 { 873 matrix[rand()%numI][rand()%numJ].type = PLATFORM_EMPTY; 874 } 875 else 876 { 877 matrix[rand()%numI][rand()%numJ].type = PLATFORM_FAKE; 878 } 931 879 } 932 880 … … 968 916 xPosition = randomXPosition(numJ, j); 969 917 zPosition = sectionBegin + i*sectionLength/numI; 970 platformList.push_back(addPlatformTimer(xPosition, zPosition, 1 0.0, 1.5));918 platformList.push_back(addPlatformTimer(xPosition, zPosition, 12.0, 1.5)); 971 919 matrix[i][j].done = true; 972 920 break; … … 1044 992 break; 1045 993 default: 1046 // 994 //ERROR 1047 995 break; 1048 996 1049 997 } 1050 1051 /*if (platformtype1 != PLATFORM_TIMER && platformtype2 != PLATFORM_TIMER)1052 {1053 switch (itemType)1054 {1055 case ITEM_SPRING:1056 addSpring(xPosition, zPosition, leftBoundary, rightBoundary, lowerBoundary, upperBoundary, xVelocity, zVelocity);1057 itemType = ITEM_NOTHING;1058 break;1059 case ITEM_ROCKET:1060 addRocket(xPosition, zPosition, leftBoundary, rightBoundary, lowerBoundary, upperBoundary, xVelocity, zVelocity);1061 itemType = ITEM_NOTHING;1062 break;1063 case ITEM_PROPELLER:1064 addPropeller(xPosition, zPosition, leftBoundary, rightBoundary, lowerBoundary, upperBoundary, xVelocity, zVelocity);1065 itemType = ITEM_NOTHING;1066 break;1067 case ITEM_BOOTS:1068 addBoots(xPosition, zPosition, leftBoundary, rightBoundary, lowerBoundary, upperBoundary, xVelocity, zVelocity);1069 itemType = ITEM_NOTHING;1070 break;1071 case ITEM_SHIELD:1072 addShield(xPosition, zPosition, leftBoundary, rightBoundary, lowerBoundary, upperBoundary, xVelocity, zVelocity);1073 itemType = ITEM_NOTHING;1074 break;1075 default:1076 // ERROR1077 break;1078 }1079 }*/1080 998 } 1081 999 } … … 1085 1003 int numNewPlatforms = platformList.size(); 1086 1004 1087 if ( numNewPlatforms >0)1005 if (rand()%4 == 0) 1088 1006 { 1089 JumpPlatform* itemPlatform = platformList[rand()%numNewPlatforms]; 1090 1091 switch (ITEM_BOOTS) 1092 { 1093 case ITEM_SPRING: 1094 addSpring(itemPlatform); 1095 break; 1096 case ITEM_ROCKET: 1097 addRocket(itemPlatform); 1098 break; 1099 case ITEM_PROPELLER: 1100 addPropeller(itemPlatform); 1101 break; 1102 case ITEM_BOOTS: 1103 addBoots(itemPlatform); 1104 break; 1105 case ITEM_SHIELD: 1106 addShield(itemPlatform); 1107 break; 1108 default: 1109 break; 1110 } 1007 if (rand()%2 == 0) 1008 { 1009 switch (itemType) 1010 { 1011 case ITEM_ROCKET: 1012 addRocket(0.0, randomPosition(sectionBegin, sectionBegin + sectionLength), -fieldWidth/2, fieldWidth/2, 0.0, 0.0, randomSpeed(), 0.0); 1013 break; 1014 case ITEM_PROPELLER: 1015 addPropeller(0.0, randomPosition(sectionBegin, sectionBegin + sectionLength), -fieldWidth/2, fieldWidth/2, 0.0, 0.0, randomSpeed(), 0.0); 1016 break; 1017 case ITEM_BOOTS: 1018 addBoots(0.0, randomPosition(sectionBegin, sectionBegin + sectionLength), -fieldWidth/2, fieldWidth/2, 0.0, 0.0, randomSpeed(), 0.0); 1019 break; 1020 case ITEM_SHIELD: 1021 addShield(0.0, randomPosition(sectionBegin, sectionBegin + sectionLength), -fieldWidth/2, fieldWidth/2, 0.0, 0.0, randomSpeed(), 0.0); 1022 break; 1023 default: 1024 break; 1025 } 1026 } 1027 else 1028 { 1029 switch (itemType) 1030 { 1031 case ITEM_ROCKET: 1032 addRocket(randomPosition(-fieldWidth/2, fieldWidth/2), sectionBegin + sectionLength/2, 0.0, 0.0, sectionBegin, sectionEnd, 0.0, randomSpeed()); 1033 break; 1034 case ITEM_PROPELLER: 1035 addPropeller(randomPosition(-fieldWidth/2, fieldWidth/2), sectionBegin + sectionLength/2, 0.0, 0.0, sectionBegin, sectionEnd, 0.0, randomSpeed()); 1036 break; 1037 case ITEM_BOOTS: 1038 addBoots(randomPosition(-fieldWidth/2, fieldWidth/2), sectionBegin + sectionLength/2, 0.0, 0.0, sectionBegin, sectionEnd, 0.0, randomSpeed()); 1039 break; 1040 case ITEM_SHIELD: 1041 addShield(randomPosition(-fieldWidth/2, fieldWidth/2), sectionBegin + sectionLength/2, 0.0, 0.0, sectionBegin, sectionEnd, 0.0, randomSpeed()); 1042 break; 1043 default: 1044 break; 1045 } 1046 } 1047 } 1048 else 1049 { 1050 if (numNewPlatforms > 0) 1051 { 1052 JumpPlatform* itemPlatform = platformList[rand()%numNewPlatforms]; 1053 1054 switch (itemType) 1055 { 1056 case ITEM_SPRING: 1057 addSpring(itemPlatform); 1058 break; 1059 case ITEM_ROCKET: 1060 addRocket(itemPlatform); 1061 break; 1062 case ITEM_PROPELLER: 1063 addPropeller(itemPlatform); 1064 break; 1065 case ITEM_BOOTS: 1066 addBoots(itemPlatform); 1067 break; 1068 case ITEM_SHIELD: 1069 addShield(itemPlatform); 1070 break; 1071 default: 1072 break; 1073 } 1074 } 1111 1075 } 1112 1076 1113 1077 if (sectionNumber_ >= 5 && rand()%3 == 0) 1114 1078 { 1115 // BEWEGUNG Verbessern, Grenzen anpassen !!!!!!!! Auch Vertikale Bewegung zulassen1116 1117 1118 1079 switch(rand()%4) 1119 1080 { 1120 1081 case 0: 1121 addEnemy(1, randomXPosition(), randomPosition(sectionBegin, sectionBegin + sectionLength), -fieldWidth , fieldWidth, sectionBegin, sectionBegin + sectionLength, 5.0, 0.0);1082 addEnemy(1, randomXPosition(), randomPosition(sectionBegin, sectionBegin + sectionLength), -fieldWidth/3*2, fieldWidth/3*2, sectionBegin, sectionBegin + sectionLength, randomSpeed(), 0.0); 1122 1083 break; 1123 1084 case 1: 1124 addEnemy(2, randomXPosition(), randomPosition(sectionBegin, sectionBegin + sectionLength), -fieldWidth , fieldWidth, sectionBegin, sectionBegin + sectionLength, 5.0, 0.0);1085 addEnemy(2, randomXPosition(), randomPosition(sectionBegin, sectionBegin + sectionLength), -fieldWidth/3*2, fieldWidth/3*2, sectionBegin, sectionBegin + sectionLength, randomSpeed(), 0.0); 1125 1086 break; 1126 1087 case 2: 1127 addEnemy(3, randomXPosition(), randomPosition(sectionBegin, sectionBegin + sectionLength), -fieldWidth , fieldWidth, sectionBegin, sectionBegin + sectionLength, 5.0, 0.0);1088 addEnemy(3, randomXPosition(), randomPosition(sectionBegin, sectionBegin + sectionLength), -fieldWidth/3*2, fieldWidth/3*2, sectionBegin, sectionBegin + sectionLength, randomSpeed(), 0.0); 1128 1089 break; 1129 1090 case 3: 1130 addEnemy(4, randomXPosition(), randomPosition(sectionBegin, sectionBegin + sectionLength), -fieldWidth , fieldWidth, sectionBegin, sectionBegin + sectionLength, 5.0, 0.0);1091 addEnemy(4, randomXPosition(), randomPosition(sectionBegin, sectionBegin + sectionLength), -fieldWidth/3*2, fieldWidth/3*2, sectionBegin, sectionBegin + sectionLength, randomSpeed(), 0.0); 1131 1092 break; 1132 1093 } … … 1147 1108 { 1148 1109 int numI = 10; 1149 for (int i = 0; i < numI; ++ i)1110 if (rand()%2 == 0) 1150 1111 { 1151 addPlatformStatic((2*fieldWidth-platformWidth_)*i/numI-fieldWidth+platformWidth_/2, sectionBegin+i*sectionLength/numI); 1112 for (int i = 0; i < numI; ++ i) 1113 { 1114 addPlatformStatic((2*fieldWidth-platformWidth_)*i/numI-fieldWidth+platformWidth_/2, sectionBegin+i*sectionLength/numI); 1115 } 1116 } 1117 else 1118 { 1119 for (int i = 0; i < numI; ++ i) 1120 { 1121 addPlatformStatic((2*fieldWidth-platformWidth_)*i/numI-fieldWidth+platformWidth_/2, sectionBegin+(numI-i)*sectionLength/numI); 1122 } 1152 1123 } 1153 1124 break; … … 1158 1129 1159 1130 addPlatformStatic(0.0, sectionBegin); 1160 for (int i = 1; i < numI; ++ i) 1161 { 1162 addPlatformStatic((fieldWidth-platformWidth_/2)*i/numI, sectionBegin+i*sectionLength/numI); 1163 addPlatformStatic(-(fieldWidth-platformWidth_/2)*i/numI, sectionBegin+i*sectionLength/numI); 1131 if (rand()%2 == 0) 1132 { 1133 for (int i = 1; i < numI; ++ i) 1134 { 1135 addPlatformStatic((fieldWidth-platformWidth_/2)*i/numI, sectionBegin+i*sectionLength/numI); 1136 addPlatformStatic(-(fieldWidth-platformWidth_/2)*i/numI, sectionBegin+i*sectionLength/numI); 1137 } 1138 } 1139 else 1140 { 1141 for (int i = 1; i < numI; ++ i) 1142 { 1143 addPlatformStatic((fieldWidth-platformWidth_/2)*i/numI, sectionBegin+(numI-i)*sectionLength/numI); 1144 addPlatformStatic(-(fieldWidth-platformWidth_/2)*i/numI, sectionBegin+(numI-i)*sectionLength/numI); 1145 } 1164 1146 } 1165 1147 break; … … 1168 1150 { 1169 1151 int numI = 5; 1170 for (int i = 0; i < numI; ++ i)1152 for (int i = 0; i <= numI; ++ i) 1171 1153 { 1172 addPlatformStatic((2*fieldWidth-platformWidth_)*i/numI-fieldWidth +platformWidth_/2, sectionBegin);1173 addPlatformStatic((2*fieldWidth-platformWidth_)*i/numI-fieldWidth +platformWidth_/2, sectionBegin+sectionLength/5);1174 addPlatformStatic((2*fieldWidth-platformWidth_)*i/numI-fieldWidth +platformWidth_/2, sectionBegin+sectionLength*2/5);1175 addPlatformStatic((2*fieldWidth-platformWidth_)*i/numI-fieldWidth +platformWidth_/2, sectionBegin+sectionLength*3/5);1176 addPlatformStatic((2*fieldWidth-platformWidth_)*i/numI-fieldWidth +platformWidth_/2, sectionBegin+sectionLength*4/5);1154 addPlatformStatic((2*fieldWidth-platformWidth_)*i/numI-fieldWidth, sectionBegin); 1155 addPlatformStatic((2*fieldWidth-platformWidth_)*i/numI-fieldWidth, sectionBegin+sectionLength/5); 1156 addPlatformStatic((2*fieldWidth-platformWidth_)*i/numI-fieldWidth, sectionBegin+sectionLength*2/5); 1157 addPlatformStatic((2*fieldWidth-platformWidth_)*i/numI-fieldWidth, sectionBegin+sectionLength*3/5); 1158 addPlatformStatic((2*fieldWidth-platformWidth_)*i/numI-fieldWidth, sectionBegin+sectionLength*4/5); 1177 1159 addEnemy(4, (2*fieldWidth-platformWidth_)*i/numI-fieldWidth+platformWidth_/2, sectionBegin+sectionLength/2, -fieldWidth, fieldWidth, sectionBegin, sectionBegin + sectionLength, 0.0, 0.0); 1178 1160 } 1161 break; 1162 } 1163 case 3: 1164 { 1165 addRocket(addPlatformStatic(0.0, sectionBegin)); 1166 addEnemy(2, 0.0, sectionBegin+sectionLength/5, 0.0,0.0, 0.0, 0.0, 0.0, 0.0); 1167 break; 1168 } 1169 case 4: 1170 { 1171 addPropeller(addPlatformStatic(0.0, sectionBegin)); 1172 addPropeller(addPlatformStatic(-fieldWidth/2, sectionBegin)); 1173 addPropeller(addPlatformStatic(fieldWidth/2, sectionBegin)); 1179 1174 break; 1180 1175 } … … 1195 1190 float Jump::randomXPosition(int totalColumns, int culomn) 1196 1191 { 1197 float fieldWidth = center_->getFieldDimension().x; //Width of the half field1198 1199 float halfWidth = fieldWidth/totalColumns; //Width of a half column1200 float leftBound = culomn*halfWidth*2-fieldWidth; //Left beginning of the column1192 float fieldWidth = center_->getFieldDimension().x; 1193 1194 float halfWidth = fieldWidth/totalColumns; 1195 float leftBound = culomn*halfWidth*2-fieldWidth; 1201 1196 float rightBound = leftBound + 2*halfWidth; 1202 1197 … … 1206 1201 float Jump::randomXPositionLeft(int totalColumns, int culomn) 1207 1202 { 1208 float fieldWidth = center_->getFieldDimension().x; //Width of the half field1209 1210 float halfWidth = fieldWidth/totalColumns; //Width of a half column1211 float leftBound = culomn*halfWidth*2-fieldWidth; //LeftBeginning of the column1203 float fieldWidth = center_->getFieldDimension().x; 1204 1205 float halfWidth = fieldWidth/totalColumns; 1206 float leftBound = culomn*halfWidth*2-fieldWidth; 1212 1207 float rightBound = leftBound + 2*halfWidth/3; 1213 1208 … … 1217 1212 float Jump::randomXPositionRight(int totalColumns, int culomn) 1218 1213 { 1219 float fieldWidth = center_->getFieldDimension().x; //Width of the half field1220 1221 float halfWidth = fieldWidth/totalColumns; //Width of a half column1214 float fieldWidth = center_->getFieldDimension().x; 1215 1216 float halfWidth = fieldWidth/totalColumns; 1222 1217 float rightBound = (culomn+1)*halfWidth*2-fieldWidth; 1223 1218 float leftBound = rightBound - 2*halfWidth/3; … … 1227 1222 float Jump::randomZPosition(int totalRows, int row, float sectionBegin, float SectionEnd) 1228 1223 { 1229 float fieldHeight = SectionEnd - sectionBegin; //Heigt of the half field1230 float halfHeight = fieldHeight/totalRows; //Height of a half row1231 float lowerBound = row*halfHeight*2+sectionBegin; //Lower beginning of the row1224 float fieldHeight = SectionEnd - sectionBegin; 1225 float halfHeight = fieldHeight/totalRows; 1226 float lowerBound = row*halfHeight*2+sectionBegin; 1232 1227 float upperBound = lowerBound + 2*halfHeight; 1233 1228 … … 1237 1232 float Jump::randomZPositionLower(int totalRows, int row, float sectionBegin, float SectionEnd) 1238 1233 { 1239 float fieldHeight = SectionEnd - sectionBegin; //Heigt of the half field1240 float rowHeight = fieldHeight/totalRows; //Height of a row1241 float lowerBound = row*rowHeight+sectionBegin; //Lower beginning of the row1234 float fieldHeight = SectionEnd - sectionBegin; 1235 float rowHeight = fieldHeight/totalRows; 1236 float lowerBound = row*rowHeight+sectionBegin; 1242 1237 float upperBound = lowerBound + rowHeight/3; 1243 1238 … … 1247 1242 float Jump::randomZPositionUpper(int totalRows, int row, float sectionBegin, float SectionEnd) 1248 1243 { 1249 float fieldHeight = SectionEnd - sectionBegin; //Heigt of the half field1250 float rowHeight = fieldHeight/totalRows; //Height of a row1251 float lowerBound = (row+1)*rowHeight+sectionBegin; //Upper end of the row1244 float fieldHeight = SectionEnd - sectionBegin; 1245 float rowHeight = fieldHeight/totalRows; 1246 float lowerBound = (row+1)*rowHeight+sectionBegin; 1252 1247 float upperBound = lowerBound - rowHeight/3; 1253 1248
Note: See TracChangeset
for help on using the changeset viewer.