gsa/src/gsa_render_to_screen.rs

24 lines
766 B
Rust

use crate::{Gsa, MAX_SPRITES, TILE_SIZE};
use glam::IVec2;
use softbuffer::Buffer;
pub(crate) fn render_to_window(target: &mut Buffer, gsa: &Gsa, window_size: IVec2) {
for (y, row) in target.chunks_exact_mut(window_size.x as usize).enumerate() {
let y = y as i32;
for x in 0..window_size.x {
let mut p = 0;
for sprite in &gsa.sprites {
if sprite.tile > 0
&& x >= sprite.pos.x
&& y >= sprite.pos.y
&& x < sprite.pos.x + TILE_SIZE as i32
&& y < sprite.pos.y + TILE_SIZE as i32
{
p = 1;
}
}
row[x as usize] = gsa.palette[p].to_u32();
}
}
}