当前位置: 首页>>代码示例>>C++>>正文


C++ Opt::GetSpeed方法代码示例

本文整理汇总了C++中Opt::GetSpeed方法的典型用法代码示例。如果您正苦于以下问题:C++ Opt::GetSpeed方法的具体用法?C++ Opt::GetSpeed怎么用?C++ Opt::GetSpeed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Opt的用法示例。


在下文中一共展示了Opt::GetSpeed方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Update

void AccelerationSystem::Update( double DeltaTime )
{
    for( ActorList_t::iterator it = mScene.GetActors().begin(), e = mScene.GetActors().end(); it != e; ++it )
    {
        Actor& actor = **it;
        Opt<IMoveComponent> moveC = actor.Get<IMoveComponent>();
        if ( !moveC.IsValid() )
        {
            continue;
        }
        Opt<IAccelerationComponent> accelerationC = actor.Get<IAccelerationComponent>();
        if ( !accelerationC.IsValid() )
        {
            continue;
        }

        double speed = moveC->GetSpeed().mBase.Get();
        double acceleration = accelerationC->GetAcceleration();
        speed += acceleration * DeltaTime;
        speed = ( acceleration > 0.0 ) ?
                std::min( speed, accelerationC->GetMaxSpeed() ) :
                std::max( speed, accelerationC->GetMinSpeed() );
        moveC->GetSpeed().mBase.Set( speed );
    }

}
开发者ID:abannerth,项目名称:Reaping2,代码行数:26,代码来源:acceleration_system.cpp

示例2: Collide

void BounceCollisionSubSystem::Collide( Actor& actor, Actor& other )
{
    Opt<BounceCollisionComponent> bounceCC = actor.Get<BounceCollisionComponent>();
    if (mShotCollisionSubSystem.IsValid() && bounceCC->IsUseShotCollision())
    {
        mShotCollisionSubSystem->Collide(actor, other);
    }
    //TODO: for now its wallcc should be a bouncableComponent or this should be a collision class
    Opt<WallCollisionComponent> wallCC = other.Get<WallCollisionComponent>();
    if( !wallCC.IsValid() )
    {
        return;
    }
    Opt<IPositionComponent> positionC = actor.Get<IPositionComponent>();
    Opt<IMoveComponent> moveC = actor.Get<IMoveComponent>();

    Opt<IPositionComponent> otherPositionC = other.Get<IPositionComponent>();
    Opt<ICollisionComponent> otherCC = other.Get<ICollisionComponent>();
    if ( !otherPositionC.IsValid() || !otherCC.IsValid() || !positionC.IsValid() )
    {
        return;
    }
    double const dx = otherPositionC->GetX() - positionC->GetX();
    double const dy = otherPositionC->GetY() - positionC->GetY();

    const double h = moveC->GetHeading();
    double c = cos( h );
    double s = sin( h );
    double at = atan2( s, c );
    double at2 = atan2( c, s );
    if( std::abs( dx ) > std::abs( dy ) )
    {
        c *= -1;
    }
    else if( std::abs( dx ) < std::abs( dy ) )
    {
        s *= -1;
    }
    moveC->SetHeading( atan2( s, c ) );
    moveC->GetSpeed().mBase.Set( moveC->GetSpeed().mBase.Get() * ( 1.0 - bounceCC->GetSpeedLossPercent() ) );
    if (bounceCC->GetHitCountToKill() > 0)
    {
        bounceCC->SetHitCountToKill(bounceCC->GetHitCountToKill() - 1);
    }
    if (bounceCC->IsResetActorsCollidedOnBounce())
    {
        bounceCC->ResetDamagedActorIds();
    }
}
开发者ID:abannerth,项目名称:Reaping2,代码行数:49,代码来源:bounce_collision_sub_system.cpp

示例3: rotateMsg

std::auto_ptr<RotateMessage> RotateMessageSenderSystem::GenerateRotateMessage(Actor &actor)
{
    Opt<IRotateComponent> rotateC = actor.Get<IRotateComponent>();
    if (!rotateC.IsValid())
    {
        return std::auto_ptr<RotateMessage>();
    }
    std::auto_ptr<RotateMessage> rotateMsg(new RotateMessage);
    rotateMsg->mActorGUID=actor.GetGUID();
    rotateMsg->mSpeed=rotateC->GetSpeed();
    rotateMsg->mRotating=rotateC->IsRotating();
    return rotateMsg;
}
开发者ID:HalalUr,项目名称:Reaping2,代码行数:13,代码来源:rotate_message.cpp


注:本文中的Opt::GetSpeed方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。