Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 27, 2017, 3:08:16 PM (7 years ago)
Author:
jkindle
Message:

Added a HUD and type to QBlocks

Location:
code/branches/SuperOrxoBros_FS17/src/modules/superorxobros
Files:
2 added
11 edited

Legend:

Unmodified
Added
Removed
  • code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/CMakeLists.txt

    r11402 r11405  
    77  SOBQBlock.cc
    88  SOBMushroom.cc
     9  SOBHUDInfo.cc
    910
    1011)
  • code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/Orxo.h

    r11392 r11405  
    4444    class Orxo : public SpaceShip
    4545    {
    46         public:
    47             Orxo(Context* context);
     46    public:
     47        Orxo(Context* context);
    4848
    49             virtual void tick(float dt) override;
     49        virtual void tick(float dt) override;
    5050
    5151
    5252            // overwrite for 2d movement
    53             virtual void moveFrontBack(const Vector2& value) override;
    54             virtual void moveRightLeft(const Vector2& value) override;
     53        virtual void moveFrontBack(const Vector2& value) override;
     54        virtual void moveRightLeft(const Vector2& value) override;
    5555
    5656            // Starts or stops fireing
    57             virtual void boost(bool bBoost) override;
     57        virtual void boost(bool bBoost) override;
    5858
    5959            //no rotation!
    60             virtual void rotateYaw(const Vector2& value) override{};
    61             virtual void rotatePitch(const Vector2& value) override{};
     60        virtual void rotateYaw(const Vector2& value) override{};
     61        virtual void rotatePitch(const Vector2& value) override{};
    6262            //return to main menu if game has ended.
    63             virtual void rotateRoll(const Vector2& value) override;
     63        virtual void rotateRoll(const Vector2& value) override;
    6464
    65             virtual void updateLevel();
     65        virtual void updateLevel();
    6666
    67             virtual inline bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) override;
     67        virtual inline bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) override;
    6868
    69         protected:
    70             virtual void death() override;
    71         private:
     69
     70
     71
     72     
     73
     74
     75    protected:
     76        virtual void death() override;
     77    private:
    7278            //SOB* getGame();
    7379            //WeakPtr<SOB> game;
    74             Camera* camera;
    75             float speed, damping, posforeward;
    76             float lastTimeFront, lastTimeLeft, lastTime;
    77             struct Velocity
    78             {
    79                 float x;
    80                 float y;
    81             } velocity, desiredVelocity;
     80        Camera* camera;
     81        float speed, damping, posforeward;
     82        float lastTimeFront, lastTimeLeft, lastTime;
     83        struct Velocity
     84        {
     85            float x;
     86            float y;
     87        } velocity, desiredVelocity;
    8288
    8389           // WeakPtr<InvaderEnemy> lastEnemy;
  • code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOB.cc

    r11402 r11405  
    6464        this->center_ = nullptr;
    6565        figure_ = nullptr;
    66         setHUDTemplate("JumpHUD");
     66        setHUDTemplate("SOBHUD");
     67        coins_=0;
     68        points_=0;
     69        timeLeft_=400.0;
    6770
    6871    }
     
    105108
    106109        // Call start for the parent class.
    107         Deathmatch::start();
     110        Gametype::start();
    108111
    109112        if (figure_ != nullptr)
     
    152155            orxout() << "DEED" << endl;
    153156       
     157
     158       timeLeft_-=dt*2.5;
    154159    }
    155160
  • code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOB.h

    r11402 r11405  
    4646{
    4747
    48  
     48
    4949    class _SOBExport SOB : public Deathmatch
    5050    {
    51         public:
     51    public:
    5252            SOB(Context* context); //!< Constructor. Registers and initializes the object.
    5353            virtual ~SOB(); //!< Destructor. Cleans up, if initialized.
    5454            virtual void tick(float dt) override;
    5555
    56        
     56
    5757            void setCenterpoint(SOBCenterpoint* center)
    58                 { this->center_ = center; }
    59                 virtual void start() override;
     58            { this->center_ = center; }
     59            virtual void start() override;
    6060            virtual void end() override;
    6161            virtual void spawnPlayer(PlayerInfo* player) override;
    62                         PlayerInfo* getPlayer() const;
     62            PlayerInfo* getPlayer() const;
    6363
    64        
    65          
     64            int getPoints() {
     65                return points_;
     66            }
     67            int getCoins() {
     68                return coins_;
     69            }
     70            void addCoin() {
     71                ++coins_;
     72                points_+=200;
     73            }
     74            void addMushroom() {
     75                points_+=1000;
     76            }
     77            int getTimeLeft() {
     78                return timeLeft_;
     79            }
     80           
     81
     82           virtual void playerEntered(PlayerInfo* player) override
     83            {
     84                Gametype::playerEntered(player);
     85            } 
     86
     87
     88            WeakPtr<SOBCenterpoint> center_;
     89
    6690        protected:
    67        
     91
    6892
    6993            void cleanup(); //!< Cleans up the Gametype
    70              WeakPtr<SOBCenterpoint> center_;
    7194            WeakPtr<SOBFigure> figure_;
    7295            WeakPtr<Camera> camera;
    73        
    74          
    75     };
    76 }
     96            int points_;
     97            int coins_;
     98            float timeLeft_;
     99
     100
     101        };
     102    }
    77103
    78104#endif /* _Pong_H__ */
  • code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBFigure.cc

    r11402 r11405  
    4141
    4242#include "SOBMushroom.h"
     43#include "SOB.h"
    4344
    4445namespace orxonox
     
    6667
    6768        dead_ = false;
     69        gotPowerUp_ = false;
     70       
    6871        setAngularFactor(0.0);
    69          this->enableCollisionCallback();
     72        this->enableCollisionCallback();
    7073    }
    7174
     
    7679        isColliding_ = true;
    7780        SOBMushroom* mush = orxonox_cast<SOBMushroom*>(otherObject);
    78         if (mush != nullptr) {
    79             orxout() << "YEPPIE" << endl;
    80             //DESTROY THE OTHER OBJECT otherObject.destroyLater();
    81         }
    82 
    83 return true;
     81        // ADD ANOTHER OBJECT FOR BAD GUMBAS AND REMOVE POWERUP OR KILL PLAYER ON COLLISION WITHOUT Z-ACCELERATION
     82        if (mush != nullptr && !(mush->hasCollided_)) {
     83            otherObject->destroyLater();
     84            gotPowerUp_ = true;
     85            SOB* SOBGame = orxonox_cast<SOB*>(getGametype());
     86            SOBGame->addMushroom();
     87            mush->hasCollided_ = true;
     88
     89        }
     90
     91        return true;
    8492    }
    8593
     
    101109            for (WorldEntity* object : this->getAttachedObjects())
    102110            {
    103                  if (object->isA(Class(ParticleSpawner)))
    104                     particlespawner_ = object;
    105                    
    106             }
    107  
    108         }
    109        
    110 
    111 
    112 
    113 
    114 
    115         if (firePressed_ == false) {
    116              gravityAcceleration_ = 350.0;
    117 
    118         }
    119 
    120         if (hasLocalController())
    121         {
    122           Vector3 velocity = getVelocity();
    123           Vector3 position = getPosition();
    124 
    125 
    126           if (position.z < -100)
    127             dead_ = true;
    128 
    129           if (dead_) {
    130             velocity.x = 0;
    131             velocity.z = 0;
    132             setVelocity(velocity);
    133             return;
    134         }
    135 
    136 
    137         int maxvelocity_x = 100;
    138         int speedAddedPerTick = 5;
    139         int camMaxOffset = 25;
    140 
    141         timeSinceLastFire_ += dt;
    142         lastSpeed_z = velocity.z;
     111               if (object->isA(Class(ParticleSpawner)))
     112                particlespawner_ = object;
     113
     114        }
     115
     116    }
     117
     118
     119
     120
     121
     122
     123    if (firePressed_ == false) {
     124       gravityAcceleration_ = 350.0;
     125
     126   }
     127
     128   if (hasLocalController())
     129   {
     130      Vector3 velocity = getVelocity();
     131      Vector3 position = getPosition();
     132
     133
     134      if (position.z < -100)
     135        dead_ = true;
     136
     137    if (dead_) {
     138        velocity.x = 0;
     139        velocity.z = 0;
     140        setVelocity(velocity);
     141        return;
     142    }
     143
     144
     145    int maxvelocity_x = 100;
     146    int speedAddedPerTick = 5;
     147    int camMaxOffset = 25;
     148
     149    timeSinceLastFire_ += dt;
     150    lastSpeed_z = velocity.z;
    143151
    144152
    145153
    146154        //Handle the rocket fire from the jetpack
    147         if (velocity.z > 40)
    148             particlespawner_->setVisible(true);
    149         else
    150             particlespawner_->setVisible(false);
     155    if (velocity.z > 40)
     156        particlespawner_->setVisible(true);
     157    else
     158        particlespawner_->setVisible(false);
    151159
    152160        //If player hits space and does not move in z-dir
    153         if (firePressed_ && isColliding_ && std::abs(velocity.z) < 0.1 && std::abs(lastSpeed_z) < 0.1) {
    154             gravityAcceleration_ = 100.0;
     161    if (firePressed_ && isColliding_ && std::abs(velocity.z) < 0.1 && std::abs(lastSpeed_z) < 0.1) {
     162        gravityAcceleration_ = 100.0;
    155163            velocity.z = 110; //150
    156164        }
     
    163171        if (moveRightPressed_) {
    164172            if (rot < 0.0)
    165                     setOrientation(Vector3::UNIT_Z, getOrientation().getRoll() + dt*Radian(6));
     173                setOrientation(Vector3::UNIT_Z, getOrientation().getRoll() + dt*Radian(6));
    166174
    167175            if (std::abs(velocity.x) < maxvelocity_x) {
     
    178186        } else if (moveLeftPressed_) {
    179187            if (rot >= 0.0)
    180                     setOrientation(Vector3::UNIT_Z, getOrientation().getRoll() + dt*Radian(6));
     188                setOrientation(Vector3::UNIT_Z, getOrientation().getRoll() + dt*Radian(6));
    181189
    182190            if (std::abs(velocity.x) < maxvelocity_x) {
     
    200208            cam->setPosition(campos);
    201209        }
    202            if (campos.x - camMaxOffset > position.x) {
     210        if (campos.x - camMaxOffset > position.x) {
    203211            campos.x = position.x + camMaxOffset;
    204212            cam->setPosition(campos);
  • code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBFigure.h

    r11400 r11405  
    6161        private:
    6262           
     63            bool gotPowerUp_;
    6364            bool moveUpPressed_;
    6465            bool moveDownPressed_;
  • code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBMushroom.cc

    r11402 r11405  
    5454        gravityAcceleration_ = 350.0;
    5555        speed_ = 0.0;
     56        hasCollided_=false;
    5657       
    5758    }
  • code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBMushroom.h

    r11402 r11405  
    6060                { return speed_; }
    6161
    62 
     62            bool hasCollided_;
    6363        protected:
    6464            float gravityAcceleration_;
  • code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBPrereqs.h

    r11402 r11405  
    8080    class SOBQBlock;
    8181    class SOBMushroom;
     82    class SOBHUDInfo;
    8283    /*
    8384    class PongScore;*/
  • code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBQBlock.cc

    r11400 r11405  
    3535
    3636#include "core/CoreIncludes.h"
     37#include "core/XMLPort.h"
     38#include "SOB.h"
     39#include "SOBMushroom.h"
    3740
    3841namespace orxonox
     
    6265        if (!used_ && v_z > 50.0) {
    6366            used_ = true;
    64         orxout() << "WDestrozed the block" << v_z << endl;
    6567
    66           for (WorldEntity* object : this->getAttachedObjects())
    67             {
    68                
    69                    
    70                 object->setVisible(!object->isVisible());   
     68            for (WorldEntity* object : this->getAttachedObjects())
     69                object->setVisible(!object->isVisible());           
     70
     71            SOB* SOBGame = orxonox_cast<SOB*>(getGametype());
     72            if (type_ == "Coin") {
     73                SOBGame->addCoin();
    7174            }
    72 
    73 
     75            if (type_ == "Mushroom") {
     76                spawnMushroom();
     77            }
    7478
    7579        }
     
    7882
    7983
     84    void SOBQBlock::XMLPort(Element& xmlelement, XMLPort::Mode mode)
     85    {
     86        SUPER(SOBQBlock, XMLPort, xmlelement, mode);
     87        XMLPortParam(SOBQBlock, "type",     setType,     getType,     xmlelement, mode).defaultValues(false);
     88
     89
     90     }
     91
     92
     93     void SOBQBlock::spawnMushroom() {
     94        SOBCenterpoint* center_ = ((SOB*)getGametype())->center_;
     95
     96         SOBMushroom* mush = new SOBMushroom(center_->getContext());
     97         Vector3 spawnpos = this->getWorldPosition();
     98         spawnpos.z += 0;
     99
     100        if (mush != nullptr && center_ != nullptr)
     101        {
     102            mush->addTemplate("mushroom");
     103           
     104
     105
     106            //newBoots->addTemplate(center_->getBootsTemplate());
     107            mush->setPosition(spawnpos);
     108            //newBoots->setProperties(leftBoundary, rightBoundary, lowerBoundary, upperBoundary, xVelocity, zVelocity);
     109            //newBoots->setFigure(figure_);
     110            //center_->attach(newBoots);
     111        }
     112     }
     113
     114
    80115}
  • code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBQBlock.h

    r11400 r11405  
    4141            virtual ~SOBQBlock();
    4242            virtual  bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) override;
     43            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
    4344
     45            void setType(std::string type) {
     46                this->type_=type;
     47            }
     48            std::string getType() {
     49                return this->type_;
     50            }
    4451        protected:
    4552            bool used_;
     53            std::string type_;
     54            void spawnMushroom();
    4655    };
    4756           
Note: See TracChangeset for help on using the changeset viewer.