attack-human #21

Merged
Glaeder merged 6 commits from attack-human into main 2024-07-07 16:24:01 +00:00
4 changed files with 16 additions and 7 deletions
Showing only changes of commit 703e0f28fb - Show all commits

View file

@ -115,6 +115,7 @@ pub fn update(state: &mut crate::State, ctx: &mut comfy::EngineContext<'_>) {
}
if house.exit_time >= 2.0 {
state.score += 500.0;
state.ghost.overworld_pos -= vec2(0.0, 1.0);
state.activity = Activity::Overworld;
}

View file

@ -2,7 +2,7 @@ use super::{
room::{Room, SCALE},
Grid
};
use comfy::{delta, draw_circle, is_key_down, is_key_pressed, main_camera_mut, vec2, KeyCode, Vec2, RED};
use comfy::{delta, draw_circle, draw_sprite, is_key_down, is_key_pressed, main_camera_mut, texture_id, vec2, KeyCode, Vec2, RED, WHITE};
use log::error;
use std::collections::HashSet;
@ -36,7 +36,8 @@ impl Player {
}
pub fn draw(&self) {
draw_circle(self.position, 0.5, RED, 0);
//draw_circle(self.position, 0.5, RED, 0);
draw_sprite(texture_id("ghost_house"), self.position, WHITE, 5, vec2(1.25, 1.25));
}
pub fn update(&mut self, room: &Room) {
@ -361,7 +362,7 @@ fn snap_to_closest_node(player: &mut Player, grid: &Grid) {
}
fn attack_human_routine(player: &mut Player, room: &Room) {
let range = 0.5;
let range = 1.0;
if is_key_pressed(KeyCode::Space) {
//In some node range?

View file

@ -399,16 +399,15 @@ impl Room {
}
if let Some(human_pos) = self.human_pos {
draw_circle(human_pos, 0.5, RED, 20);
//draw_circle(human_pos, 0.5, RED, 20);
draw_rect(human_pos , vec2(1.0, 2.0) * SCALE, GOLD, ZLayer::Human.into());
}
/* Debug draw
for node_index in &self.human_nodes {
draw_circle(*self.grid.nodes.get(*node_index).unwrap(), 0.5, GREEN, ZLayer::Human.into());
}
}*/
self.grid.draw();

View file

@ -93,6 +93,14 @@ pub fn setup(state: &mut State, ctx: &mut EngineContext<'_>) {
Assets::load(ctx);
//house::setup(state, ctx);
ctx.load_texture_from_bytes(
"ghost_house",
include_bytes!(concat!(
env!("CARGO_MANIFEST_DIR"),
"/assets/entities/ghost.png"
))
);
}
pub fn update(state: &mut State, engine: &mut EngineContext<'_>) {