resolve stutter

This commit is contained in:
Corwin 2023-06-04 00:15:16 +01:00
parent 083fd43ea3
commit cbb0b7d2a0
No known key found for this signature in database
2 changed files with 4 additions and 2 deletions

View file

@ -175,7 +175,7 @@ pub(crate) fn customise_screen(
agb.sfx.frame();
let mut upgrades = crate::level_generation::generate_upgrades(level);
let mut upgrades = crate::level_generation::generate_upgrades(level, &mut || agb.sfx.frame());
let mut _upgrade_objects = create_upgrade_objects(&agb.obj, &upgrades);
let mut input = agb::input::ButtonController::new();

View file

@ -37,7 +37,7 @@ fn generate_cooldown(current_level: u32) -> u32 {
rng::gen().rem_euclid((5 * 60 - current_level as i32 * 10).max(1)) as u32 + 2 * 60
}
pub fn generate_upgrades(level: u32) -> Vec<Face> {
pub fn generate_upgrades(level: u32, call: &mut dyn FnMut()) -> Vec<Face> {
let mut upgrade_values = HashMap::new();
upgrade_values.insert(Face::Shoot, 5);
@ -73,6 +73,8 @@ pub fn generate_upgrades(level: u32) -> Vec<Face> {
let mut attempts = 0;
while upgrades.len() != 3 {
call();
attempts += 1;
let next = potential_upgrades[rng::gen() as usize % potential_upgrades.len()];
let number_of_malfunctions = upgrades