Changeset 11192 for code/branches/tgidronFS16/src/modules/hover
- Timestamp:
- May 19, 2016, 5:50:36 PM (9 years ago)
- Location:
- code/branches/tgidronFS16/src/modules/hover
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/tgidronFS16/src/modules/hover/Hover.cc
r11184 r11192 64 64 cellHeight = 0; 65 65 66 bShowLevel = false; 67 66 68 totFlags = 0; 67 69 … … 80 82 cellSize = this->origin_->getCellSize(); 81 83 cellHeight = this->origin_->getCellHeight(); 84 85 /* 86 bool occupiedCells[numCells][numCells]; 87 88 for(int i = 0; i < numCells; i++) 89 { 90 for(int j = 0; j < numCells; j++) 91 { 92 occupiedCells[i][j] = false; 93 } 94 } 95 occupiedCells[0][0] = true; 96 */ 82 97 83 98 MazeGenerator generator(numCells); … … 93 108 (new HoverWall(origin_->getContext()))->init(i+1, 0, cellSize, cellHeight, 2); 94 109 (new HoverWall(origin_->getContext()))->init(i+1, numCells, cellSize, cellHeight, 2); 110 } 111 112 113 //Ground 114 for(int i = 0; i<numCells; i++){ 115 for(int j = 0; j<numCells; j++){ 116 StaticEntity* groundCell = new StaticEntity(origin_->getContext()); 117 118 groundCell->addTemplate(origin_->getGroundTemplate()); 119 groundCell->setPosition(get3dCoordinates(i,j,-60)); 120 } 121 95 122 } 96 123 … … 112 139 } 113 140 114 //Generate 5 flags randomly (test only 1 flag) 141 createFlags(); 142 143 //Generate 3 PickupSpawners randomly (destroy hover pickup) 144 for (int i = 0; i<3; i++) 145 { 146 PickupSpawner* pickupSpawner = new PickupSpawner(origin_->getContext()); 147 148 pickupSpawner->setPosition(get3dCoordinates(rand()%numCells, rand()%numCells, 0.0f)); 149 pickupSpawner->setPickupTemplateName(origin_->getPickupTemplate()); 150 pickupSpawner->setMaxSpawnedItems(3); 151 pickupSpawner->setRespawnTime(30); 152 pickupSpawner->setTriggerDistance(40); 153 // Add pickup spawner to the pickup spawner list 154 pickupSpawners_.push_back(pickupSpawner); 155 } 156 157 //Generate 3 PickupSpawners randomly (speed pickup) 158 for (int i = 0; i<3; i++) 159 { 160 PickupSpawner* pickupSpawner = new PickupSpawner(origin_->getContext()); 161 162 pickupSpawner->setPosition(get3dCoordinates(rand()%numCells, rand()%numCells, 0.0f)); 163 pickupSpawner->setPickupTemplateName(origin_->getPickupTemplateSpeed()); 164 pickupSpawner->setMaxSpawnedItems(3); 165 pickupSpawner->setRespawnTime(30); 166 pickupSpawner->setTriggerDistance(40); 167 // Add pickup spawner to the pickup spawner list 168 pickupSpawners_.push_back(pickupSpawner); 169 } 170 171 //Generate 3 PickupSpawners randomly (shrink pickup) 172 for (int i = 0; i<3; i++) 173 { 174 PickupSpawner* pickupSpawner = new PickupSpawner(origin_->getContext()); 175 176 pickupSpawner->setPosition(get3dCoordinates(rand()%numCells, rand()%numCells, 0.0f)); 177 pickupSpawner->setPickupTemplateName(origin_->getPickupTemplateShrink()); 178 pickupSpawner->setMaxSpawnedItems(3); 179 pickupSpawner->setRespawnTime(30); 180 pickupSpawner->setTriggerDistance(40); 181 // Add pickup spawner to the pickup spawner list 182 pickupSpawners_.push_back(pickupSpawner); 183 } 184 185 //***************************************************************************** 186 187 //Generate destroyable crates randomly on field 188 189 for (int i = 0; i<10; i++){ 190 191 Pawn* crate = new Pawn(origin_->getContext()); 192 193 crate->addTemplate(origin_->getObstacleTemplate()); 194 crate->setPosition(get3dCoordinates(rand()%numCells, rand()%numCells, 43.0f)); 195 196 197 } 198 199 200 201 202 //If no lives are left, end game 203 if(lives <= 0) 204 { 205 GSLevel::startMainMenu(); 206 } 207 // Debug 208 orxout() << this->origin_->getPickupTemplate() << endl; 209 orxout() << this->origin_->getPickupRepresentationTemplate() << endl; 210 211 212 orxout() << this->origin_->getPickupTemplateSpeed() << endl; 213 orxout() << this->origin_->getPickupRepresentationTemplateSpeed() << endl; 214 215 orxout() << this->origin_->getObstacleTemplate() << endl; 216 //orxout() << crate->getPosition() << endl; 217 } 218 } 219 220 221 // Start new level 222 void Hover::createFlags() 223 { 224 //Generate 5 flags randomly (test only 1 flag) 225 226 /* do 227 { 228 int i = 0; 229 230 HoverFlag* flag = new HoverFlag(origin_->getContext()); 231 int x = rand()%numCells; 232 int y = rand()%numCells; 233 flag->init(x, y, cellSize); 234 flags_.push_back(flag); 235 236 occupiedCells[x][y] = true; 237 238 i++; 239 240 }while( i<5 || occupiedCells[x][y] == true); 241 */ 242 115 243 for ( int i = 0; i < 5; i++ ) 116 244 { … … 118 246 flag->init(rand()%numCells, rand()%numCells, cellSize); 119 247 flags_.push_back(flag); 120 } 248 121 249 122 250 123 //Generate 3 PickupSpawners randomly (destroy hover pickup) 124 for (int i = 0; i<3; i++) 125 { 126 PickupSpawner* pickupSpawner = new PickupSpawner(origin_->getContext()); 127 128 pickupSpawner->setPosition(get3dCoordinates(rand()%numCells, rand()%numCells, 10.0f)); 129 pickupSpawner->setPickupTemplateName(origin_->getPickupTemplate()); 130 pickupSpawner->setMaxSpawnedItems(3); 131 pickupSpawner->setRespawnTime(30); 132 pickupSpawner->setTriggerDistance(5); 133 // Add pickup spawner to the pickup spawner list 134 pickupSpawners_.push_back(pickupSpawner); 135 } 136 137 //Generate 3 PickupSpawners randomly (speed pickup) 138 for (int i = 0; i<3; i++) 139 { 140 PickupSpawner* pickupSpawner = new PickupSpawner(origin_->getContext()); 141 142 pickupSpawner->setPosition(get3dCoordinates(rand()%numCells, rand()%numCells, 10.0f)); 143 pickupSpawner->setPickupTemplateName(origin_->getPickupTemplateSpeed()); 144 pickupSpawner->setMaxSpawnedItems(3); 145 pickupSpawner->setRespawnTime(30); 146 pickupSpawner->setTriggerDistance(5); 147 // Add pickup spawner to the pickup spawner list 148 pickupSpawners_.push_back(pickupSpawner); 149 } 150 151 //Generate 3 PickupSpawners randomly (shrink pickup) 152 for (int i = 0; i<3; i++) 153 { 154 PickupSpawner* pickupSpawner = new PickupSpawner(origin_->getContext()); 155 156 pickupSpawner->setPosition(get3dCoordinates(rand()%numCells, rand()%numCells, 10.0f)); 157 pickupSpawner->setPickupTemplateName(origin_->getPickupTemplateShrink()); 158 pickupSpawner->setMaxSpawnedItems(3); 159 pickupSpawner->setRespawnTime(30); 160 pickupSpawner->setTriggerDistance(5); 161 // Add pickup spawner to the pickup spawner list 162 pickupSpawners_.push_back(pickupSpawner); 163 } 164 165 //***************************************************************************** 166 167 //Generate a destroyable crate randomly on field 168 169 Pawn* crate = new Pawn(origin_->getContext()); 170 171 172 crate->addTemplate(origin_->getObstacleTemplate()); 173 crate->setPosition(get3dCoordinates(rand()%numCells, rand()%numCells, 10.0f)); 174 //ate->setInitialHealth(100.0f); 175 176 177 178 179 //If no lives are left, end game 180 if(lives <= 0) 181 { 182 GSLevel::startMainMenu(); 183 } 184 // Debug 185 orxout() << this->origin_->getPickupTemplate() << endl; 186 orxout() << this->origin_->getPickupRepresentationTemplate() << endl; 187 188 orxout() << this->origin_->getPickupTemplateSpeed() << endl; 189 orxout() << this->origin_->getPickupRepresentationTemplateSpeed() << endl; 190 191 orxout() << this->origin_->getObstacleTemplate() << endl; 192 orxout() << crate->getPosition() << endl; 193 } 194 } 195 196 197 // Start new level 198 void Hover::newLevel() 199 { 200 //Generate 5 flags randomly (test only 1 flag) 201 for ( int i = 0; i < 5; i++ ) 202 { 203 HoverFlag* flag = new HoverFlag(origin_->getContext()); 204 flag->init(rand()%numCells, rand()%numCells, cellSize); 205 flags_.push_back(flag); 251 if(flags_[i]->getPosition() == get3dCoordinates(0,0,-60)) 252 { 253 flags_[i]->destroyLater(); 254 flags_.erase(flags_.begin()+i); 255 } 206 256 } 207 257 … … 245 295 lives++; 246 296 } 247 newLevel(); 297 createFlags(); 298 toggleShowLevel(); 299 showLevelTimer.setTimer(1.0f, false, createExecutor(createFunctor(&Hover::toggleShowLevel, this))); 248 300 249 301 } -
code/branches/tgidronFS16/src/modules/hover/Hover.h
r11182 r11192 58 58 59 59 void start(); 60 void newLevel();60 void createFlags(); 61 61 void levelUp(); 62 62 void endLevel(); … … 77 77 { return this->level; } 78 78 79 bool bShowLevel; 80 79 81 private: 80 82 … … 94 96 95 97 std::vector<PickupSpawner*> pickupSpawners_; 96 98 99 void toggleShowLevel(){bShowLevel = !bShowLevel;} 100 101 Timer showLevelTimer; 97 102 }; 98 103 } -
code/branches/tgidronFS16/src/modules/hover/HoverOrigin.cc
r11184 r11192 73 73 XMLPortParam(HoverOrigin, "pickuptemplateshrink", setPickupTemplateShrink, getPickupTemplateShrink, xmlelement, mode); 74 74 XMLPortParam(HoverOrigin, "pickuprepresentationtemplateshrink", setPickupRepresentationTemplateShrink, getPickupRepresentationTemplateShrink, xmlelement, mode); 75 XMLPortParam(HoverOrigin, "groundtemplate", setGroundTemplate, getGroundTemplate, xmlelement, mode); 75 76 } 76 77 -
code/branches/tgidronFS16/src/modules/hover/HoverOrigin.h
r11182 r11192 110 110 { return this->obstacleTemplate_; } 111 111 112 //get and set for ground template 113 114 inline void setGroundTemplate(std::string groundTemplate) 115 { this->groundTemplate_ = groundTemplate; } 116 inline std::string getGroundTemplate() const 117 { return this->groundTemplate_; } 118 112 119 private: 113 120 void checkGametype(); … … 132 139 //Template for crate obstacle 133 140 std::string obstacleTemplate_; 141 142 //Template for ground cell 143 std::string groundTemplate_; 134 144 }; 135 145 } -
code/branches/tgidronFS16/src/modules/hover/TFlagsLivesLevelHUD.cc
r11177 r11192 85 85 this->setColour(ColourValue(1, 1, 1, 1)); 86 86 this->setCaption(level); 87 87 88 } 88 89 90 if(this->hoverGame_->bShowLevel) 91 { 92 setTextSize(0.2); 93 setPosition(Vector2(0.3, 0.55)); 94 std::stringstream sstm; 95 sstm << "Level " << level; 96 this->setCaption(sstm.str()); 97 } 89 98 } 90 99 -
code/branches/tgidronFS16/src/modules/hover/TFlagsLivesLevelHUD.h
r11177 r11192 85 85 { return this->totLevel_; } 86 86 87 87 88 private: 88 89 Hover* hoverGame_;
Note: See TracChangeset
for help on using the changeset viewer.