mirror of
https://github.com/Noratrieb/game-wip-dontplay.git
synced 2026-01-15 12:15:01 +01:00
Add torches
This commit is contained in:
parent
704819a988
commit
77099ab8a6
13 changed files with 427 additions and 133 deletions
102
src/debug.rs
102
src/debug.rs
|
|
@ -1,11 +1,20 @@
|
|||
use sfml::window::Key;
|
||||
use egui_inspect::inspect;
|
||||
use sfml::{audio::SoundSource, window::Key};
|
||||
|
||||
use crate::input::Input;
|
||||
use crate::{
|
||||
game::GameState,
|
||||
input::Input,
|
||||
math::{px_per_frame_to_km_h, WorldPos},
|
||||
res::Res,
|
||||
stringfmt::LengthDisp,
|
||||
tiles::tiledb_edit_ui::tiledb_edit_ui,
|
||||
};
|
||||
|
||||
#[derive(Default, Debug)]
|
||||
pub struct DebugState {
|
||||
pub panel: bool,
|
||||
panel: bool,
|
||||
pub freecam: bool,
|
||||
tiledb_edit: bool,
|
||||
}
|
||||
|
||||
impl DebugState {
|
||||
|
|
@ -18,3 +27,90 @@ impl DebugState {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn debug_panel_ui(
|
||||
debug: &mut DebugState,
|
||||
mut game: &mut GameState,
|
||||
ctx: &egui::Context,
|
||||
res: &mut Res,
|
||||
mut scale: &mut u8,
|
||||
) {
|
||||
egui::Window::new("Debug (F12)").show(ctx, |ui| {
|
||||
if debug.freecam {
|
||||
ui.label("Cam x");
|
||||
ui.add(egui::DragValue::new(&mut game.camera_offset.x));
|
||||
ui.label("Cam y");
|
||||
ui.add(egui::DragValue::new(&mut game.camera_offset.y));
|
||||
let co = game.camera_offset;
|
||||
ui.label(format!(
|
||||
"Cam Depth: {}",
|
||||
LengthDisp(co.y as f32 - WorldPos::SURFACE as f32)
|
||||
));
|
||||
ui.label(format!(
|
||||
"Cam offset from center: {}",
|
||||
LengthDisp(co.x as f32 - WorldPos::CENTER as f32)
|
||||
));
|
||||
} else {
|
||||
ui.label(format!(
|
||||
"Player Depth: {}",
|
||||
LengthDisp(game.player.feet_y() as f32 - WorldPos::SURFACE as f32)
|
||||
));
|
||||
ui.label(format!(
|
||||
"Player offset from center: {}",
|
||||
LengthDisp(game.player.col_en.en.pos.x as f32 - WorldPos::CENTER as f32)
|
||||
));
|
||||
ui.label(format!(
|
||||
"Hspeed: {} ({} km/h)",
|
||||
game.player.hspeed,
|
||||
px_per_frame_to_km_h(game.player.hspeed)
|
||||
));
|
||||
ui.label(format!(
|
||||
"Vspeed: {} ({} km/h)",
|
||||
game.player.vspeed,
|
||||
px_per_frame_to_km_h(game.player.vspeed)
|
||||
));
|
||||
}
|
||||
ui.label("Music volume");
|
||||
let mut vol = res.surf_music.volume();
|
||||
ui.add(egui::DragValue::new(&mut vol));
|
||||
res.surf_music.set_volume(vol);
|
||||
ui.separator();
|
||||
egui::ScrollArea::both()
|
||||
.id_source("insp_scroll")
|
||||
.max_height(240.)
|
||||
.max_width(340.0)
|
||||
.show(ui, |ui| {
|
||||
inspect! {
|
||||
ui,
|
||||
scale,
|
||||
game,
|
||||
debug.tiledb_edit
|
||||
}
|
||||
});
|
||||
ui.separator();
|
||||
egui::ScrollArea::vertical().show(ui, |ui| {
|
||||
gamedebug_core::for_each_imm(|info| match info {
|
||||
gamedebug_core::Info::Msg(msg) => {
|
||||
ui.label(msg);
|
||||
}
|
||||
gamedebug_core::Info::Rect(_, _, _, _, _) => todo!(),
|
||||
});
|
||||
});
|
||||
gamedebug_core::clear_immediates();
|
||||
});
|
||||
}
|
||||
|
||||
pub(crate) fn do_debug_ui(
|
||||
ctx: &egui::Context,
|
||||
debug: &mut DebugState,
|
||||
game: &mut GameState,
|
||||
res: &mut Res,
|
||||
scale: &mut u8,
|
||||
) {
|
||||
if debug.panel {
|
||||
debug_panel_ui(debug, game, ctx, res, scale);
|
||||
}
|
||||
if debug.tiledb_edit {
|
||||
tiledb_edit_ui(ctx, &mut game.tile_db);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue