WIP room movement
This commit is contained in:
parent
c8e21d544a
commit
0a7e741207
5 changed files with 67 additions and 20 deletions
|
@ -6,13 +6,21 @@ use grid::Grid;
|
|||
use player::Player;
|
||||
use room::Room;
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
#[derive(Debug)]
|
||||
pub struct HouseState {
|
||||
room: Room,
|
||||
//grid: Grid,
|
||||
player: Player
|
||||
}
|
||||
|
||||
impl Default for HouseState {
|
||||
fn default() -> Self {
|
||||
let room = Room::default();
|
||||
let player = Player::new(&room);
|
||||
Self { room, player}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn draw(state: &crate::State, _engine: &comfy::EngineContext<'_>) {
|
||||
//Draw House
|
||||
state.house.room.draw();
|
||||
|
@ -26,4 +34,12 @@ pub fn draw(state: &crate::State, _engine: &comfy::EngineContext<'_>) {
|
|||
|
||||
pub fn update(state: &mut crate::State, _engine: &mut comfy::EngineContext<'_>) {
|
||||
state.house.player.update(&state.house.room.grid);
|
||||
|
||||
if state.house.player.is_moving_to_right_room(&state.house.room) {
|
||||
state.house.room = Room::default();
|
||||
state.house.player.reset_on_room(&state.house.room, true);
|
||||
} else if state.house.player.is_moving_to_left_room(&state.house.room) {
|
||||
state.house.room = Room::default();
|
||||
state.house.player.reset_on_room(&state.house.room, false);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue