diff --git a/src/game.rs b/src/game.rs index 9541cd7..0afb9b6 100644 --- a/src/game.rs +++ b/src/game.rs @@ -1,6 +1,4 @@ use bevy::prelude::*; -use bevy_inspector_egui::*; -use bevy_prototype_debug_lines::DebugLinesPlugin; use bevy_rapier2d::prelude::*; use crate::{ @@ -11,29 +9,28 @@ use crate::{ use self::{ camera::{GameCameraPlugin, WORLD_WIDTH}, kinematic::KinematicPlugin, - player::PlayerPlugin, + player::PlayerPlugin, debug::DebugPlugin, }; pub mod camera; pub mod kinematic; pub mod player; +pub mod debug; pub fn init() { App::new() .add_plugins(DefaultPlugins) - .add_plugin(DebugLinesPlugin::default()) .add_plugin(RapierPhysicsPlugin::::default()) - .add_plugin(RapierDebugRenderPlugin::default()) - .add_plugin(WorldInspectorPlugin::new()) + .add_plugin(DebugPlugin) .add_plugin(KinematicPlugin) .add_plugin(GameCameraPlugin) .add_plugin(Terrain2DPlugin) .add_plugin(PlayerPlugin) - .add_startup_system(setup_debug_terrain) + .add_startup_system(setup_terrain) .run(); } -fn setup_debug_terrain(mut commands: Commands, mut terrain: ResMut) { +fn setup_terrain(mut commands: Commands, mut terrain: ResMut) { let terrain_gen = TerrainGen2D::new(432678); for y in 0..(WORLD_WIDTH / Chunk2D::SIZE_Y as i32) { for x in 0..(WORLD_WIDTH / Chunk2D::SIZE_X as i32) { diff --git a/src/game/debug.rs b/src/game/debug.rs new file mode 100644 index 0000000..f9e8664 --- /dev/null +++ b/src/game/debug.rs @@ -0,0 +1,14 @@ +use bevy::prelude::*; +use bevy_inspector_egui::*; +use bevy_prototype_debug_lines::DebugLinesPlugin; +use bevy_rapier2d::prelude::*; + +pub struct DebugPlugin; + +impl Plugin for DebugPlugin { + fn build(&self, app: &mut App) { + app.add_plugin(DebugLinesPlugin::default()) + .add_plugin(RapierDebugRenderPlugin::default()) + .add_plugin(WorldInspectorPlugin::new()); + } +}