Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jul 19, 2005, 12:20:58 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: remake of the Projectile and TestBullet

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/world_entities/weapons/weapon.cc

    r4885 r4890  
    122122    printf("next action will be %s in %f seconds\n", actionToChar(action), this->stateDuration);
    123123    this->requestedAction = action;
     124  }
     125}
     126
     127
     128/**
     129 * adds energy to the Weapon
     130 * @param energyToAdd The amount of energy
     131 * @returns the amount of energy we did not pick up, because the weapon is already full
     132 */
     133float Weapon::increaseEnergy(float energyToAdd)
     134{
     135  float maxAddEnergy = this->energyMax - this->energy;
     136
     137  if (maxAddEnergy >= energyToAdd)
     138  {
     139    this->energy += energyToAdd;
     140    return 0.0;
     141  }
     142  else
     143  {
     144    this->energy += maxAddEnergy;
     145    return energyToAdd - maxAddEnergy;
    124146  }
    125147}
Note: See TracChangeset for help on using the changeset viewer.