Changeset 1931 in orxonox.OLD for orxonox/trunk/core/world.cc
- Timestamp:
- Jun 9, 2004, 10:49:04 AM (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/core/world.cc
r1919 r1931 33 33 lastEnv = null; 34 34 primitiveMove = 0; 35 step = 0; 35 36 } 36 37 … … 104 105 105 106 /** 107 \brief Remove Non-Player Character 108 \param player A reference to the new npc object 109 110 Remove a new Non-Player-Character to the game. 111 */ 112 bool World::removeNPC(NPC* npc) { 113 114 npcList* npcRef = lastNPC; 115 npcList* lastRef = lastNPC; 116 while ( npcRef != null ) 117 { 118 if ( npcRef->npc == npc ) { 119 cout << "found" << endl; 120 if ( npcRef == lastRef ) { 121 lastNPC = lastNPC->next; 122 delete npcRef; 123 npcRef = lastNPC; 124 lastRef = lastNPC; 125 } 126 else { 127 lastRef->next = npcRef->next; 128 delete npcRef; 129 npcRef = lastRef->next; 130 } 131 cout << "killed ..." << endl; 132 } 133 else { 134 lastRef = npcRef; 135 npcRef = npcRef->next; 136 } 137 } 138 cout << "npc left" << endl; 139 } 140 141 142 143 /** 106 144 \brief Add environmental object 107 145 \param player A reference to the new env object … … 126 164 } 127 165 128 129 130 131 132 /**133 \brief Remove Non-Player Character134 \param player A reference to the new npc object135 136 Remove a new Non-Player-Character to the game.137 */138 bool World::removeNPC(NPC* npc) {139 cout << "World::removeNPC not implemented yet" << endl;140 }141 166 142 167 … … 167 192 } 168 193 169 170 194 /* now draw the rest of the world: environement */ 171 195 envList* tmpEnv = lastEnv; … … 175 199 tmpEnv = tmpEnv->next; 176 200 } 177 178 201 179 202 /* draw the ground grid */ … … 189 212 } 190 213 } 191 glEnd(); 192 //glPopMatrix(); 193 214 glEnd(); 215 194 216 glBegin(GL_LINES); 195 217 for (int x = 0; x < 60; x += 2) … … 204 226 205 227 //primitiveMove+=0.07; 206 DataTank::yOffset += 0.07;228 DataTank::yOffset += step; 207 229 208 230 tmpPlayer = lastPlayer; 209 231 while( tmpPlayer != null ) 210 232 { 211 tmpPlayer->player->yCor += 0.07;233 tmpPlayer->player->yCor += step; 212 234 tmpPlayer = tmpPlayer->next; 213 235 } … … 228 250 } 229 251 } 252 253 254 void World::setWorldStep(float step) 255 { 256 this->step = step; 257 cout << "setting speed to " << step << endl; 258 } 259 230 260 231 261 … … 250 280 //cout << "World::detectCollision" << endl; 251 281 float xOff, yOff, zOff, radius; 252 npcList* tmpNPC ;282 npcList* tmpNPC, *tmpRef; 253 283 254 284 //cout << "World::detectCollsions" << endl; … … 256 286 playerList* tmpPlayer = lastPlayer; 257 287 Player* player = tmpPlayer->player; 288 int state; 258 289 while( tmpPlayer != null ) 259 290 { … … 261 292 while( tmpNPC != null ) 262 293 { 294 //cout << "npc != null" << endl; 263 295 radius = tmpNPC->npc->collisionRadius; 296 //cout << "worki" << endl; 264 297 ShootLaser::shoot* shoota = tmpPlayer->player->shootLaser->lastShoot; 265 298 while( shoota != null ) … … 268 301 yOff = shoota->yCor - tmpNPC->npc->yCor; 269 302 zOff = shoota->zCor - tmpNPC->npc->zCor; 270 if ( sqrt(xOff*xOff + yOff*yOff + zOff*zOff) < radius ) 271 cout << "COLLISION " << endl; 303 if ( sqrt(xOff*xOff + yOff*yOff + zOff*zOff) < radius ) 304 { 305 //cout << "COLLISION " << endl; 306 int state = tmpNPC->npc->hit(); 307 /* state is a value that marks if the ship dies or not */ 308 /* if state == 0 the ship dies and we have to remove it */ 309 /* 310 if ( state == 0 ) { 311 tmpRef = tmpNPC; 312 tmpNPC = tmpNPC->next; 313 removeNPC(tmpRef->npc); 314 break; 315 } 316 */ 317 } 272 318 shoota = shoota->next; 273 319 } 320 //cout << "changing npc..." << endl; 274 321 tmpNPC = tmpNPC->next; 275 } 276 322 //cout << "..changing npc done" << endl; 323 } 324 //cout << "changing play..." << endl; 277 325 tmpPlayer = tmpPlayer->next; 278 } 326 //cout << "changing play done" << endl; 327 } 328 329 //cout << "World::detectCollisions middle" << endl; 279 330 280 331 /* second: check if any player hits an enemy */ 281 282 283 332 tmpPlayer = lastPlayer; 284 333 while( tmpPlayer != null ) … … 291 340 yOff = tmpPlayer->player->yCor - tmpNPC->npc->yCor; 292 341 zOff = tmpPlayer->player->zCor - tmpNPC->npc->zCor; 293 if ( sqrt(xOff*xOff + yOff*yOff + zOff*zOff) < radius ) 294 cout << "COLLISION " << endl; 342 if ( sqrt(xOff*xOff + yOff*yOff + zOff*zOff) < radius ) { 343 //cout << "COLLISION " << endl; 344 tmpNPC->npc->hit(); 345 } 295 346 296 347 tmpNPC = tmpNPC->next;
Note: See TracChangeset
for help on using the changeset viewer.