Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6679 in orxonox.OLD for trunk


Ignore:
Timestamp:
Jan 24, 2006, 10:56:46 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: WeaponManager seems to work, better than before.

Location:
trunk/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/event/event_handler.cc

    r6664 r6679  
    262262    SDL_WM_GrabInput(SDL_GRAB_OFF);
    263263  else
    264     SDL_WM_GrabInput(SDL_GRAB_ON);
     264    ;// SDL_WM_GrabInput(SDL_GRAB_ON);
    265265}
    266266
  • trunk/src/world_entities/space_ships/space_ship.cc

    r6637 r6679  
    110110  this->addWeapon(wpRight,1 ,1);
    111111  this->addWeapon(cannon, 0, 6);
    112 
    113   //this->addWeapon(turret, 3, 0);
    114112
    115113  this->getWeaponManager()->changeWeaponConfig(1);
     
    291289    if (yMouse > controlVelocityY) yMouse = controlVelocityY;
    292290    else if (yMouse < -controlVelocityY) yMouse = -controlVelocityY;
    293    
     291
    294292    pitchDir = (Quaternion(xMouse*mouseSensitivity*0.5, Vector(1,0,0)));
    295    
     293
    296294    mouseDir *= (Quaternion(-M_PI/4*xMouse*mouseSensitivity, Vector(0,1,0))*Quaternion(-M_PI/4*yMouse*mouseSensitivity*yInvert, Vector(0,0,1))*pitchDir);
    297295    xMouse = yMouse = 0;
     
    306304
    307305  Vector move = velocity*time;
    308  
     306
    309307  //orient the velocity in the direction of the spaceship.
    310308  travelSpeed = velocity.len();
     
    321319  if(travelSpeed >= 120) velocity -= velocity.getNormalized()*travelSpeed*travelSpeed*0.0001;
    322320  else if (travelSpeed <= 80) velocity -= velocity.getNormalized()*travelSpeed*0.001;
    323  
     321
    324322  //other physics (gravity)
    325323  if(travelSpeed < 120)
    326324  move += Vector(0,-1,0)*60*time + Vector(0,1,0)*travelSpeed/2*time;
    327    
     325
    328326  //hoover effect
    329327  //cycle += time;
  • trunk/src/world_entities/weapons/weapon_manager.cc

    r6677 r6679  
    203203}
    204204
    205 
    206 bool WeaponManager::addWeapon(Weapon* weapon)
    207 {
    208   int weaponConf = this->currentConfigID;
    209   int slot = this->getNextFreeSlot(weaponConf, weapon->getCapability());
    210   if (slot  != -1 )
    211   {
    212     return this->addWeapon(weapon, weaponConf, slot);
    213   }
    214   else
    215   {
    216     return this->addWeapon(weapon, -1, -1);
    217   }
    218 }
    219205
    220206/**
     
    231217bool WeaponManager::addWeapon(Weapon* weapon, int configID, int slotID)
    232218{
     219  assert(weapon != NULL);
     220
    233221  if (unlikely(configID >= WM_MAX_CONFIGS || slotID >= (int)this->slotCount))
    234222  {
    235     PRINTF(2)("Slot %d of config %d is not availiabe (max: %d)\n", slotID, configID, this->slotCount);
    236     return false;
     223    PRINTF(2)("Slot %d of config %d is not availiabe (max: %d) searching for suitable slot\n", slotID, configID, this->slotCount);
     224    if (configID >= WM_MAX_CONFIGS)
     225      configID = -1;
     226    if (slotID >= (int)this->slotCount)
     227      slotID = -1;
     228  }
     229  // if no ConfigID is supplied set to Current Config.
     230  if (configID <= -1)
     231    configID = this->currentConfigID;
     232  //
     233  if (configID > -1 && slotID == -1)
     234  {
     235    slotID = this->getNextFreeSlot(configID, weapon->getCapability());
     236    if (slotID == -1)
     237      configID = -1;
    237238  }
    238239
  • trunk/src/world_entities/weapons/weapon_manager.h

    r6669 r6679  
    7474    PNode* getParent() const { return this->parent; };
    7575
    76     bool addWeapon(Weapon* weapon);
    77     bool addWeapon(Weapon* weapon, int configID, int slotID = -1);
     76    bool addWeapon(Weapon* weapon, int configID = -1, int slotID = -1);
    7877    void removeWeapon(Weapon* weapon, int configID = -1);
    7978
Note: See TracChangeset for help on using the changeset viewer.