handsonrust/src/spawners.rs

30 lines
723 B
Rust
Raw Normal View History

2021-08-28 04:25:52 +00:00
pub 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-08-28 20:59:12 +00: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'), // Ettin
1 => to_cp437('O'), // Ogre
2 => to_cp437('o'), // Orc
_ => to_cp437('g'), // goblin
},
},
2021-08-28 23:28:48 +00:00
MovingRandomly {},
2021-08-28 20:59:12 +00:00
));
}