2024-07-06 17:59:56 +00:00
|
|
|
mod grid;
|
|
|
|
mod player;
|
2024-07-07 00:01:46 +02:00
|
|
|
mod room;
|
2024-07-06 17:59:56 +00:00
|
|
|
|
|
|
|
use grid::Grid;
|
|
|
|
use player::Player;
|
2024-07-07 00:01:46 +02:00
|
|
|
use room::Room;
|
2024-07-06 17:59:56 +00:00
|
|
|
|
2024-07-07 00:48:37 +02:00
|
|
|
#[derive(Debug)]
|
2024-07-06 17:59:56 +00:00
|
|
|
pub struct HouseState {
|
2024-07-07 00:01:46 +02:00
|
|
|
room: Room,
|
|
|
|
//grid: Grid,
|
2024-07-06 17:59:56 +00:00
|
|
|
player: Player
|
|
|
|
}
|
|
|
|
|
2024-07-07 00:48:37 +02:00
|
|
|
impl Default for HouseState {
|
|
|
|
fn default() -> Self {
|
|
|
|
let room = Room::default();
|
|
|
|
let player = Player::new(&room);
|
|
|
|
Self { room, player}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-07-06 20:23:25 +00:00
|
|
|
pub fn draw(state: &crate::State, _engine: &comfy::EngineContext<'_>) {
|
2024-07-07 00:01:46 +02:00
|
|
|
//Draw House
|
|
|
|
state.house.room.draw();
|
|
|
|
|
2024-07-06 17:59:56 +00:00
|
|
|
//Draw Grid
|
2024-07-07 00:01:46 +02:00
|
|
|
//state.house.grid.draw();
|
2024-07-06 17:59:56 +00:00
|
|
|
|
|
|
|
//Draw Player
|
|
|
|
state.house.player.draw();
|
|
|
|
}
|
|
|
|
|
2024-07-06 20:23:25 +00:00
|
|
|
pub fn update(state: &mut crate::State, _engine: &mut comfy::EngineContext<'_>) {
|
2024-07-07 00:01:46 +02:00
|
|
|
state.house.player.update(&state.house.room.grid);
|
2024-07-07 00:48:37 +02:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
2024-07-06 17:59:56 +00:00
|
|
|
}
|