Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Feb 18, 2018, 4:02:50 PM (6 years ago)
Author:
landauf
Message:

merged SOBv2_HS17

Location:
code/branches/Presentation_HS17_merge
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/Presentation_HS17_merge

  • code/branches/Presentation_HS17_merge/src/modules/superorxobros/SOBGumba.cc

    r11416 r11766  
    6060        changeAllowed_ = true;
    6161        changedOn_ = 0.0;
     62        creator_ = nullptr;
     63        maxLifetime_ = 10;
     64        lifetime_ = 0;
    6265       
    6366    }
     
    9194    }
    9295
     96    void SOBGumba::setDirection(const bool direction)
     97    {
     98        if(direction)
     99        {
     100            goesRight_=true;
     101        }
     102        else
     103        {
     104            goesRight_=false;
     105        }
     106    }
    93107
     108    void SOBGumba::die(){
     109        Vector3 velocity = this->getVelocity();
     110        velocity.y = speed_;
     111        this->setVelocity(velocity);
     112    }
    94113
    95114    void SOBGumba::tick(float dt)
     
    100119            changedOn_+= dt;
    101120            // After a collision, we don't listen for collisions for 200ms - that's because one wall can cause several collisions!
    102             if (changedOn_> 0.200) {
     121            if (changedOn_> 0.400) {
    103122                changeAllowed_ = true;
    104123                changedOn_ = 0.0;
     
    106125            }
    107126        }
    108        
     127   
    109128
    110129        int dir = 1;
     
    113132
    114133        Vector3 velocity = getVelocity();
     134        if(velocity.z > -1 && velocity.z < 1)
     135        {
     136            velocity.x = dir*speed_;
     137        }     
     138
    115139        velocity.z -= gravityAcceleration_*dt;
    116         velocity.x = dir*speed_;
    117140        setVelocity(velocity);
    118141
    119142        lastPos_ = getPosition();
     143
     144        if (creator_ != nullptr)
     145        {
     146            lifetime_ += dt;
     147            if(lifetime_>maxLifetime_)
     148            {
     149               
     150            }
     151        }
     152
     153        if(abs(this->getPosition().z) > 1000) delete this;
     154
    120155    }
    121 
    122 
    123156}
Note: See TracChangeset for help on using the changeset viewer.