Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 24, 2009, 11:53:09 PM (15 years ago)
Author:
bknecht
Message:

introducing the bouncing pickup

Location:
code/branches/pickups2/src/orxonox/objects/pickup
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/pickups2/src/orxonox/objects/pickup/PickupSpawner.cc

    r2917 r3046  
    4444namespace orxonox
    4545{
     46    const float PickupSpawner::bounceSpeed_s = 6.0f;
     47    const float PickupSpawner::rotationSpeed_s = 1.0f;
     48    const float PickupSpawner::bounceDistance_s = 4.0f;
     49
    4650    CreateFactory(PickupSpawner);
    4751
     
    5761        this->triggerDistance_ = 20;
    5862        this->respawnTime_ = 0.0f;
     63        this->tickSum_ = 0.0f;
    5964    }
    6065    //! Deconstructor.
     
    108113                    this->trigger(*it);
    109114            }
     115            this->yaw(Radian(rotationSpeed_s*dt));
     116            this->tickSum_ += bounceSpeed_s*dt;
     117            this->translate(Vector3(0,bounceDistance_s*dt*sin(this->tickSum_),0));
     118            if (this->tickSum_ > 2*Ogre::Math::PI)
     119                this->tickSum_ -= 2*Ogre::Math::PI;
    110120        }
    111121    }
  • code/branches/pickups2/src/orxonox/objects/pickup/PickupSpawner.h

    r3042 r3046  
    109109        float triggerDistance_;                 //!< Distance in which this gets triggered.
    110110
     111        /* Pickup animation */
     112        float tickSum_;                         //!< Adds up tick to use in sine movement
     113        static const float bounceSpeed_s;       //!< Speed of pickup to bounce up and down
     114        static const float bounceDistance_s;    //!< Distance the pickup bounces up and down
     115        static const float rotationSpeed_s;     //!< Rotation speed of pickup
     116
    111117        float respawnTime_;                     //!< Time after which this gets re-actived.
    112118        Timer<PickupSpawner> respawnTimer_;     //!< Timer used for re-activating.
Note: See TracChangeset for help on using the changeset viewer.