示例#1
0
void CCSceneMoveable::updateMovement(const float delta)
{	
    if( moveable )
    {
        const float movementMagnitude = applyMovementDirection( delta );
        velocity = movementVelocity;

        const float additionalMagnitude = CCVector3LengthSquared( additionalVelocity );
        if( additionalMagnitude > 0.0f )
        {
            velocity.add( additionalVelocity );
            const float deceleration = decelerationSpeed * delta;
            CCToTarget( additionalVelocity.x, 0.0f, deceleration );
            CCToTarget( additionalVelocity.y, 0.0f, deceleration );
            CCToTarget( additionalVelocity.z, 0.0f, deceleration );
        }

        const float velocityMagnitude = CCVector3LengthSquared( velocity );
        if( velocityMagnitude > 0.0f )
        {
            applyVelocity( delta, movementMagnitude );

            dirtyModelMatrix();
            updateCollisions = true;
            CCOctreeRefreshObject( this );
        }
    }
}
示例#2
0
void Projectile::fire(int angle, int speed) {
	applyVelocity(speed * cos(angle * PI / 180.0), LR);
	applyVelocity(speed * sin(angle * PI / 180.0), UD);
}