This commit is contained in:
Crispy 2024-10-12 23:27:28 +02:00
parent 27ff77f133
commit ed956ffbe4
5 changed files with 22 additions and 20 deletions

View file

@ -232,6 +232,7 @@ impl Board {
pub fn draw(&self, d: &mut RaylibDrawHandle, textures: &Textures, offset: Vector2, zoom: i32) {
let tile_size = 16 << zoom;
let scale = (1 << zoom) as f32;
let start_x = (-offset.x as i32) / tile_size - 1;
let tile_width = d.get_screen_width() / tile_size + 2;
@ -240,18 +241,15 @@ impl Board {
for x in start_x..(start_x + tile_width) {
for y in start_y..(start_y + tile_height) {
let tx = x as usize;
let ty = y as usize;
let px = x * tile_size + offset.x as i32;
let py = y * tile_size + offset.y as i32;
if self.in_bounds((tx, ty).into()) {
let tile = self.rows[ty][tx];
if let Some(tile) = self.get((x, y).into()) {
let texname = tile.texture();
if texname.is_empty() {
continue;
}
let texture = textures.get(&texname);
draw_scaled_texture(d, texture, px, py, (1 << zoom) as f32);
draw_scaled_texture(d, texture, px, py, scale);
} else {
d.draw_rectangle(px, py, tile_size, tile_size, Color::new(0, 0, 0, 80));
}