Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 24, 2006, 11:58:23 PM (17 years ago)
Author:
nicolasc
Message:

updated damage() to use tick
added collidesWith() to Projectile

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/playability/src/world_entities/space_ships/space_ship.cc

    r9953 r9957  
    521521
    522522
    523 int SpaceShip::getShieldCur () { return this->shieldCur; }
    524 int SpaceShip::getShieldMax () { return this->shieldMax; }
    525 
    526 int SpaceShip::getArmorCur () { return this->armorCur; }
    527 int SpaceShip::getArmorMax () { return this->armorMax; }
    528 
    529 int SpaceShip::getElectronicCur () { return this->electronicCur; }
    530 int SpaceShip::getElectronicMax () { return this->electronicMax; }
    531 
    532 void SpaceShip::damage(int pDamage, int eDamage){
     523void SpaceShip::damage(float pDamage, float eDamage){
    533524if( this->shieldActive) {
    534525    if( this->shieldCur > pDamage) {
     
    540531      pDamage = pDamage - this->shieldCur;
    541532      if( !this->shieldActive) {
    542         this->armorCur = pDamage / 2; // remaining damages hits armor at half rate
     533        this->armorCur -= pDamage / 2; // remaining damages hits armor at half rate
    543534        this->electronicCur -= eDamage;
    544535      }
     
    552543}
    553544
    554 void SpaceShip::regen(){
    555   int time = 1; // FIXME implement tick time calculation
    556   if (this->shieldCur == this->shieldMax){}
    557   else {
    558     if( this->shieldCur + this->shieldRegen * time > shieldMax)
     545void SpaceShip::regen(float time){
     546  float tmp;
     547  if (this->shieldCur != this->shieldMax){
     548    tmp =  this->shieldCur + this->shieldRegen * time;
     549    if( tmp > shieldMax)
    559550      this->shieldCur = this->shieldMax;
    560551    else
    561       this->shieldCur += this->shieldRegen * time;
    562     if( this->shieldCur > shieldTH)
    563       this->shieldActive = true;
    564   }
    565   if (this->electronicCur == this->electronicMax){}
    566   else{
    567     if (this->electronicCur + this->electronicRegen * time > electronicMax)
     552      this->shieldCur = tmp;
     553    this->shieldActive = ( this->shieldActive || this->shieldCur > shieldTH);
     554  }
     555  if (this->electronicCur != this->electronicMax){
     556    tmp = this->electronicCur + this->electronicRegen * time;
     557    if ( tmp > electronicMax)
    568558      this->electronicCur = this->electronicMax;
    569559    else
    570       this->electronicCur += this->electronicRegen * time;
    571   }
    572 }
    573 
     560      this->electronicCur = tmp;
     561  }
     562}
Note: See TracChangeset for help on using the changeset viewer.