示例#1
0
void GameEngine::handleInput()
{
    b2Vec2 v(0, 0);
    if (keyStates[GLUT_KEY_LEFT]) {
        v.x = -bot.GetSpeed();
        bot.TurnLeft();
    }
    else if (keyStates[GLUT_KEY_RIGHT]) {
        v.x = bot.GetSpeed();
        bot.TurnRight();
    }
    if (keyStates[GLUT_KEY_DOWN]) {
        v.y = -bot.GetSpeed();
    }
    else if (keyStates[GLUT_KEY_UP]) {
        v.y = +bot.GetSpeed();
    }
    m_actor->SetTransform(m_actor->GetPosition() + v, 0);
}