Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 1924 in orxonox.OLD for orxonox/trunk/core


Ignore:
Timestamp:
Jun 8, 2004, 6:30:23 PM (20 years ago)
Author:
bensch
Message:

orxonox/truk/core: added support for different types of rockets, and implemented Side-Accelerators :) I think they really rock.

Location:
orxonox/trunk/core
Files:
3 edited

Legend:

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

    r1920 r1924  
    7878  shootLaser->addShootExt(xCor, yCor, zCor, .1, .4, .0);
    7979  shootLaser->addShootExt(xCor, yCor, zCor, -0.1, .4, .0);
    80   shootRocket->addShoot(xCor, yCor, zCor);
     80    shootRocket->addBackParable(xCor, yCor, zCor);
     81    shootRocket->addSideAcc(xCor, yCor, zCor, RIGHT);
     82    shootRocket->addSideAcc(xCor, yCor, zCor, LEFT);
    8183  //cout << "Player::shoot" << endl;
    8284}
  • orxonox/trunk/core/shoot_rocket.cc

    r1921 r1924  
    4848      glPushMatrix();
    4949      glTranslatef(tmpShoot->xCor, tmpShoot->yCor, tmpShoot->zCor);
    50       tmpShoot->xCor+=tmpShoot->xVel;
    51       tmpShoot->yCor+=tmpShoot->yVel;
    52       tmpShoot->xVel+=tmpShoot->xAcc;
    53       tmpShoot->yVel+=tmpShoot->yAcc;
    54      
     50      switch (tmpShoot->type)
     51        {
     52        case BACKPARABLE:
     53          tmpShoot->xCor+=tmpShoot->xVel;
     54          tmpShoot->yCor+=tmpShoot->yVel;
     55          tmpShoot->xVel+=tmpShoot->xAcc;
     56          tmpShoot->yVel+=tmpShoot->yAcc;
     57          break;
     58       
     59        case SIDEACC:
     60          if (tmpShoot->xVel >= .01 || tmpShoot->xVel <= -.01)
     61            {
     62              tmpShoot->xCor+=tmpShoot->xVel;
     63              tmpShoot->xVel*=tmpShoot->xAcc;
     64            }
     65          else
     66            {
     67              tmpShoot->yCor+=tmpShoot->yVel;
     68              tmpShoot->yVel+=tmpShoot->yVel*tmpShoot->yAcc;
     69            }
     70          break;
     71        }
     72         
    5573      glScalef(0.1, 0.1, 0.1);
    5674      glutWireCube(1.0);
     
    112130}
    113131
    114 void ShootRocket::addShoot(float x, float y, float z)
     132void ShootRocket::addBackParable(float x, float y, float z)
    115133{
    116134  inhibitor++;
     
    119137      //cout << "ShootRocket::addShoot" << endl;
    120138      shoot* sh = new shoot;
     139      sh->type = BACKPARABLE;
    121140      sh->xCor = x; sh->yCor = y; sh->zCor = z;
    122141      sh->xVel = (-1+(float)random() / 1000000000/step)/5;
     
    129148    }
    130149}
     150void ShootRocket::addSideAcc(float x, float y, float z, enum RocketDirection direction)
     151{
     152  inhibitor++;
     153  if (inhibitor >= 10)
     154    {
     155      //cout << "ShootRocket::addShoot" << endl;
     156      shoot* sh = new shoot;
     157      sh->type = SIDEACC;
     158      sh->xCor = x; sh->yCor = y; sh->zCor = z;
     159      switch (direction)
     160        {
     161        case LEFT:
     162          sh->xVel = -.3; sh->yVel = .05; sh->zVel = 0;
     163           cout << "Left\n";
     164          break;
     165        case RIGHT:
     166          sh->xVel = .3; sh->yVel = .05; sh->zVel = 0;
     167          break;
     168        }
     169      sh->xAcc = .9; sh->yAcc = .02; sh->zAcc = 0;
     170      sh->next = lastShoot;
     171      lastShoot = sh;
     172      inhibitor =0;
     173    }
     174}
    131175
    132 void ShootRocket::addShootExt(float x, float y, float z,
    133                              float xVel, float yVel, float zVel)
    134 {
    135   //cout << "ShootRocket::addShootExtended" << endl;
    136   shoot* sh = new shoot;
    137   sh->xCor = x; sh->yCor = y; sh->zCor = z;
    138   sh->xVel = xVel/step; sh->yVel = yVel/step; sh->zVel = zVel/step;
    139   sh->xAcc = 0; sh->yAcc = .02; sh->zAcc = 0;
    140   sh->next = lastShoot;
    141   lastShoot = sh;
    142 }
    143176
    144177void ShootRocket::setShootStep(float step)
  • orxonox/trunk/core/shoot_rocket.h

    r1921 r1924  
    1010#include "npc.h"
    1111
     12enum RocketType { HOMING, SIDEACC, BACKPARABLE};
     13enum RocketDirection {LEFT, RIGHT, UP, DOWN};
     14
    1215class ShootRocket {
    1316
     
    1720  /* a list of all shoot-amental objects */
    1821  struct shoot {
     22    enum RocketType type;
    1923    shoot *next;
    2024    float xCor;
     
    3943  void drawShoot(void);
    4044  void addShoot(shoot* sh);
    41   void addShoot(float x, float y, float z);
    42   void addShootExt(float x, float y, float z, float xVel, float yVel, float zVel);
     45  void addBackParable(float x, float y, float z);
     46  void addSideAcc(float x, float y, float z, enum RocketDirection direction);
    4347  void setShootStep(float step);
    4448  void removeShoot(shoot* sh);
Note: See TracChangeset for help on using the changeset viewer.