dungeoncrawler/src/spawner.rs

34 lines
756 B
Rust
Raw Normal View History

2021-07-06 00:52:14 -05:00
use crate::prelude::*;
pub fn spawn_player(ecs: &mut World, pos: Point) {
ecs.push((
Player,
pos,
Render {
color: ColorPair::new(WHITE, BLACK),
glyph: to_cp437('@'),
},
2021-07-07 12:36:24 -05:00
Health {
current: 20,
max: 20,
},
2021-07-06 00:52:14 -05:00
));
}
pub fn spawn_monster(ecs: &mut World, rng: &mut RandomNumberGenerator, pos: Point) {
ecs.push((
Enemy,
pos,
Render {
color: ColorPair::new(WHITE, BLACK),
glyph: match rng.range(0, 4) {
0 => to_cp437('E'),
1 => to_cp437('O'),
2 => to_cp437('o'),
_ => to_cp437('g'),
},
},
MovingRandomly,
));
}