Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jul 3, 2011, 5:42:19 PM (13 years ago)
Author:
dafrick
Message:

Cleaning up in SpaceShip and Engine. Fixed several bugs.
Kicked localLinearAcceleration, primaryThrust and auxiliaryThrust out of the SpaceShip, since it wasn't used anymore.
Moved the trail lights back a bit.
Added some documentation to SpaceShip and Engine.
SpeedPickup is working again, will need some further tuning.

Location:
code/trunk/src/modules/pickup/items
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/modules/pickup/items/SpeedPickup.cc

    r7548 r8727  
    3838#include "core/XMLPort.h"
    3939
    40 #include "items/Engine.h"
    4140#include "pickup/PickupIdentifier.h"
    4241#include "worldentities/pawns/SpaceShip.h"
     
    7675        this->speedMultiply_ = 1.0f;
    7776
    78         this->addTarget(ClassIdentifier<Engine>::getIdentifier());
     77        this->addTarget(ClassIdentifier<SpaceShip>::getIdentifier());
    7978    }
    8079
     
    127126        SUPER(SpeedPickup, changedUsed);
    128127
    129         Engine* engine = this->carrierToEngineHelper();
    130         if(engine == NULL) // If the PickupCarrier is no Engine, then this pickup is useless and therefore is destroyed.
     128        SpaceShip* ship = this->carrierToSpaceShipHelper();
     129        if(ship == NULL) // If the PickupCarrier is no SpaceShip, then this pickup is useless and therefore is destroyed.
    131130            this->Pickupable::destroy();
    132131
     
    147146            }
    148147
    149             engine->setSpeedAdd(this->getSpeedAdd());
    150             engine->setSpeedMultiply(this->getSpeedMultiply());
    151         }
    152         else
    153         {
    154             engine->setSpeedAdd(0.0f);
    155             engine->setSpeedMultiply(1.0f);
     148            ship->addSpeed(this->getSpeedAdd());
     149            ship->addSpeedFactor(this->getSpeedMultiply());
     150        }
     151        else
     152        {
     153            ship->addSpeed(-this->getSpeedAdd());
     154            ship->addSpeedFactor(1.0f/this->getSpeedMultiply());
    156155
    157156            // We destroy the pickup if either, the pickup has activationType immediate and durationType once or it has durationType continuous and the duration was exceeded.
     
    170169    /**
    171170    @brief
    172         Helper to transform the PickupCarrier to a Pawn, and throw an error message if the conversion fails.
     171        Helper to transform the PickupCarrier to a SpaceShip, and throw an error message if the conversion fails.
    173172    @return
    174         A pointer to the Pawn, or NULL if the conversion failed.
    175     */
    176     Engine* SpeedPickup::carrierToEngineHelper(void)
     173        A pointer to the SpaceShip, or NULL if the conversion failed.
     174    */
     175    SpaceShip* SpeedPickup::carrierToSpaceShipHelper(void)
    177176    {
    178177        PickupCarrier* carrier = this->getCarrier();
    179         Engine* engine = dynamic_cast<Engine*>(carrier);
    180 
    181         if(engine == NULL)
     178        SpaceShip* ship = dynamic_cast<SpaceShip*>(carrier);
     179
     180        if(ship == NULL)
    182181        {
    183182            COUT(1) << "Invalid PickupCarrier in SpeedPickup." << std::endl;
    184183        }
    185184
    186         return engine;
     185        return ship;
    187186    }
    188187
  • code/trunk/src/modules/pickup/items/SpeedPickup.h

    r7547 r8727  
    112112        private:
    113113            void initialize(void); //!< Initializes the member variables.
    114             Engine* carrierToEngineHelper(void); //!< Helper to transform the PickupCarrier to a Pawn, and throw an error message if the conversion fails.
     114            SpaceShip* carrierToSpaceShipHelper(void); //!< Helper to transform the PickupCarrier to a SpaceSHip, and throw an error message if the conversion fails.
    115115
    116116            Timer durationTimer_; //!< Timer.
Note: See TracChangeset for help on using the changeset viewer.