From 3538f022459523c30f944a9c7ed86008f9a2bda4 Mon Sep 17 00:00:00 2001 From: Milan Oberkirch Date: Mon, 1 Jul 2024 19:31:00 +0200 Subject: [PATCH] Fix issues with signed number comparison --- src/main.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index b5dca69..0447e73 100644 --- a/src/main.rs +++ b/src/main.rs @@ -326,8 +326,8 @@ async fn click(State(state): State, Form(input): Form) }; let step = bat.height / 2; let y = (input.y * 1000.) as u16; - if (y - (bat.height / 2)) < bat.position { - bat.position = (bat.position - step).max(1) + if y < (bat.position + (bat.height / 2)) { + bat.position = if step < bat.position {bat.position - step} else {1} } else { bat.position = (bat.position + step).min(1000) }