From 28655cc819e48c50ae502563b64775da11ae3c15 Mon Sep 17 00:00:00 2001 From: Dominic Date: Sun, 7 Jul 2024 17:39:06 +0200 Subject: [PATCH] overworld human icon --- src/activities/overworld/mod.rs | 27 +++++++++++++++++++++++---- src/game.rs | 3 ++- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/activities/overworld/mod.rs b/src/activities/overworld/mod.rs index 47baf43..5060dfc 100644 --- a/src/activities/overworld/mod.rs +++ b/src/activities/overworld/mod.rs @@ -4,15 +4,25 @@ use crate::{ State }; use comfy::{ - delta, draw_circle, draw_rect_outline, draw_sprite, error, info, is_key_down, - main_camera_mut, EngineContext, IVec2, KeyCode, Vec2, RED, WHITE + draw_circle, draw_rect_outline, draw_sprite, error, info, is_key_down, + main_camera_mut, texture_id, vec2, EngineContext, IVec2, KeyCode, Vec2, RED, WHITE }; use std::time::Instant; use worldgen::MovementCost; pub mod worldgen; -pub fn draw(state: &crate::State, _engine: &comfy::EngineContext<'_>) { +pub fn setup(_state: &State, ctx: &EngineContext<'_>) { + ctx.load_texture_from_bytes( + "human_overworld", + include_bytes!(concat!( + env!("CARGO_MANIFEST_DIR"), + "/assets/entities/human_overworld.png" + )) + ); +} + +pub fn draw(state: &State, _ctx: &EngineContext<'_>) { for (coords, tile) in state.overworld.iter_tiles() { for (i, texture) in tile.textures().iter().rev().enumerate() { let i = i as i32; @@ -28,7 +38,16 @@ pub fn draw(state: &crate::State, _engine: &comfy::EngineContext<'_>) { } } } - draw_circle(state.ghost.overworld_pos, 0.5, RED, ZLayer::Ghost.into()); + + let mut ghost_pos = state.ghost.overworld_pos; + ghost_pos.y += 0.5; + draw_sprite( + texture_id("human_overworld"), + ghost_pos, + WHITE, + ZLayer::Ghost.into(), + vec2(1.0, 1.25) + ); } fn update_move_player(state: &mut State, _ctx: &mut EngineContext<'_>) { diff --git a/src/game.rs b/src/game.rs index d7aaad3..8246bbf 100644 --- a/src/game.rs +++ b/src/game.rs @@ -101,9 +101,10 @@ impl Add for ZLayer { } } -pub fn setup(_state: &mut State, ctx: &mut EngineContext<'_>) { +pub fn setup(state: &mut State, ctx: &mut EngineContext<'_>) { Assets::load(ctx); + overworld::setup(state, ctx); //house::setup(state, ctx); }