Overworld Movement #9
2 changed files with 23 additions and 27 deletions
|
@ -1,14 +1,10 @@
|
|||
use comfy::{
|
||||
draw_circle, draw_rect_outline, draw_sprite, main_camera_mut, EngineContext, IVec2,
|
||||
Vec2, RED, WHITE,
|
||||
draw_circle, draw_rect_outline, draw_sprite, is_key_down, is_key_pressed,
|
||||
main_camera_mut, EngineContext, IVec2, KeyCode, Vec2, RED, WHITE
|
||||
};
|
||||
use log::info;
|
||||
use comfy::is_key_pressed;
|
||||
use comfy::is_key_down;
|
||||
use comfy::KeyCode;
|
||||
|
||||
use crate::game::Ghost;
|
||||
use crate::game::ZLayer;
|
||||
use crate::game::{Ghost, ZLayer};
|
||||
|
||||
pub mod worldgen;
|
||||
|
||||
|
@ -21,7 +17,7 @@ pub fn draw(state: &crate::State, _engine: &comfy::EngineContext<'_>) {
|
|||
coords.as_vec2(),
|
||||
WHITE,
|
||||
ZLayer::MapMax - i,
|
||||
Vec2::ONE,
|
||||
Vec2::ONE
|
||||
);
|
||||
draw_rect_outline(coords.as_vec2(), Vec2::ONE, 0.1, RED, 10);
|
||||
}
|
||||
|
@ -30,7 +26,7 @@ pub fn draw(state: &crate::State, _engine: &comfy::EngineContext<'_>) {
|
|||
state.ghost.overworld_pos.as_vec2(),
|
||||
0.5,
|
||||
RED,
|
||||
ZLayer::Ghost.into(),
|
||||
ZLayer::Ghost.into()
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -58,17 +54,17 @@ pub fn update(state: &mut crate::State, _engine: &mut EngineContext<'_>) {
|
|||
// generate more chunks if needed
|
||||
{
|
||||
let half_viewport = (camera.world_viewport() * 0.5 + 3.0).as_ivec2();
|
||||
state
|
||||
.overworld
|
||||
.get_or_generate_tile(*ghost_pos + IVec2::new(half_viewport.x, half_viewport.y));
|
||||
state
|
||||
.overworld
|
||||
.get_or_generate_tile(*ghost_pos + IVec2::new(half_viewport.x, -half_viewport.y));
|
||||
state
|
||||
.overworld
|
||||
.get_or_generate_tile(*ghost_pos + IVec2::new(-half_viewport.x, half_viewport.y));
|
||||
state
|
||||
.overworld
|
||||
.get_or_generate_tile(*ghost_pos + IVec2::new(-half_viewport.x, -half_viewport.y));
|
||||
state.overworld.get_or_generate_tile(
|
||||
*ghost_pos + IVec2::new(half_viewport.x, half_viewport.y)
|
||||
);
|
||||
state.overworld.get_or_generate_tile(
|
||||
*ghost_pos + IVec2::new(half_viewport.x, -half_viewport.y)
|
||||
);
|
||||
state.overworld.get_or_generate_tile(
|
||||
*ghost_pos + IVec2::new(-half_viewport.x, half_viewport.y)
|
||||
);
|
||||
state.overworld.get_or_generate_tile(
|
||||
*ghost_pos + IVec2::new(-half_viewport.x, -half_viewport.y)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ pub struct Ghost {
|
|||
pub charge: f32,
|
||||
/// max electric charge of the Ghost
|
||||
pub max_charge: f32,
|
||||
pub overworld_pos: IVec2,
|
||||
pub overworld_pos: IVec2
|
||||
}
|
||||
|
||||
impl Default for Ghost {
|
||||
|
@ -19,7 +19,7 @@ impl Default for Ghost {
|
|||
Self {
|
||||
charge: 1000.0,
|
||||
max_charge: 1000.0,
|
||||
overworld_pos: IVec2::ZERO,
|
||||
overworld_pos: IVec2::ZERO
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue