Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 11654


Ignore:
Timestamp:
Dec 11, 2017, 3:17:02 PM (6 years ago)
Author:
varxth
Message:

better than evverevver

Location:
code/branches/SOBv2_HS17/src/modules/superorxobros
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/branches/SOBv2_HS17/src/modules/superorxobros/SOBGumba.cc

    r11651 r11654  
    106106    }
    107107
     108    void SOBGumba::die(){
     109        Vector3 velocity = this->getVelocity();
     110        velocity.y = speed_;
     111        this->setVelocity(velocity);
     112    }
     113
    108114    void SOBGumba::tick(float dt)
    109115    {
     
    141147            if(lifetime_>maxLifetime_)
    142148            {
    143                 this->destroyLater();
     149               
    144150            }
    145151        }
    146152
     153        if(abs(this->getPosition().z) > 1000) delete this;
     154
    147155    }
    148156}
  • code/branches/SOBv2_HS17/src/modules/superorxobros/SOBGumba.h

    r11651 r11654  
    5252
    5353            void setDirection(const bool direction);
     54            void die();
    5455         
    5556            bool attachedToFigure_;
  • code/branches/SOBv2_HS17/src/modules/superorxobros/SOBGumbaBoss.cc

    r11653 r11654  
    5454        RegisterObject(SOBGumbaBoss);
    5555
    56         gumbaMaxTime_   = 1;
    57         gumbaTime_      = 0;
    58         maxGumbas_      = 10; //Max Gumbas spawnable by a Boss
    59         jumpTime_       = 0;
    60         jumpTimeMax_    = 5;
     56        gumbaMaxTime_   = 1;  // time after which a Gumba is shot
     57        gumbaTime_      = 0;  // time since last gumba was shot
     58        maxGumbas_      = 50; // Max Gumbas spawnable by a Boss
     59        jumpTimeMax_    = 5;  // time after which the gumba boss jumps
     60        jumpTime_       = 0;  // time since last jump of gumba boss
    6161       
    6262    }
    6363
    64    
     64    // PRE: otherObject collides with this.
     65    // POST: collision is handled: velocity changed, small gumbas murdered
    6566    bool SOBGumbaBoss::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) {
    6667
     
    6869        SOBGumbaBoss*   gumbaBoss   = orxonox_cast<SOBGumbaBoss*>(otherObject);
    6970
     71        // if boss collides with small gumbas, destroy them.
    7072        if (gumba != nullptr && gumbaBoss == nullptr && !(gumba->hasCollided_)) {
    71             gumba->destroyLater();
    72             gumba->hasCollided_ = true;
     73            gumba->die();
    7374        }
    7475
     
    8586
    8687
    87 
     88    // POST: done what was to do in a time dt
    8889    void SOBGumbaBoss::tick(float dt)
    8990    {
    9091        SUPER(SOBGumbaBoss, tick, dt);
     92
     93        // increase timers:
    9194        gumbaTime_ += dt;
    9295        jumpTime_  += dt;
     96
     97        // set y-component of position of gumba boss to 0, so he doesn't fall in to the nothing
     98        Vector3 position = getPosition();
     99        position.y = 0;
     100        setPosition(position);
     101
    93102
    94103        if (!changeAllowed_) {
     
    125134            dir = -1;
    126135
    127         Vector3 velocity = getVelocity(); //Jump
    128         if(jumpTime_ > jumpTimeMax_){
     136        //
     137        if(getPosition().x < 1640)
     138            dir = 1;
     139        else if (getPosition().x > 1750)
     140            dir = -1;
     141
     142        //change velocity
     143        Vector3 velocity = getVelocity();
     144        if(jumpTime_ > jumpTimeMax_){ // jump if the time has come.
    129145            velocity.z = speed_*15;
    130146            jumpTime_ = 0;
    131147        }
    132         else{       //Gravity
     148        else{
    133149            velocity.z -= gravityAcceleration_*dt;
    134150        }
    135 
    136151        velocity.x = dir*speed_;
    137152        setVelocity(velocity);
     
    140155
    141156    }
     157
     158    // spawn gumbas
    142159    void SOBGumbaBoss::spawnGumba() {
    143160        SOBCenterpoint* center_ = ((SOB*)getGametype())->center_;
     
    145162         SOBGumba* gumba = new SOBGumba(center_->getContext());
    146163         Vector3 spawnpos = this->getWorldPosition();
    147          spawnpos.z += 0;
    148164         gumba->creator_=this;
    149165
     166         // we can shoot a gumba!
    150167        if (gumba != nullptr && center_ != nullptr)
    151168        {
Note: See TracChangeset for help on using the changeset viewer.