Changeset 1899 in orxonox.OLD for orxonox/trunk/core/world.cc
- Timestamp:
- May 20, 2004, 1:03:53 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/core/world.cc
r1896 r1899 33 33 lastNPC = null; 34 34 lastEnv = null; 35 lastShoot = null;36 35 } 37 36 … … 128 127 129 128 130 /** 131 \brief Add environmental object 132 \param player A reference to the new env object 133 134 Add a new Environment to the world. Env has to be initialised before. 135 */ 136 bool World::addShoot(ShootLaser* shoot) 137 { 138 shootList* listMember = new shootList; 139 listMember->shoot = shoot; 140 if ( lastShoot != null ) 141 { 142 listMember->number = lastShoot->number + 1; 143 listMember->next = lastShoot; 144 } 145 else 146 { 147 listMember->number = 0; 148 listMember->next = null; 149 } 150 lastShoot = listMember; 151 } 129 152 130 153 131 … … 193 171 tmpEnv = tmpEnv->next; 194 172 } 195 /* now draw all the shoots (many) */ 196 shootList* tmpShoot = lastShoot; 197 while( tmpShoot != null ) 198 { 199 (*tmpShoot->shoot).drawShoot(); 200 tmpShoot = tmpShoot->next; 201 } 173 202 174 203 175 glColor3f(0.0, 1.0, 0.0); … … 255 227 256 228 229 /* collision detection */ 230 /* fix: bad efficency: stupid brute force */ 231 232 void World::detectCollision() 233 { 234 float xOff, yOff, zOff, radius; 235 npcList* tmpNPC; 236 237 //cout << "World::detectCollsions" << endl; 238 /* first: check if any player's shoots trigger a collision */ 239 playerList* tmpPlayer = lastPlayer; 240 Player* player = tmpPlayer->player; 241 while( tmpPlayer != null ) 242 { 243 tmpNPC = lastNPC; 244 while( tmpNPC != null ) 245 { 246 radius = tmpNPC->npc->collisionRadius; 247 ShootLaser::shoot* shoota = tmpPlayer->player->shootLaser->lastShoot; 248 while( shoota != null ) 249 { 250 xOff = shoota->xCor - tmpNPC->npc->xCor; 251 yOff = shoota->yCor - tmpNPC->npc->yCor; 252 zOff = shoota->zCor - tmpNPC->npc->zCor; 253 if ( sqrt(xOff*xOff + yOff*yOff + zOff*zOff) < radius ) 254 cout << "COLLISION " << endl; 255 shoota = shoota->next; 256 } 257 tmpNPC = tmpNPC->next; 258 } 259 260 tmpPlayer = tmpPlayer->next; 261 } 262 263 /* second: check if any player hits an enemy */ 264 265 /* third: check if any enemy shoots a player */ 266 267 //cout << "World::detectCollisions end" << endl; 268 } 269 270 257 271 258 272 /**
Note: See TracChangeset
for help on using the changeset viewer.