Esempio n. 1
0
/**
 * Translate this key to symbol, compare with borrowed buttons.
 * @return symbol or SYM_NONE for unknown key
 */
char
Unit::mySymbolBorrowed(SDLKey key, const KeyControl &buttons) const
{
    if (key == buttons.getLeft()) {
        return m_symbols.getLeft();
    }
    if (key == buttons.getRight()) {
        return m_symbols.getRight();
    }
    if (key == buttons.getUp()) {
        return m_symbols.getUp();
    }
    if (key == buttons.getDown()) {
        return m_symbols.getDown();
    }
    return ControlSym::SYM_NONE;
}
Esempio n. 2
0
/**
 * Test keys and try move, use borrowed controls.
 * @return a symbol when unit has moved or SYM_NONE
 */
char
Unit::driveBorrowed(const InputProvider *input, const KeyControl &buttons)
{
    if (canDrive()) {
        if (input->isPressed(buttons.getLeft())) {
            return goLeft();
        }
        if (input->isPressed(buttons.getRight())) {
            return goRight();
        }
        if (input->isPressed(buttons.getUp())) {
            return goUp();
        }
        if (input->isPressed(buttons.getDown())) {
            return goDown();
        }
    }
    return ControlSym::SYM_NONE;
}