mod furniture; mod grid; mod player; mod room; use comfy::EngineContext; use grid::Grid; use player::Player; use room::Room; #[derive(Debug)] pub struct HouseState { room: Room, //grid: Grid, player: Player } pub fn setup(state: &mut crate::State, ctx: &mut EngineContext<'_>) { let house = { let room = Room::new(ctx); let player = Player::new(&room); HouseState { room, player } }; state.house = Some(house); } pub fn draw(state: &crate::State, _ctx: &comfy::EngineContext<'_>) { if let Some(house) = &state.house { //Draw House house.room.draw(); //Draw Grid //state.house.grid.draw(); //Draw Player house.player.draw(); } } pub fn update(state: &mut crate::State, ctx: &mut comfy::EngineContext<'_>) { if let Some(house) = &mut state.house { house.player.update(&house.room.grid); if house.player.is_moving_to_right_room(&house.room) { house.room = Room::new(ctx); house.player.reset_on_room(&house.room, true); } else if house.player.is_moving_to_left_room(&house.room) { house.room = Room::new(ctx); house.player.reset_on_room(&house.room, false); } } }