lots of adds

This commit is contained in:
2026-09-19 21:44:14 +02:00
parent 92f83c1c4e
commit d6e4c06d7e
12 changed files with 630 additions and 39 deletions
+23 -4
View File
@@ -4,6 +4,7 @@ use bevy::{
};
use crate::{
config::{SCREEN_HEIGHT, SCREEN_WIDTH},
gameplay::{camera::MainCamera, player::Player},
states::GameState,
world::RunSeed,
@@ -15,6 +16,9 @@ pub struct Debug;
#[derive(Component)]
pub struct DebugCamera;
#[derive(Component)]
struct ViewDebugText;
fn spawn_debug_camera(mut commands: Commands) {
commands.spawn((
Debug,
@@ -69,8 +73,8 @@ fn spawn_debug_frame(mut commands: Commands) {
FrameSide::Right,
] {
let size = match side {
FrameSide::Top | FrameSide::Bottom => Vec2::new(1936.0, 8.0),
FrameSide::Left | FrameSide::Right => Vec2::new(8.0, 1096.0),
FrameSide::Top | FrameSide::Bottom => Vec2::new(SCREEN_WIDTH + 16.0, 8.0),
FrameSide::Left | FrameSide::Right => Vec2::new(8.0, SCREEN_HEIGHT + 16.0),
};
commands.spawn((
@@ -91,8 +95,8 @@ fn draw_view_frame(
>,
) {
let center = main_camera.translation;
let half_width = 960.0;
let half_height = 540.0;
let half_width = SCREEN_WIDTH / 2.0;
let half_height = SCREEN_HEIGHT / 2.0;
let visible = if debug_camera.is_active {
Visibility::Visible
@@ -154,6 +158,15 @@ fn spawn_debug_texts(mut commands: Commands) {
},
TextColor(Color::srgb(1.0, 1.0, 0.0)),
FpsDebugText,
),
(
Text::new(""),
TextFont {
font_size: FontSize::Px(20.0),
..default()
},
TextColor(Color::srgb(1.0, 1.0, 0.0)),
ViewDebugText,
)
],
));
@@ -184,6 +197,11 @@ fn cleanup_debug(mut commands: Commands, entities: Query<Entity, With<Debug>>) {
}
}
// Show the world rect the game camera renders
fn update_view_debug_text(mut text: Single<&mut Text, With<ViewDebugText>>) {
text.0 = format!("View: {SCREEN_WIDTH:.0}x{SCREEN_HEIGHT:.0}");
}
pub struct DebugPlugin;
impl Plugin for DebugPlugin {
@@ -205,6 +223,7 @@ impl Plugin for DebugPlugin {
toggle_debug_camera,
update_seed_debug_text,
update_fps_debug_text,
update_view_debug_text,
)
.run_if(in_state(GameState::InGame)),
)