30 lines
704 B
Rust
30 lines
704 B
Rust
use rltk::{Console, GameState, Rltk};
|
|
use specs::prelude::*;
|
|
|
|
use crate::entity::{Position, Renderable};
|
|
use crate::map;
|
|
use crate::player;
|
|
|
|
pub struct State {
|
|
pub ecs: World,
|
|
pub systems: Dispatcher<'static, 'static>,
|
|
}
|
|
|
|
impl GameState for State {
|
|
fn tick(&mut self, ctx: &mut Rltk) {
|
|
ctx.cls();
|
|
|
|
player::input(self, ctx);
|
|
self.systems.dispatch(&self.ecs);
|
|
|
|
map::draw(&self.ecs, ctx);
|
|
|
|
let positions = self.ecs.read_storage::<Position>();
|
|
let renderables = self.ecs.read_storage::<Renderable>();
|
|
|
|
for (pos, rend) in (&positions, &renderables).join() {
|
|
ctx.set(pos.x, pos.y, rend.fg, rend.bg, rend.glyph);
|
|
}
|
|
}
|
|
}
|