Main menu and saving
This commit is contained in:
parent
e1b5e25e85
commit
25651d5c82
22
src/main.rs
22
src/main.rs
@ -376,6 +376,19 @@ fn handle_keys(tcod: &mut Tcod, game: &mut Game, objects: &mut Vec<Object>) -> P
|
|||||||
DidntTakeTurn
|
DidntTakeTurn
|
||||||
}
|
}
|
||||||
|
|
||||||
|
(Key { code: Text, .. }, "d", true) => {
|
||||||
|
// Show the inventory; if an item is selected, drop it
|
||||||
|
let inventory_index = inventory_menu(
|
||||||
|
&game.inventory,
|
||||||
|
"Press the key next to an item to drop it, or any other to cancel.\n",
|
||||||
|
&mut tcod.root,
|
||||||
|
);
|
||||||
|
if let Some(inventory_index) = inventory_index {
|
||||||
|
drop_item(inventory_index, game, objects);
|
||||||
|
}
|
||||||
|
DidntTakeTurn
|
||||||
|
}
|
||||||
|
|
||||||
_ => DidntTakeTurn,
|
_ => DidntTakeTurn,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1058,6 +1071,15 @@ fn target_monster(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn drop_item(inventory_id: usize, game: &mut Game, objects: &mut Vec<Object>) {
|
||||||
|
let mut item = game.inventory.remove(inventory_id);
|
||||||
|
item.set_pos(objects[PLAYER].x, objects[PLAYER].y);
|
||||||
|
game
|
||||||
|
.messages
|
||||||
|
.add(format!("You dropped a {}.", item.name), YELLOW);
|
||||||
|
objects.push(item);
|
||||||
|
}
|
||||||
|
|
||||||
fn render_all(tcod: &mut Tcod, game: &mut Game, objects: &[Object], fov_recompute: bool) {
|
fn render_all(tcod: &mut Tcod, game: &mut Game, objects: &[Object], fov_recompute: bool) {
|
||||||
if fov_recompute {
|
if fov_recompute {
|
||||||
let player = &objects[PLAYER];
|
let player = &objects[PLAYER];
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user