bool Game_Map::PrepareEncounter() { if (GetEncounterRate() <= 0) { return false; } int x = Main_Data::game_player->GetX(); int y = Main_Data::game_player->GetY(); std::vector<int> encounters = GetEncountersAt(x, y); if (encounters.empty()) { // No enemies on this map :( return false; } Game_Temp::battle_troop_id = encounters[Utils::GetRandomNumber(0, encounters.size() - 1)]; Game_Temp::battle_calling = true; if (Utils::GetRandomNumber(1, 32) == 1) { Game_Temp::battle_first_strike = true; } SetupBattle(); return true; }
void MainMenu::onLogic() { if (ScreenManager::getTop() != this) { return; } Music::playSong("data/music/menu.xm"); if (Input::isPressed(Button_Up)) { mySelectedIndex--; if (mySelectedIndex < 0) mySelectedIndex = 0; else Sound::playSample("data/sound/gui_select.wav"); } if (Input::isPressed(Button_Exit)) { ScreenManager::exit(this); } if (Input::isPressed(Button_Down)) { mySelectedIndex++; if (mySelectedIndex > 1) mySelectedIndex = 1; else Sound::playSample("data/sound/gui_select.wav"); } if (Input::isPressed(Button_Action)) { if (mySelectedIndex == 0) { ScreenManager::add(SetupBattle()); } else if (mySelectedIndex == 1) { ScreenManager::exit(this); } } }