diff --git a/Cargo.lock b/Cargo.lock index 3446ced..30c4f28 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -364,6 +364,7 @@ dependencies = [ "bevy", "bevy-inspector-egui", "bevy_mod_debugdump", + "bevy_prototype_debug_lines", "bevy_rapier2d", "num-traits", ] @@ -833,6 +834,13 @@ dependencies = [ "thread_local", ] +[[package]] +name = "bevy_prototype_debug_lines" +version = "0.11.1" +dependencies = [ + "bevy", +] + [[package]] name = "bevy_ptr" version = "0.13.0" diff --git a/Cargo.toml b/Cargo.toml index 46e6532..3fb2348 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,6 +11,9 @@ bevy-inspector-egui = "0.23.2" bevy_mod_debugdump = "0.10.0" bevy_rapier2d = "0.25.0" num-traits = "0.2.18" +bevy_prototype_debug_lines = { path = "../bevy_debug_lines", features = [ + # "3d" +] } # NOTE: Local version until registry updates to 0.13 # Enable a small amount of optimization in debug mode [profile.dev] diff --git a/src/debug.rs b/src/debug.rs index 4cfe27a..2e2c658 100644 --- a/src/debug.rs +++ b/src/debug.rs @@ -9,8 +9,9 @@ impl Plugin for DebugPlugin { fn build(&self, app: &mut App) { app.configure_sets(Last, DebugSet.run_if(is_debug_enabled)); - app.insert_resource(DebugMode::off()) + app.insert_resource(DebugMode::on()) .add_plugins(( + bevy_prototype_debug_lines::DebugLinesPlugin::default(), bevy_inspector_egui::quick::WorldInspectorPlugin::new().run_if(is_debug_enabled), bevy_rapier2d::prelude::RapierDebugRenderPlugin::default(), )) @@ -34,7 +35,7 @@ impl DebugMode { } } -fn is_debug_enabled(debug_mode: Res) -> bool { +pub fn is_debug_enabled(debug_mode: Res) -> bool { debug_mode.enabled } diff --git a/src/game.rs b/src/game.rs index d61f35b..e1f1e63 100644 --- a/src/game.rs +++ b/src/game.rs @@ -2,15 +2,137 @@ use crate::{debug, game_setup}; use bevy::prelude::*; pub fn init(app: &mut App) { - app.add_plugins(( + let mut app = app.add_plugins(( game_setup::GameSetupPlugin, bevy_rapier2d::prelude::RapierPhysicsPlugin::::default( ), debug::DebugPlugin, - )) - .add_systems(Startup, setup); + )); + + app.add_systems(Startup, setup_2d) + .add_systems(Update, demo_2d); + + // NOTE: If using 3D, make sure you have '3d' feature enabled for the + // 'bevy_prototype_debug_lines' crate + // app.add_systems(Startup, setup_3d) + // .add_systems(Update, demo_3d); } -fn setup(mut commands: Commands) { - commands.spawn(Camera2dBundle::default()); +fn setup_2d(mut commands: Commands) { + commands.spawn(Camera2dBundle { + transform: Transform::from_xyz(0.0, 0.0, 100.0), + ..default() + }); +} + +fn demo_2d( + mut camera_query: Query<(&mut Transform, &mut OrthographicProjection)>, + mut mouse_events: EventReader, + mut scroll_events: EventReader, + mut debug_lines: ResMut, + mut debug_shapes: ResMut, + mouse_input: Res>, + time: Res