2024-04-01 03:51:30 +01:00
|
|
|
#![allow(dead_code)]
|
|
|
|
|
2024-04-08 08:27:03 +01:00
|
|
|
use component_macro::Component;
|
2024-04-01 03:51:30 +01:00
|
|
|
use engine::{Component, Sprite, System};
|
2024-04-08 08:27:03 +01:00
|
|
|
use std::any::{Any, TypeId};
|
2024-04-01 00:01:49 +01:00
|
|
|
mod engine;
|
|
|
|
|
2024-04-08 08:27:03 +01:00
|
|
|
#[derive(Component)]
|
|
|
|
struct Player {
|
|
|
|
sprite: Option<Sprite>,
|
2024-04-01 03:51:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
struct PlayerRenderer;
|
|
|
|
|
|
|
|
impl System for PlayerRenderer {
|
2024-04-01 21:15:31 +01:00
|
|
|
fn on_add(&self, _ctx: &mut engine::Context) {}
|
2024-04-01 03:51:30 +01:00
|
|
|
|
|
|
|
fn on_update(&self, _ctx: &mut engine::Context) {}
|
|
|
|
}
|
|
|
|
|
2024-04-08 10:14:29 +01:00
|
|
|
fn main() {
|
|
|
|
let mut game = engine::Game::new().unwrap();
|
|
|
|
|
2024-04-08 08:27:03 +01:00
|
|
|
let mut context = game.context();
|
|
|
|
context.add_system(Box::new(PlayerRenderer));
|
|
|
|
context.spawn(vec![Box::new(Player { sprite: None })]);
|
2024-04-01 03:51:30 +01:00
|
|
|
|
2024-04-01 21:15:31 +01:00
|
|
|
game.run(|context| {
|
2024-04-01 21:03:04 +01:00
|
|
|
let sprite = context.load_sprite("textures/player.png").unwrap();
|
|
|
|
context.draw_sprite(&sprite, 16, 16).unwrap();
|
2024-04-01 21:15:31 +01:00
|
|
|
});
|
2024-03-31 22:56:03 +01:00
|
|
|
}
|