diff --git a/src/main.rs b/src/main.rs index 65ca8cd..dc20cc0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,24 @@ -use rltk::{Rltk, GameState}; +use rltk::{GameState, Rltk, VirtualKeyCode, RGB}; +use specs::prelude::*; +use specs_derive::Component; +use std::cmp::{max, min}; -struct State {} +#[derive(Component)] +struct Position { + x: i32, + y: i32, +} + +#[derive(Component)] +struct Renderable { + glyph: rltk::FontCharType, + fg: RGB, + bg: RGB, +} + +struct State { + ecs: World, +} impl GameState for State { fn tick(&mut self, ctx: &mut Rltk) { @@ -16,7 +34,20 @@ fn main() -> rltk::BError { .with_title("Roguelike Tutorial") .build()?; - let gs = State {}; + let mut gs = State { ecs: World::new() }; + + gs.ecs.register::(); + gs.ecs.register::(); + + gs.ecs + .create_entity() + .with(Position { x: 40, y: 25 }) + .with(Renderable { + glyph: rltk::to_cp437('@'), + fg: RGB::named(rltk::YELLOW), + bg: RGB::named(rltk::BLACK), + }) + .build(); rltk::main_loop(context, gs) -} \ No newline at end of file +}