Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 11575


Ignore:
Timestamp:
Nov 20, 2017, 3:21:35 PM (6 years ago)
Author:
varxth
Message:

merged Fireball and player

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

Legend:

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

    r11573 r11575  
    4242#include "SOBMushroom.h"
    4343#include "SOBGumba.h"
     44#include "SOBFireball.h"
    4445#include "SOB.h"
    4546#include "SOBFlagstone.h"
     
    103104
    104105        //Orxocast returns object with casted type if otherObject has that class, and if not a nullptr
    105         SOBMushroom* mush = orxonox_cast<SOBMushroom*>(otherObject);
    106         SOBGumba* gumba = orxonox_cast<SOBGumba*>(otherObject);
    107         SOBFlagstone* flagstone = orxonox_cast<SOBFlagstone*>(otherObject);
    108         SOBCastlestone* castlestone = orxonox_cast<SOBCastlestone*>(otherObject);
     106        SOBMushroom*    mush        = orxonox_cast<SOBMushroom*>    (otherObject);
     107        SOBGumba*       gumba       = orxonox_cast<SOBGumba*>       (otherObject);
     108        SOBFlagstone*   flagstone   = orxonox_cast<SOBFlagstone*>   (otherObject);
     109        SOBCastlestone* castlestone = orxonox_cast<SOBCastlestone*> (otherObject);
     110        SOBFireball* fireball       = orxonox_cast<SOBFireball*>    (otherObject);
    109111
    110112        //Check if otherObject is a powerup
     
    122124        }
    123125       
     126
    124127        //Check if otherObject is a Gumba (that walking enemies)
    125128
     
    130133                // If player hasn't a power up, he dies. Else he shrinks and the gumba dies.
    131134                if(!gotPowerUp_){
    132                     Vector3 vel = getVelocity();
    133                     vel.y = -80;
    134                     vel.z = 200;
    135                     setVelocity(vel);
    136                     predead_=true;
    137                     SOB* SOBGame = orxonox_cast<SOB*>(getGametype());
    138                     SOBGame->setDone(true);
     135                    this->die();
    139136                } else{
    140137                    gotPowerUp_ = false;
     
    158155    }
    159156
     157        else if (fireball != nullptr && !(fireball->hasCollided_)){
     158            this-> die();
     159        }
     160
    160161    //Purpose is that if player hits the flag, he should walk into the castle at the end of the level. For that we use SOBCastlestone
    161162    if (reachedLvlEndState_ == 0 && flagstone != nullptr && !(flagstone->hasCollided_)) {
     
    440441}
    441442
    442 }
     443void SOBFigure::die(){
     444    Vector3 vel = getVelocity();
     445    vel.y = -80;
     446    vel.z = 200;
     447    setVelocity(vel);
     448    predead_=true;
     449    SOB* SOBGame = orxonox_cast<SOB*>(getGametype());
     450    SOBGame->setDone(true);
     451}
     452
     453}
  • code/branches/SOBv2_HS17/src/modules/superorxobros/SOBFigure.h

    r11573 r11575  
    4848            void changeClothes(std::string& name);
    4949            void spawnFireball();
     50            void die();
    5051
    5152            bool dead_;
  • code/branches/SOBv2_HS17/src/modules/superorxobros/SOBFireball.cc

    r11573 r11575  
    6767        collDisX_ = 0;
    6868        collDisZ_ = 0;
    69 
    70       orxout() << "fireball existed" << endl;
    71 
     69        hitCounter_ = 0;
    7270       
    7371    }
     
    9088        SOBGumba* gumba = orxonox_cast<SOBGumba*>(otherObject);
    9189
     90
    9291        if(gumba!=nullptr && !(gumba->hasCollided_)) //if other object is a Gumba, kill the Gumba and add score and destroy the fireball
    9392        {
     
    9998            this->hasCollided_ = true;
    10099        }
     100
     101
    101102         //collision with either top or bottom of a block
    102103        else if(changeAllowed_ && (abs(collDisX_)<=abs(collDisZ_)))
     
    104105            changeAllowed_ = false;
    105106            Vector3 velocity = getVelocity();
    106             orxout() << "before:    velocity in z = " << velocity.z << endl;
    107107            velocity.z = -velocity.z;
    108             orxout() << "after:     velocity in z = " << velocity.z << endl;
     108     
    109109
    110110            setVelocity(velocity);
     
    114114        else if(changeAllowed_ && (abs(collDisX_)>abs(collDisZ_)))
    115115        {
    116             orxout() << "collision with the vertical side of a block " << endl;
    117 
    118116            changeAllowed_ = false;
    119117            goesRight_=!goesRight_;
    120118        }
    121119
     120        hitCounter_++;
    122121       
    123122        return true;
     
    154153            velocity.x = dir*speed_;
    155154            velocity.y = 0;
     155            if(hitCounter_ >= 3) velocity.y = 50;
    156156            setVelocity(velocity);
    157157
    158158            lastPos_ = getPosition();
     159
     160            if(abs(this->getPosition().z) > 1000) delete this;
    159161       
    160162    }
  • code/branches/SOBv2_HS17/src/modules/superorxobros/SOBFireball.h

    r11573 r11575  
    7272            float changedOn_;
    7373            int hitCounter_;
     74 
    7475
    7576
Note: See TracChangeset for help on using the changeset viewer.