add bounds check

This commit is contained in:
Corwin 2024-04-19 23:59:58 +01:00
parent 9fc52000fe
commit e1a8b04616
No known key found for this signature in database

View file

@ -54,12 +54,11 @@ impl<'bitmap, 'gba> BitmapTextRender<'bitmap, 'gba> {
for y in 0..letter.height as usize { for y in 0..letter.height as usize {
for x in 0..letter.width as usize { for x in 0..letter.width as usize {
let rendered = letter.bit_absolute(x, y); let rendered = letter.bit_absolute(x, y);
if rendered { let x = x as i32 + self.head_position.x;
self.bitmap.draw_point( let y = y as i32 + y_position_start;
x as i32 + self.head_position.x,
y as i32 + y_position_start, if rendered && (0..=WIDTH).contains(&x) && (0..=HEIGHT).contains(&y) {
self.colour, self.bitmap.draw_point(x, y, self.colour);
);
} }
} }
} }