Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 22, 2010, 10:45:09 PM (15 years ago)
Author:
ebeier
Message:

first working version of the SpeedPickup, needs some more work for "onUse" type. Spaceship trails need to be looked at, because they don't show when a SpeedPickup with SpeedAdd is used.

Location:
code/branches/ppspickups1/src/orxonox
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • code/branches/ppspickups1/src/orxonox/interfaces/PickupCarrier.h

    r6540 r6607  
    4848{
    4949
    50     //! Pre-declarations.
    51     class Pickup;
    52     class HealthPickup;
    53     class MetaPickup;
    54 
    5550    /**
    5651    @brief
     
    6661        friend class HealthPickup;
    6762        friend class MetaPickup;
    68        
     63        friend class SpeedPickup;
     64
    6965        public:
    7066            PickupCarrier(); //!< Constructor.
    7167            virtual ~PickupCarrier(); //!< Destructor.
    72            
     68
    7369            /**
    7470            @brief Can be called to pick up a Pickupable.
     
    8682                    return pickedUp;
    8783                }
    88                
     84
    8985            /**
    9086            @brief Can be called to drop a Pickupable.
     
    9490            */
    9591            bool drop(Pickupable* pickup, bool drop = true)
    96                 { 
     92                {
    9793                    bool dropped = this->pickups_.erase(pickup) == 1;
    9894                    if(dropped && drop)
     
    10399                    return dropped;
    104100                }
    105                
     101
    106102            /**
    107103            @brief Can be used to check whether the PickupCarrier or a child of his is a target ot the input Pickupable.
     
    113109                    if(pickup->isTarget(this)) //!< If the PickupCarrier itself is a target.
    114110                        return true;
    115                    
     111
    116112                    //! Go recursively through all children to check whether they are a target.
    117113                    std::list<PickupCarrier*>* children = this->getCarrierChildren();
     
    121117                            return true;
    122118                    }
    123                    
     119
    124120                    children->clear();
    125121                    delete children;
    126                    
     122
    127123                    return false;
    128124                }
    129                
     125
    130126            /**
    131127            @brief Get the carrier that is both a child of the PickupCarrier (or the PickupCarrier itself) and a target of the input Pickupable.
     
    137133                    if(!this->isTarget(pickup))
    138134                        return NULL;
    139                    
     135
    140136                    if(pickup->isTarget(this)) //!< If the PickupCarrier itself is a target.
    141137                        return this;
    142                    
     138
    143139                    //! Go recursively through all children to check whether they are the target.
    144140                    std::list<PickupCarrier*>* children = this->getCarrierChildren();
     
    148144                            return *it;
    149145                    }
    150                    
     146
    151147                    children->clear();
    152148                    delete children;
    153                    
     149
    154150                    return NULL;
    155151                }
    156                
     152
    157153            /**
    158154            @brief Get the (absolute) position of the PickupCarrier.
     
    161157            */
    162158            virtual const Vector3& getCarrierPosition(void) = 0;
    163            
    164         protected:       
     159
     160        protected:
    165161            /**
    166162            @brief Get all direct children of this PickupSpawner.
    167163                   This method needs to be implemented by any direct derivative class of PickupCarrier.
    168164                   The returned list will be deleted by the methods calling this function.
    169             @return Returns a pointer to a list of all direct children. 
     165            @return Returns a pointer to a list of all direct children.
    170166            */
    171167            virtual std::list<PickupCarrier*>* getCarrierChildren(void) = 0;
     
    176172            */
    177173            virtual PickupCarrier* getCarrierParent(void) = 0;
    178                            
     174
    179175            /**
    180176            @brief Get all Pickupables this PickupCarrier has.
     
    183179            std::set<Pickupable*>& getPickups(void)
    184180                { return this->pickups_; }
    185        
     181
    186182        private:
    187183            std::set<Pickupable*> pickups_; //!< The list of Pickupables carried by this PickupCarrier.
    188            
     184
    189185    };
    190186}
  • code/branches/ppspickups1/src/orxonox/items/Engine.cc

    r6540 r6607  
    6464        this->boostBlur_ = 0;
    6565
     66        this->speedAdd_ = 0.0;
     67        this->speedMultiply_ = 1.0;
     68
    6669        this->setConfigValues();
    6770        this->registerVariables();
     
    119122        registerVariable(this->accelerationLeftRight_, VariableDirection::ToClient);
    120123        registerVariable(this->accelerationUpDown_,    VariableDirection::ToClient);
     124
     125        registerVariable(this->speedAdd_, VariableDirection::ToClient);
     126        registerVariable(this->speedMultiply_, VariableDirection::ToClient);
    121127    }
    122128
     
    192198        }
    193199
    194         this->ship_->setAcceleration(this->ship_->getOrientation() * acceleration);
     200        this->ship_->setAcceleration(this->ship_->getOrientation() * (acceleration*this->getSpeedMultiply()+Vector3(0,0,-this->getSpeedAdd())));
    195201
    196202        if (!this->ship_->getPermanentBoost())
     
    241247            return Vector3::ZERO;
    242248    }
     249
     250    PickupCarrier* Engine::getCarrierParent(void)
     251    {
     252        return this->ship_;
     253    }
     254
     255    const Vector3& Engine::getCarrierPosition(void)
     256    {
     257        return this->ship_->getWorldPosition();
     258    }
    243259}
  • code/branches/ppspickups1/src/orxonox/items/Engine.h

    r6417 r6607  
    3535#include "Item.h"
    3636
     37#include "interfaces/PickupCarrier.h"
     38
    3739namespace orxonox
    3840{
    39     class _OrxonoxExport Engine : public Item, public Tickable
     41    class _OrxonoxExport Engine : public Item, public Tickable, public PickupCarrier
    4042    {
    4143        public:
     
    104106                { return this->accelerationUpDown_; }
    105107
     108            inline float getSpeedAdd(void)
     109                { return this->speedAdd_; }
     110            inline float getSpeedMultiply(void)
     111                { return this->speedMultiply_; }
     112
    106113            virtual const Vector3& getDirection() const;
     114
     115            virtual const Vector3& getCarrierPosition(void);
     116
     117            /* not in protected ?? */
     118            inline void setSpeedAdd(float speedAdd)
     119                { this->speedAdd_=speedAdd; }
     120            inline void setSpeedMultiply(float speedMultiply)
     121                { this->speedMultiply_=speedMultiply; }
     122
     123        protected:
     124            virtual std::list<PickupCarrier*>* getCarrierChildren(void)
     125                { return new std::list<PickupCarrier*>(); }
     126            virtual PickupCarrier* getCarrierParent(void);
    107127
    108128        private:
     
    114134            float boostFactor_;
    115135            float speedFactor_;
     136
     137            float speedAdd_;
     138            float speedMultiply_;
    116139
    117140            float maxSpeedFront_;
  • code/branches/ppspickups1/src/orxonox/worldentities/pawns/SpaceShip.cc

    r6417 r6607  
    220220            engine->addToSpaceShip(this);
    221221    }
     222
     223    std::list<PickupCarrier*>* SpaceShip::getCarrierChildren(void)
     224    {
     225        std::list<PickupCarrier*>* list = new std::list<PickupCarrier*>();
     226        list->push_front(engine_);
     227        return list;
     228    }
    222229}
  • code/branches/ppspickups1/src/orxonox/worldentities/pawns/SpaceShip.h

    r5781 r6607  
    8686
    8787        protected:
     88            virtual std::list<PickupCarrier*>* getCarrierChildren(void);
    8889            bool bInvertYAxis_;
    8990
Note: See TracChangeset for help on using the changeset viewer.