From 06a3bd26d8a6615430588325644694f8181f1ae2 Mon Sep 17 00:00:00 2001 From: Dukantic Date: Sat, 31 May 2025 21:13:06 +0200 Subject: [PATCH] fix a bug with global rotation --- src/main.rs | 9 ++++----- src/polygon_draw.rs | 5 +---- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/main.rs b/src/main.rs index 32a5ca2..f246653 100644 --- a/src/main.rs +++ b/src/main.rs @@ -52,8 +52,9 @@ impl MyApp { teta: 0.0, polygons: vec![ //Polygon::n_gon(0.0, 12), - Polygon::triangle(0.0), - Polygon::square(PI / 4.0), + //Polygon::triangle(0.0), + //Polygon::square(PI / 4.0), + Polygon::nr_6_in_30(1.5), ], }, }, @@ -76,7 +77,6 @@ impl MyApp { * (1.0 / self.nb_sec_for_rev as f32) * (time_btw.as_millis() as f32 / 1_000.0); self.polys.teta %= 2.0 * PI; - //println!("Teta : {}", self.polys.teta); if self .polys .have_point_polygon_btw(teta_temp, self.polys.teta) @@ -84,7 +84,6 @@ impl MyApp { self.audio_manager .play(self.default_sound.clone()) .expect("Error to play sound"); - //do_sound("assets/tick.mp3"); } self.time_last_frame = Instant::now(); } @@ -109,7 +108,7 @@ impl MyApp { .into() } fn subscription(&self) -> iced::Subscription { - time::every(Duration::from_millis(1)).map(|_| Message::Tick) + time::every(Duration::from_millis(16)).map(|_| Message::Tick) } } /* diff --git a/src/polygon_draw.rs b/src/polygon_draw.rs index 6b2f052..1e1d19f 100644 --- a/src/polygon_draw.rs +++ b/src/polygon_draw.rs @@ -115,13 +115,10 @@ impl Polygon { } let mut p_g; for p in self.points_teta.clone() { - p_g = p + self.global_teta; + p_g = (p + self.global_teta) % (2.0 * PI); if before <= p_g && p_g <= after { return true; } - if p_g > after { - return false; - }; } false }