Room Creating: Place Kitchen Furniture (#11)
Co-authored-by: Glaeder <niklas@vousten.dev> Co-authored-by: Fredi <fredrik.konrad@rwth-aachen.de> Reviewed-on: #11 Co-authored-by: Dominic <git@msrd0.de> Co-committed-by: Dominic <git@msrd0.de>
This commit is contained in:
parent
1275b92a5b
commit
33b301a410
54 changed files with 569 additions and 46 deletions
|
@ -1,26 +1,52 @@
|
|||
mod furniture;
|
||||
mod grid;
|
||||
mod player;
|
||||
mod room;
|
||||
|
||||
use grid::Grid;
|
||||
use player::Player;
|
||||
use self::{grid::Grid, player::Player, room::Room};
|
||||
use crate::State;
|
||||
use comfy::{error, EngineContext};
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
#[derive(Debug)]
|
||||
pub struct HouseState {
|
||||
grid: Grid,
|
||||
room: Room,
|
||||
//grid: Grid,
|
||||
player: Player
|
||||
}
|
||||
|
||||
pub fn draw(state: &crate::State, _engine: &comfy::EngineContext<'_>) {
|
||||
if let Some(house) = state.house() {
|
||||
//Draw Grid
|
||||
house.grid.draw();
|
||||
|
||||
//Draw Player
|
||||
house.player.draw();
|
||||
impl HouseState {
|
||||
pub fn generate_new_house(ctx: &mut EngineContext<'_>) -> Self {
|
||||
let room = Room::new(ctx);
|
||||
let player = Player::new(&room);
|
||||
HouseState { room, player }
|
||||
}
|
||||
}
|
||||
|
||||
pub fn update(state: &mut crate::State, _engine: &mut comfy::EngineContext<'_>) {
|
||||
let house = state.house_mut();
|
||||
house.player.update(&house.grid);
|
||||
pub fn draw(state: &State, _ctx: &comfy::EngineContext<'_>) {
|
||||
let Some(house) = state.house() else {
|
||||
error!("How can I render a house when I'm not in one?!?");
|
||||
return;
|
||||
};
|
||||
|
||||
//Draw House
|
||||
house.room.draw();
|
||||
|
||||
//Draw Grid
|
||||
//state.house.grid.draw();
|
||||
|
||||
//Draw Player
|
||||
house.player.draw();
|
||||
}
|
||||
|
||||
pub fn update(state: &mut State, ctx: &mut comfy::EngineContext<'_>) {
|
||||
let house = state.house_mut(ctx);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue