Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 1931 in orxonox.OLD for orxonox


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

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

Location:
orxonox/trunk/core
Files:
6 edited

Legend:

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

    r1904 r1931  
    2525
    2626
    27 NPC::NPC () {}
     27NPC::NPC ()
     28{
     29  hasDied = 0;
     30}
    2831
    2932NPC::~NPC () {}
     
    5861}
    5962
    60 
    6163void NPC::drawNPC(void)
    6264{
    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  }
    6973}
     74
     75
     76/* define the reaction, if the ship is been hit */
     77int NPC::hit()
     78{
     79  die();
     80  return 0;
     81}
     82
     83void NPC::die()
     84{
     85  hasDied = 1;
     86}
  • orxonox/trunk/core/npc.h

    r1904 r1931  
    2727  void addAI(AI* ai);
    2828  void setCollisionRadius(float r);
    29   float getCollisionRadius();
     29  float getCollisionRadius(void);
     30  int hit(void);
     31  void die(void);
    3032
    3133 private:
     
    3335
    3436  int npcType;
     37  int hasDied;
    3538
    3639
  • orxonox/trunk/core/orxonox.cc

    r1918 r1931  
    136136  cout << "got " << fps << " fps" << endl;
    137137  /* 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 */
    140141  fps = 0;
    141142  inputEnabled = true;
  • orxonox/trunk/core/player.cc

    r1930 r1931  
    7575void Player::shoot(int n)
    7676{
    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);
    9581  //cout << "Player::shoot" << endl;
    9682}
  • 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;
  • orxonox/trunk/core/world.h

    r1920 r1931  
    6565  void drawWorld(void);
    6666  void initEnvironement(void);
     67  void setWorldStep(float step);
    6768  void updateWorld(void);
    6869  void detectCollision(void);
     
    7172 private:
    7273  float surface[120][120];
     74  float step;
    7375
    7476
Note: See TracChangeset for help on using the changeset viewer.