/** * @brief This function is called when a game key is pressed and the game is not suspended. * @param key the key pressed */ void Hero::State::key_pressed(GameControls::GameKey key) { switch (key) { // action key case GameControls::ACTION: action_key_pressed(); break; // sword key case GameControls::SWORD: sword_key_pressed(); break; // move the hero case GameControls::RIGHT: directional_key_pressed(0); break; case GameControls::UP: directional_key_pressed(1); break; case GameControls::LEFT: directional_key_pressed(2); break; case GameControls::DOWN: directional_key_pressed(3); break; // use an inventory item case GameControls::ITEM_1: item_key_pressed(0); break; case GameControls::ITEM_2: item_key_pressed(1); break; default: break; } }
/** * @brief This function is called by the game when a key is pressed * while displaying a dialog. * @param key the key pressed */ void DialogBox::key_pressed(GameControls::GameKey key) { switch (key) { // action key case GameControls::ACTION: action_key_pressed(); break; // sword key case GameControls::SWORD: sword_key_pressed(); break; case GameControls::UP: case GameControls::DOWN: up_or_down_key_pressed(); default: break; } }