pvp-game-dilapidation/src/main.rs

33 lines
748 B
Rust

#![allow(dead_code)]
use component_macro::Component;
use engine::{Component, Sprite, System};
use std::any::{Any, TypeId};
mod engine;
#[derive(Component)]
struct Player {
sprite: Option<Sprite>,
}
struct PlayerRenderer;
impl System for PlayerRenderer {
fn on_add(&self, _ctx: &mut engine::Context) {}
fn on_update(&self, _ctx: &mut engine::Context) {}
}
fn main() {
let mut game = engine::Game::new().unwrap();
let mut context = game.context();
context.add_system(Box::new(PlayerRenderer));
context.spawn(vec![Box::new(Player { sprite: None })]);
game.run(|context| {
let sprite = context.load_sprite("textures/player.png").unwrap();
context.draw_sprite(&sprite, 16, 16).unwrap();
});
}