handle tick dist of 0 for catch (#14)

This commit is contained in:
Max
2022-08-02 18:08:05 +02:00
committed by GitHub
parent 3d92656f19
commit f6cb9f5bd2
+6 -4
View File
@@ -95,6 +95,9 @@ impl FruitOrJuice {
let target = *pixel_len - tick_dist / 8.0;
let mut slider_objects = vec![(h.pos, h.start_time)];
if tick_dist > 0.0 {
params.ticks.reserve((target / tick_dist) as usize);
// Tick of the first span
@@ -114,9 +117,7 @@ impl FruitOrJuice {
&params.ticks,
);
let mut slider_objects =
Vec::with_capacity(span_count as usize * (params.ticks.len() + 1));
slider_objects.push((h.pos, h.start_time));
slider_objects.reserve(span_count as usize * (params.ticks.len()));
// Other spans
if *repeats == 0 {
@@ -154,13 +155,14 @@ impl FruitOrJuice {
params.ticks.clear();
}
}
// Slider tail
let progress = (*repeats % 2 == 0) as u8 as f64;
let pos = h.pos + curve.position_at(progress);
slider_objects.push((pos, h.start_time + duration));
let new_fruits = *repeats + 2;
let new_fruits = 2 + (tick_dist > 0.0) as usize * *repeats;
params.attributes.n_fruits += new_fruits;
params.attributes.n_droplets += slider_objects.len() - new_fruits;