本文整理汇总了C++中Tank::move_ud方法的典型用法代码示例。如果您正苦于以下问题:C++ Tank::move_ud方法的具体用法?C++ Tank::move_ud怎么用?C++ Tank::move_ud使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tank
的用法示例。
在下文中一共展示了Tank::move_ud方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: perform_logic
void perform_logic()
{
const float time_passed = m_chrono.seconds();
const float time_step = time_passed - m_time_passed;
m_time_passed = time_passed;
// without a multiplier, this will rotate a full turn after ~6.28s
// this rotates clockwise of c-clockwise depending on m_turn_????
//m_tank.turn_left((m_turn_left - m_turn_right) * time_step);
m_tank.move_lr((m_turn_left - m_turn_right) * time_step * 100.0f);
// without the '100.0f', it would move at ~1px/s
m_tank.move_ud((m_forward - m_backward) * time_step * 100.0f);
if(m_fire)
{
m_fire = false;
m_bullets.push_back(m_tank.fire());
}
// move bullets
for(list<Bullet *>::iterator it = m_bullets.begin(); it != m_bullets.end(); ++it)
(*it)->move_ud(time_step * 200.0f);
// remove off screen bullets for perfrmance boost
for(list<Bullet *>::iterator it = m_bullets.begin(); it != m_bullets.end();) {
const Point2f &p = (*it)->get_position();
if(p.x < -10.0f || p.x > 10.0f + get_Window().get_width() ||
p.y < -10.0f || p.y > 10.0f + get_Window().get_height())
{
delete *it;
it = m_bullets.erase(it);
}
else
++it;
}
}