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


C++ WorldInterface::addExplosion方法代码示例

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


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

示例1: if

void Ship :: update (WorldInterface& r_world)
{
    if (isUnitAiSet())
    {
        if (!desired_velocity.isZero())
        {
            double theta = max_rotation_rate * TimeSystem::getFrameDuration();
            if(theta > 0.0)
            {
                rotateTowards(desired_velocity.getNormalized(), theta);
            }
            
            double delta = max_acceleration * TimeSystem::getFrameDuration();
            if(delta > 0.0)
            {
                double currentSpeed = getSpeed();
                double desiredSpeed = desired_velocity.getNorm();
                
                if (currentSpeed < desiredSpeed)
                {
                    currentSpeed += delta;
                    if (currentSpeed > desiredSpeed) currentSpeed = desiredSpeed;
                    setSpeed(currentSpeed);
                }
                else if (currentSpeed > desiredSpeed)
                {
                    currentSpeed -= delta;
                    if (currentSpeed < desiredSpeed) currentSpeed = desiredSpeed;
                    setSpeed(currentSpeed);
                }
            }
        }
        
        if (wantsToFire && isReloaded())
        {
            r_world.addBullet(getPosition(), getForward(), getId());
            wantsToFire = false;
            markReloading();
        }
    }
    
	if(isAlive() && isDying())
	{
		r_world.addExplosion(getPositionPrevious(), getRadius() * EXPLOSION_SIZE_FACTOR, 0);
		m_is_dead = true;

		// no further updates
		assert(invariant());
		return;
	}

	if(isAlive())
	{
		updateBasic();  // moves the Ship

		m_reload_timer += TimeSystem::getFrameDuration();
	}

	assert(invariant());
}
开发者ID:streibeb,项目名称:cs409,代码行数:60,代码来源:Ship.cpp

示例2: update

void Ship::update(WorldInterface& world)
{
	if (m_health <= 0 && m_status == dying){
		m_status = dead;
		world.addExplosion(getPositionPrevious(), EXPLOSION_SIZE, 0);
	}

	if (m_status == alive){
		if (isUnitAiSet()){
			double duration = TimeSystem::getFrameDuration();
			m_coordinate.rotateToVector(m_desired_velocity, duration*m_rotation_rate);
			changeSpeed(m_desired_velocity.getNorm(), duration*m_acceleration);
			if (m_fire_bullet_desired && isBulletReady()){
				world.addBullet(getPosition(), m_coordinate.getForward(), m_id);
				m_fire_bullet_desired = false;
				reloadBullet();
			}
		}
		updateBasic();
		m_reloadTimer.update();
	}


	else if (m_health > 0 && m_status == dead){
		m_status = alive;
		Vector3 position = m_coordinate.getPosition();
		position -= 500 * m_coordinate.getForward();
		m_coordinate.setPosition(position);
	}
}
开发者ID:whitelight2134,项目名称:spacewar,代码行数:30,代码来源:Ship.cpp

示例3: update

void Bullet :: update (WorldInterface& r_world)
{
	// explode if out of lifespan (or markDead(false) was called)
	if(isAlive() && isDying())
	{
		r_world.addExplosion(getPosition(), EXPLOSION_SIZE, 0);
		m_is_dead = true;

		// no further updates
		return;
	}

	if (isAlive())
		updateBasic();  // moves the Bullet
}
开发者ID:whitelight2134,项目名称:spacewar,代码行数:15,代码来源:Bullet.cpp


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