enter house (#10)
Reviewed-on: #10 Co-authored-by: luckyturtledev <git@lukas1818.de> Co-committed-by: luckyturtledev <git@lukas1818.de>
This commit is contained in:
parent
1c897d6712
commit
bb37f613ad
5 changed files with 52 additions and 12 deletions
|
@ -11,13 +11,16 @@ pub struct HouseState {
|
|||
}
|
||||
|
||||
pub fn draw(state: &crate::State, _engine: &comfy::EngineContext<'_>) {
|
||||
//Draw Grid
|
||||
state.house.grid.draw();
|
||||
if let Some(house) = state.house() {
|
||||
//Draw Grid
|
||||
house.grid.draw();
|
||||
|
||||
//Draw Player
|
||||
state.house.player.draw();
|
||||
//Draw Player
|
||||
house.player.draw();
|
||||
}
|
||||
}
|
||||
|
||||
pub fn update(state: &mut crate::State, _engine: &mut comfy::EngineContext<'_>) {
|
||||
state.house.player.update(&state.house.grid);
|
||||
let house = state.house_mut();
|
||||
house.player.update(&house.grid);
|
||||
}
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
use comfy::IVec2;
|
||||
|
||||
pub mod house;
|
||||
pub mod overworld;
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
pub enum Activity {
|
||||
#[allow(dead_code)]
|
||||
House,
|
||||
House(IVec2),
|
||||
#[default]
|
||||
Overworld
|
||||
}
|
||||
|
|
|
@ -1,4 +1,11 @@
|
|||
use crate::{game::ZLayer, State};
|
||||
use crate::{
|
||||
activities::{
|
||||
house::{self, HouseState},
|
||||
Activity
|
||||
},
|
||||
game::ZLayer,
|
||||
State
|
||||
};
|
||||
use comfy::{
|
||||
draw_circle, draw_rect_outline, draw_sprite, error, info, is_key_down,
|
||||
main_camera_mut, EngineContext, IVec2, KeyCode, Vec2, RED, WHITE
|
||||
|
@ -146,6 +153,16 @@ fn update_move_player(state: &mut State) {
|
|||
y: requested_pos_diff.y as _
|
||||
};
|
||||
state.ghost.overworld_pos_last_update = now;
|
||||
|
||||
//move into house if player stepp at door
|
||||
{
|
||||
let current_tile = state.overworld.get_or_generate_tile(tile_pos);
|
||||
if current_tile.can_enter_house() {
|
||||
info!("enter house at {tile_pos}");
|
||||
state.activity = Activity::House(tile_pos);
|
||||
state.house_mut(); // gen new house
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn update(state: &mut State, _ctx: &mut EngineContext<'_>) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue