Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 25, 2005, 9:29:41 AM (19 years ago)
Author:
patrick
Message:

orxonox/branches/physics: merged with trunk - with command svn merge -r 3866:HEAD

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/physics/src/world_entities/player.cc

    r3811 r3953  
    3838Player::Player() : WorldEntity()
    3939{
    40   this->weapons = new tList<Weapon>();
    41   this->activeWeapon = NULL;
    4240  /*
    4341    this is the debug player - actualy we would have to make a new
     
    4644  */
    4745  this->model = (Model*)ResourceManager::getInstance()->load("models/reaplow.obj", OBJ, RP_CAMPAIGN);
    48   //this->model = (Model*)ResourceManager::getInstance()->load("models/weapon_packet.obj", OBJ, RP_CAMPAIGN);
    4946  travelSpeed = 15.0;
    5047  velocity = new Vector();
    5148  bUp = bDown = bLeft = bRight = bAscend = bDescend = false;
    5249  bFire = false;
     50  this->bWeaponChange = false;
    5351  acceleration = 10.0;
    5452  //weapons:
    55   Weapon* wpRight = new TestGun(this, new Vector(-2.6, 0.1, 3.0), new Quaternion(), 0);
    56   Weapon* wpLeft = new TestGun(this, new Vector(-2.6, 0.1, -3.0), new Quaternion(), 1);
    57   this->weapons->add(wpRight);
    58   this->activeWeapon = wpRight;
    59   this->activeWeaponL = wpLeft;
     53  this->weaponMan = new WeaponManager();
     54  Weapon* wpRight = new TestGun(this,Vector(-2.6, 0.1, 3.0), Quaternion(), 0);
     55  Weapon* wpLeft = new TestGun(this, Vector(-2.6, 0.1, -3.0), Quaternion(), 1);
     56 
     57  this->weaponMan->addWeapon(wpRight, W_CONFIG0);
     58  this->weaponMan->addWeapon(wpLeft, W_CONFIG1);
     59  this->weaponMan->addWeapon(wpRight, W_CONFIG2);
     60  this->weaponMan->addWeapon(wpLeft, W_CONFIG2);
     61
    6062}
    6163
     
    6971     this only frees the memory allocated to save the list.
    7072  */
    71   delete this->weapons;
     73  delete this->weaponMan;
    7274}
    7375
     
    7981void Player::addWeapon(Weapon* weapon)
    8082{
    81   this->weapons->add(weapon);
     83  this->weaponMan->addWeapon(weapon);
    8284}
    8385
     
    8991void Player::removeWeapon(Weapon* weapon)
    9092{
    91   this->weapons->remove(weapon);
     93  this->weaponMan->removeWeapon(weapon);
    9294}
    9395
     
    151153  glPopMatrix();
    152154
    153   this->activeWeapon->draw();
    154   this->activeWeaponL->draw();
     155  this->weaponMan->draw();
    155156}
    156157
     
    163164{
    164165  /* link tick to weapon */
    165   this->activeWeapon->tick(time);
    166   this->activeWeaponL->tick(time); //FIX FIX DELETE REMOVE
     166  //this->activeWeapon->tick(time);
     167  //this->activeWeaponL->tick(time); //FIX FIX DELETE REMOVE
     168  this->weaponMan->tick(time);
    167169  // player controlled movement
    168170  this->move(time);
     
    180182  Vector accel(0.0, 0.0, 0.0);
    181183  /* FIXME: calculating the direction and orthDirection every timeSlice is redundant! save it somewhere */
    182  
    183184  /* calculate the direction in which the craft is heading  */
    184185  Vector direction (1.0, 0.0, 0.0);
     
    210211  if( this->bFire)
    211212    {
    212       //if(this->activeWeapon != NULL)
    213       this->activeWeapon->fire();
    214       //FIX THIS FIX FIIIIIIIIIIIX
    215       this->activeWeaponL->fire();
     213      this->weaponMan->fire();
    216214    }
    217   if( this->bWeaponChange && this->weapons->getSize() > 1)
     215  if( this->bWeaponChange)
    218216    {
    219       PRINTF(1)("changing the weapon of the player: deactivate old, activate new\n");
    220       this->activeWeapon->deactivate();
    221       //this->weapons->enumerate();  FIX: strang weapon change...
    222       this->activeWeapon = this->weapons->nextElement(this->activeWeapon);
    223       this->activeWeapon->activate();
     217      this->weaponMan->nextWeaponConf();
     218      this->bWeaponChange = false;
    224219    }
    225220}
     
    240235  if( !strcmp( cmd->cmd, "right")) this->bRight = !cmd->bUp;
    241236  if( !strcmp( cmd->cmd, "fire")) this->bFire = !cmd->bUp;
    242   if( !strcmp( cmd->cmd, "mode")) this->bWeaponChange = !cmd->bUp;
    243 }
     237  if( !strcmp( cmd->cmd, "mode")) if(cmd->bUp) this->bWeaponChange = !this->bWeaponChange;
     238}
Note: See TracChangeset for help on using the changeset viewer.