1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
#![allow(dead_code)]
pub mod components;
pub mod math;
pub mod systems;
pub mod texture_manager;
use components::*;
use math::Vec2;
use sdl2::rect::Rect;
use specs::prelude::*;
use specs::{DispatcherBuilder, World};
use systems::{SysDraw, SysInput, SysMovement};
fn main()
{
let sdl = sdl2::init().expect("Unable to start SDL context");
let video_subsys = sdl.video().expect("Unable to get SDL Video context");
let window = video_subsys
.window("Pokemon Mystery Dungeon coop clone", 800, 600)
.position_centered()
.opengl()
.resizable()
.build()
.expect("Unable to create window");
let mut world = World::new();
world.register::<Pos>();
world.register::<StaticDrawable>();
world.register::<Velocity>();
world.register::<Player>();
world
.create_entity()
.with(Pos(Vec2::new(0., 0.)))
.with(Velocity(Vec2::new(0., 0.)))
.with(StaticDrawable {
texture_name: "portraits.png".to_string(),
source_rect: Rect::new(0, 0, 40, 40),
})
.with(Player)
.build();
let sys_input = SysInput::new(&sdl);
let sys_draw = SysDraw::new(window);
let sys_move = SysMovement::new();
let mut dispatcher = DispatcherBuilder::new()
.with(sys_move, "move", &[])
.with_thread_local(sys_input)
.with_thread_local(sys_draw)
.build();
loop {
dispatcher.dispatch(&world);
}
}
|