From cbb0b7d2a0e96370cbedd8a07119fac7c91111b5 Mon Sep 17 00:00:00 2001 From: Corwin Date: Sun, 4 Jun 2023 00:15:16 +0100 Subject: [PATCH] resolve stutter --- examples/hyperspace-roll/src/customise.rs | 2 +- examples/hyperspace-roll/src/level_generation.rs | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/examples/hyperspace-roll/src/customise.rs b/examples/hyperspace-roll/src/customise.rs index 4c6a5aec..78c2d9b2 100644 --- a/examples/hyperspace-roll/src/customise.rs +++ b/examples/hyperspace-roll/src/customise.rs @@ -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(); diff --git a/examples/hyperspace-roll/src/level_generation.rs b/examples/hyperspace-roll/src/level_generation.rs index 04c45b5f..5c190495 100644 --- a/examples/hyperspace-roll/src/level_generation.rs +++ b/examples/hyperspace-roll/src/level_generation.rs @@ -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 { +pub fn generate_upgrades(level: u32, call: &mut dyn FnMut()) -> Vec { let mut upgrade_values = HashMap::new(); upgrade_values.insert(Face::Shoot, 5); @@ -73,6 +73,8 @@ pub fn generate_upgrades(level: u32) -> Vec { 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