handsonrust/src/systems/entity_render.rs

18 lines
513 B
Rust
Raw Normal View History

2021-08-28 04:25:52 +00:00
use crate::prelude::*;
#[system]
#[read_component(Point)]
#[read_component(Render)]
pub fn entity_render(ecs: &mut SubWorld, #[resource] camera: &mut Camera) {
let mut draw_batch = DrawBatch::new();
draw_batch.target(1);
let offset = Point::new(camera.left_x, camera.top_y);
<(&Point, &Render)>::query()
.iter(ecs)
.for_each(|(pos, render)| {
draw_batch.set(*pos - offset, render.color, render.glyph);
});
draw_batch.submit(5000).expect("Batch error");
}