From 641392842bb11999d8b275c5903b346021af4c4b Mon Sep 17 00:00:00 2001 From: Franco Colmenarez Date: Tue, 18 May 2021 20:36:45 -0500 Subject: [PATCH] Fix centering bug --- src/main.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 1b74252..99591f2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -112,7 +112,8 @@ impl Buffer { // vertical offset = 7 - height // horizontal offset = ((7 - width) / 2) + (1/2) -> then round the result down self.vertical_offset = MAX_SPRITE_SIZE - width; - self.horizontal_offset = ((MAX_SPRITE_SIZE - height) / 2) + (1 / 2); + let res = (((MAX_SPRITE_SIZE as f32 - height as f32) / 2.0) + (1.0 / 2.0)) as f32; + self.horizontal_offset = res.floor() as u8; // We need 3 bitplanes, the first and second ones are where the // decompressed bytes will be, which are 7 x 7 each. // The third one is usually 7 x 7 maximum too, but glitched pokemon could