diff --git a/Cargo.lock b/Cargo.lock index cf7f4bf..ab118f4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -388,17 +388,6 @@ dependencies = [ "syn", ] -[[package]] -name = "bevy-template" -version = "0.1.0" -dependencies = [ - "bevy", - "bevy-inspector-egui", - "bevy_mod_debugdump", - "bevy_rapier2d", - "num-traits", -] - [[package]] name = "bevy_a11y" version = "0.15.1" @@ -2408,6 +2397,17 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8d1add55171497b4705a648c6b583acafb01d58050a51727785f0b2c8e0a2b2" +[[package]] +name = "glorbs" +version = "0.1.0" +dependencies = [ + "bevy", + "bevy-inspector-egui", + "bevy_mod_debugdump", + "bevy_rapier2d", + "num-traits", +] + [[package]] name = "glow" version = "0.14.2" diff --git a/Cargo.toml b/Cargo.toml index fba3fd3..d2856d0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "bevy-template" +name = "glorbs" version = "0.1.0" edition = "2021" diff --git a/assets/sprites/box.aseprite b/assets/sprites/box.aseprite new file mode 100644 index 0000000..c922ed0 Binary files /dev/null and b/assets/sprites/box.aseprite differ diff --git a/assets/sprites/box.png b/assets/sprites/box.png new file mode 100644 index 0000000..797c4c1 Binary files /dev/null and b/assets/sprites/box.png differ diff --git a/assets/sprites/glorb.aseprite b/assets/sprites/glorb.aseprite new file mode 100644 index 0000000..f953e63 Binary files /dev/null and b/assets/sprites/glorb.aseprite differ diff --git a/assets/sprites/glorb.png b/assets/sprites/glorb.png new file mode 100644 index 0000000..59b02c2 Binary files /dev/null and b/assets/sprites/glorb.png differ diff --git a/assets/sprites/tree.aseprite b/assets/sprites/tree.aseprite new file mode 100644 index 0000000..463ebb4 Binary files /dev/null and b/assets/sprites/tree.aseprite differ diff --git a/assets/sprites/tree.png b/assets/sprites/tree.png new file mode 100644 index 0000000..906d59b Binary files /dev/null and b/assets/sprites/tree.png differ diff --git a/assets/sprites/wood.aseprite b/assets/sprites/wood.aseprite new file mode 100644 index 0000000..6985d16 Binary files /dev/null and b/assets/sprites/wood.aseprite differ diff --git a/assets/sprites/wood.png b/assets/sprites/wood.png new file mode 100644 index 0000000..bc84930 Binary files /dev/null and b/assets/sprites/wood.png differ diff --git a/src/debug.rs b/src/debug.rs index bde06f1..12273ad 100644 --- a/src/debug.rs +++ b/src/debug.rs @@ -9,7 +9,7 @@ impl Plugin for DebugPlugin { fn build(&self, app: &mut App) { app.configure_sets(Last, DebugSet.run_if(is_debug_enabled)); - app.insert_resource(DebugMode::on()) + app.insert_resource(DebugMode::off()) .add_plugins(( bevy_inspector_egui::quick::WorldInspectorPlugin::new().run_if(is_debug_enabled), bevy_rapier2d::prelude::RapierDebugRenderPlugin::default(), diff --git a/src/game.rs b/src/game.rs index 06f139b..a36d8ef 100644 --- a/src/game.rs +++ b/src/game.rs @@ -1,5 +1,5 @@ use crate::{debug, game_setup}; -use bevy::prelude::*; +use bevy::{prelude::*, sprite::Anchor}; use bevy_rapier2d::prelude::*; pub fn init(app: &mut App) { @@ -11,20 +11,51 @@ pub fn init(app: &mut App) { app.add_systems(Startup, setup_2d) .add_systems(Update, demo_2d); - - // app.add_systems(Startup, setup_3d) - // .add_systems(Update, demo_3d); } -fn setup_2d(mut commands: Commands) { +fn setup_2d(mut commands: Commands, assets: Res) { commands.spawn(( Name::from("Demo 2D camera"), Camera2d, Transform::from_xyz(0.0, 0.0, 10.0), )); + commands.spawn(( - Name::from("Demo 2D sprite"), - Sprite::sized(Vec2::splat(256.0)), + Name::from("Glorb"), + Transform::from_xyz(-200.0, 0.0, 0.0), + Sprite { + image: assets.load("sprites/glorb.png"), + anchor: Anchor::BottomCenter, + ..default() + }, + )); + + commands.spawn(( + Name::from("Box"), + Transform::from_xyz(-200.0, -150.0, 0.0), + Sprite { + image: assets.load("sprites/box.png"), + anchor: Anchor::Custom(Vec2 { x: 0.0, y: -0.375 }), + ..default() + }, + )); + + commands.spawn(( + Name::from("Wood"), + Sprite { + image: assets.load("sprites/wood.png"), + ..default() + }, + )); + + commands.spawn(( + Name::from("Tree"), + Transform::from_xyz(200.0, 0.0, 0.0), + Sprite { + image: assets.load("sprites/tree.png"), + anchor: Anchor::Custom(Vec2 { x: 0.0, y: -0.375 }), + ..default() + }, )); } @@ -51,68 +82,3 @@ fn demo_2d( } } } - -fn setup_3d( - mut commands: Commands, - mut meshes: ResMut>, - mut materials: ResMut>, -) { - commands.spawn(( - Name::from("Demo 3D camera"), - Camera3d::default(), - Transform::from_xyz(0.0, 0.0, 10.0), - PointLight::default(), - )); - commands.spawn(( - Name::from("Demo 3D cuboid"), - Mesh3d(meshes.add(Cuboid::from_length(1.0))), - MeshMaterial3d(materials.add(Color::from(bevy::color::palettes::css::ORANGE))), - )); -} - -fn demo_3d( - mut camera_query: Query<&mut Transform, With>, - mut mouse_events: EventReader, - mouse_input: Res>, - key_input: Res>, - time: Res