|
@@ -3,7 +3,7 @@ extern crate specs_derive;
|
|
|
#[macro_use]
|
|
|
extern crate specs_system_macro;
|
|
|
|
|
|
-use ggez::{event::EventHandler, Context, GameError};
|
|
|
+use ggez::GameError;
|
|
|
use specs::prelude::*;
|
|
|
|
|
|
#[derive(Component)]
|
|
@@ -18,6 +18,10 @@ pub struct Renderable {
|
|
|
color: carpet::Color,
|
|
|
}
|
|
|
|
|
|
+#[derive(Component)]
|
|
|
+pub struct MoveLeft;
|
|
|
+
|
|
|
+
|
|
|
system_impl! {
|
|
|
Draw(
|
|
|
resource mut board: carpet::Board<carpet::CP437>,
|
|
@@ -31,9 +35,6 @@ system_impl! {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-#[derive(Component)]
|
|
|
-pub struct MoveLeft;
|
|
|
-
|
|
|
system! {
|
|
|
Leftward (
|
|
|
_left: MoveLeft,
|
|
@@ -47,22 +48,6 @@ system! {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-struct State {
|
|
|
- world: World,
|
|
|
-}
|
|
|
-
|
|
|
-impl EventHandler for State {
|
|
|
- fn draw(&mut self, ctx: &mut Context) -> Result<(), GameError> {
|
|
|
- ggez::graphics::clear(ctx, ggez::graphics::BLACK);
|
|
|
- self.world.fetch::<carpet::Board<carpet::CP437>>().draw(ctx)?;
|
|
|
- ggez::graphics::present(ctx)
|
|
|
- }
|
|
|
-
|
|
|
- fn update(&mut self, _ctx: &mut Context) -> Result<(), GameError> {
|
|
|
- Ok(())
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
fn main() -> Result<(), GameError> {
|
|
|
let mut game = carpet::GameBuilder::new()
|
|
|
.name("game")
|