- Timestamp:
- Jun 9, 2004, 10:49:04 AM (20 years ago)
- Location:
- orxonox/trunk/core
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/core/npc.cc
r1904 r1931 25 25 26 26 27 NPC::NPC () {} 27 NPC::NPC () 28 { 29 hasDied = 0; 30 } 28 31 29 32 NPC::~NPC () {} … … 58 61 } 59 62 60 61 63 void NPC::drawNPC(void) 62 64 { 63 glPushMatrix(); 64 glTranslatef(xCor, yCor, 3.0); 65 //glScalef(1.0, 3.0, 1.0); 66 glutWireSphere(1.0, 10, 10); 67 glPopMatrix(); 68 //cout << "Player::drawNPC()" << endl; 65 /* fix: died flag approach is very stupid, just to show @ convention */ 66 if( hasDied == 0 ) { 67 glPushMatrix(); 68 glTranslatef(xCor, yCor, 3.0); 69 //glScalef(1.0, 3.0, 1.0); 70 glutWireSphere(1.0, 10, 10); 71 glPopMatrix(); 72 } 69 73 } 74 75 76 /* define the reaction, if the ship is been hit */ 77 int NPC::hit() 78 { 79 die(); 80 return 0; 81 } 82 83 void NPC::die() 84 { 85 hasDied = 1; 86 } -
orxonox/trunk/core/npc.h
r1904 r1931 27 27 void addAI(AI* ai); 28 28 void setCollisionRadius(float r); 29 float getCollisionRadius(); 29 float getCollisionRadius(void); 30 int hit(void); 31 void die(void); 30 32 31 33 private: … … 33 35 34 36 int npcType; 37 int hasDied; 35 38 36 39 -
orxonox/trunk/core/orxonox.cc
r1918 r1931 136 136 cout << "got " << fps << " fps" << endl; 137 137 /* this is very very unsafe: io could be uninit */ 138 io->setPlayerStep(19.2 / fps); /* set player to propper speed */ 139 localPlayer->shootLaser->setShootStep(fps/48.0); /* set shoot speed */ 138 io->setPlayerStep(19.2/fps); /* set player to propper speed */ 139 localPlayer->shootLaser->setShootStep(20.0/fps); /* set shoot speed */ 140 world->setWorldStep(7.0/fps); /* set the speed of the terrain moving away */ 140 141 fps = 0; 141 142 inputEnabled = true; -
orxonox/trunk/core/player.cc
r1930 r1931 75 75 void Player::shoot(int n) 76 76 { 77 if (shootLaser->inhibitor++ <= 100) 78 shootLaser->addShoot(xCor, yCor, zCor); 79 else if (shootLaser->inhibitor++ <= 200) 80 shootLaser->addShootExt(xCor, yCor, zCor, .1, .4, .0); 81 else if (shootLaser->inhibitor++ <= 300) 82 shootLaser->addShootExt(xCor, yCor, zCor, -0.1, .4, .0); 83 else 84 shootLaser->inhibitor =0; 85 86 if (shootRocket->inhibitor++ >=80) 87 { 88 shootRocket->addBackParable(xCor, yCor, zCor); 89 shootRocket->addSideAcc(xCor, yCor, zCor, RIGHT); 90 shootRocket->addSideAcc(xCor, yCor, zCor, LEFT); 91 shootRocket->addRotater(xCor, yCor, zCor); 92 if (shootRocket->inhibitor >=90) 93 shootRocket->inhibitor =0; 94 } 77 shootLaser->addShoot(xCor, yCor, zCor); 78 shootLaser->addShootExt(xCor, yCor, zCor, .1, .4, .0); 79 shootLaser->addShootExt(xCor, yCor, zCor, -0.1, .4, .0); 80 shootRocket->addShoot(xCor, yCor, zCor); 95 81 //cout << "Player::shoot" << endl; 96 82 } -
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; -
orxonox/trunk/core/world.h
r1920 r1931 65 65 void drawWorld(void); 66 66 void initEnvironement(void); 67 void setWorldStep(float step); 67 68 void updateWorld(void); 68 69 void detectCollision(void); … … 71 72 private: 72 73 float surface[120][120]; 74 float step; 73 75 74 76
Note: See TracChangeset
for help on using the changeset viewer.