Fix centering bug

This commit is contained in:
Franco Colmenarez 2021-05-18 20:36:45 -05:00
parent 8398cf5bb1
commit 641392842b

View File

@ -112,7 +112,8 @@ impl Buffer {
// vertical offset = 7 - height // vertical offset = 7 - height
// horizontal offset = ((7 - width) / 2) + (1/2) -> then round the result down // horizontal offset = ((7 - width) / 2) + (1/2) -> then round the result down
self.vertical_offset = MAX_SPRITE_SIZE - width; 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 // We need 3 bitplanes, the first and second ones are where the
// decompressed bytes will be, which are 7 x 7 each. // decompressed bytes will be, which are 7 x 7 each.
// The third one is usually 7 x 7 maximum too, but glitched pokemon could // The third one is usually 7 x 7 maximum too, but glitched pokemon could