本文整理汇总了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());
}
示例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);
}
}
示例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
}