room builders

This commit is contained in:
Llywelwyn 2023-07-23 18:35:55 +01:00
parent 2ceb20a822
commit 46e0c6ec6b
5 changed files with 108 additions and 20 deletions

View file

@ -170,6 +170,7 @@ pub fn spawn_entity(ecs: &mut World, spawn: &(&usize, &String)) {
"confusion wand" => confusion_wand(ecs, x, y),
// Food
"rations" => rations(ecs, x, y),
"apple" => apple(ecs, x, y),
// Traps
"bear trap" => bear_trap(ecs, x, y),
"confusion trap" => confusion_trap(ecs, x, y),
@ -220,7 +221,7 @@ fn item_table(_map_depth: i32) -> RandomTable {
}
fn food_table(_map_depth: i32) -> RandomTable {
return RandomTable::new().add("rations", 1);
return RandomTable::new().add("rations", 1).add("apple", 1);
}
fn trap_table(_map_depth: i32) -> RandomTable {
@ -492,6 +493,23 @@ fn rations(ecs: &mut World, x: i32, y: i32) {
.build();
}
fn apple(ecs: &mut World, x: i32, y: i32) {
ecs.create_entity()
.with(Position { x, y })
.with(Renderable {
glyph: rltk::to_cp437('%'),
fg: RGB::named(rltk::GREEN),
bg: RGB::named(rltk::BLACK),
render_order: 2,
})
.with(Name { name: "apple".to_string(), plural: "apples".to_string() })
.with(Item {})
.with(ProvidesNutrition {})
.with(Consumable {})
.marked::<SimpleMarker<SerializeMe>>()
.build();
}
// WANDS
fn fireball_wand(ecs: &mut World, x: i32, y: i32) {