#include "KeyboardController.h" #include KeyboardController::KeyboardController(Player* pPlayer, uint leftKey, uint rightKey): Controller(pPlayer), m_leftKey(leftKey), m_rightKey(rightKey) { m_nextMove = NO_MOVE; } void KeyboardController::PressKey(KeyCode key) { if (m_nextMove == NO_MOVE) { if (key == m_leftKey) { m_nextMove = MOVE_LEFT; } else if (key == m_rightKey) { m_nextMove = MOVE_RIGHT; } } } void KeyboardController::think() { if (m_nextMove == MOVE_LEFT) { m_pPlayer->turnLeft(); } else if (m_nextMove == MOVE_RIGHT) { m_pPlayer->turnRight(); } m_nextMove = NO_MOVE; } void KeyboardController::reset() { m_nextMove = NO_MOVE; } KeyboardController::~KeyboardController(void) { }