Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 1931 in orxonox.OLD for orxonox/trunk/core/world.cc


Ignore:
Timestamp:
Jun 9, 2004, 10:49:04 AM (21 years ago)
Author:
patrick
Message:

orxonox/trunk/core: speed of ground, shoot enemies

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/core/world.cc

    r1919 r1931  
    3333  lastEnv = null;
    3434  primitiveMove = 0;
     35  step = 0;
    3536}
    3637
     
    104105
    105106/**
     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*/
     112bool 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/**
    106144   \brief Add environmental object
    107145   \param player A reference to the new env object
     
    126164}
    127165
    128 
    129 
    130 
    131 
    132 /**
    133    \brief Remove Non-Player Character
    134    \param player A reference to the new npc object
    135    
    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 }
    141166
    142167
     
    167192    }
    168193
    169 
    170194  /* now draw the rest of the world: environement */
    171195  envList* tmpEnv = lastEnv;
     
    175199      tmpEnv = tmpEnv->next;
    176200    }
    177  
    178201 
    179202  /* draw the ground grid  */
     
    189212        }
    190213    }
    191  glEnd();
    192  //glPopMatrix();
    193  
     214  glEnd();
     215 
    194216  glBegin(GL_LINES);
    195217  for (int x = 0; x < 60; x += 2)
     
    204226
    205227  //primitiveMove+=0.07;
    206   DataTank::yOffset += 0.07;
     228  DataTank::yOffset += step;
    207229
    208230  tmpPlayer = lastPlayer;
    209231  while( tmpPlayer != null )
    210232    {
    211       tmpPlayer->player->yCor += 0.07;
     233      tmpPlayer->player->yCor += step;
    212234      tmpPlayer = tmpPlayer->next;
    213235    }
     
    228250    }
    229251}
     252
     253
     254void World::setWorldStep(float step)
     255{
     256  this->step = step;
     257  cout << "setting speed to " << step << endl;
     258}
     259
    230260
    231261
     
    250280  //cout << "World::detectCollision" << endl;
    251281  float xOff, yOff, zOff, radius;
    252   npcList* tmpNPC;
     282  npcList* tmpNPC, *tmpRef;
    253283
    254284  //cout << "World::detectCollsions" << endl;
     
    256286  playerList* tmpPlayer = lastPlayer;
    257287  Player* player = tmpPlayer->player;
     288  int state;
    258289  while( tmpPlayer != null )
    259290    {
     
    261292      while( tmpNPC != null )
    262293        {
     294          //cout << "npc != null" << endl;
    263295          radius = tmpNPC->npc->collisionRadius;
     296          //cout << "worki" << endl;
    264297          ShootLaser::shoot* shoota = tmpPlayer->player->shootLaser->lastShoot;
    265298          while( shoota != null )
     
    268301              yOff = shoota->yCor - tmpNPC->npc->yCor;
    269302              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                }
    272318              shoota = shoota->next;
    273319            }
     320          //cout << "changing npc..." << endl;
    274321          tmpNPC = tmpNPC->next;
    275         }
    276      
     322          //cout << "..changing npc done" << endl;
     323        }
     324      //cout << "changing play..." << endl;
    277325      tmpPlayer = tmpPlayer->next;
    278     }
     326      //cout << "changing play done" << endl;
     327    }
     328
     329  //cout << "World::detectCollisions middle" << endl;
    279330
    280331  /* second: check if any player hits an enemy */
    281 
    282  
    283332  tmpPlayer = lastPlayer;
    284333  while( tmpPlayer != null )
     
    291340          yOff = tmpPlayer->player->yCor - tmpNPC->npc->yCor;
    292341          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          }
    295346         
    296347          tmpNPC = tmpNPC->next;
Note: See TracChangeset for help on using the changeset viewer.