diff --git a/Cargo.lock b/Cargo.lock index e6ff57f..351aabd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -68,7 +68,7 @@ dependencies = [ "accesskit", "accesskit_macos", "accesskit_windows", - "raw-window-handle 0.6.0", + "raw-window-handle 0.6.1", "winit", ] @@ -169,6 +169,15 @@ dependencies = [ "libc", ] +[[package]] +name = "app" +version = "0.1.0" +dependencies = [ + "bevy", + "bevy-inspector-egui", + "game", +] + [[package]] name = "approx" version = "0.5.1" @@ -1089,7 +1098,7 @@ dependencies = [ "bevy_math", "bevy_reflect", "bevy_utils", - "raw-window-handle 0.6.0", + "raw-window-handle 0.6.1", "smol_str", ] @@ -1112,7 +1121,7 @@ dependencies = [ "bevy_utils", "bevy_window", "crossbeam-channel", - "raw-window-handle 0.6.0", + "raw-window-handle 0.6.1", "wasm-bindgen", "web-sys", "winit", @@ -1307,12 +1316,13 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.94" +version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17f6e324229dc011159fcc089755d1e2e216a90d43a7dea6853ca740b84f35e7" +checksum = "d32a725bc159af97c3e629873bb9f88fb8cf8a4867175f76dc987815ea07c83b" dependencies = [ "jobserver", "libc", + "once_cell", ] [[package]] @@ -1658,6 +1668,15 @@ dependencies = [ "bytemuck", ] +[[package]] +name = "editor" +version = "0.1.0" +dependencies = [ + "bevy", + "bevy-inspector-egui", + "game", +] + [[package]] name = "egui" version = "0.27.2" @@ -1935,6 +1954,14 @@ dependencies = [ "thread_local", ] +[[package]] +name = "game" +version = "0.1.0" +dependencies = [ + "bevy", + "bevy-inspector-egui", +] + [[package]] name = "gethostname" version = "0.4.3" @@ -2597,7 +2624,7 @@ dependencies = [ "log", "ndk-sys", "num_enum", - "raw-window-handle 0.6.0", + "raw-window-handle 0.6.1", "thiserror", ] @@ -3044,9 +3071,9 @@ checksum = "f2ff9a1f06a88b01621b7ae906ef0211290d1c8a168a15542486a8f61c0833b9" [[package]] name = "raw-window-handle" -version = "0.6.0" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42a9830a0e1b9fb145ebb365b8bc4ccd75f290f98c0247deafbbe2c75cefb544" +checksum = "8cc3bcbdb1ddfc11e700e62968e6b4cc9c75bb466464ad28fb61c5b2c964418b" [[package]] name = "rectangle-pack" @@ -3152,9 +3179,9 @@ checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" [[package]] name = "rustix" -version = "0.38.32" +version = "0.38.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65e04861e65f21776e67888bfbea442b3642beaa0138fdb1dd7a84a52dffdb89" +checksum = "e3cc72858054fcff6d7dea32df2aeaee6a7c24227366d7ea429aada2f26b16ad" dependencies = [ "bitflags 2.5.0", "errno", @@ -3411,28 +3438,20 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "that-has-no-name" -version = "0.1.0" -dependencies = [ - "bevy", - "bevy-inspector-egui", -] - [[package]] name = "thiserror" -version = "1.0.58" +version = "1.0.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03468839009160513471e86a034bb2c5c0e4baae3b43f79ffc55c4a5427b3297" +checksum = "f0126ad08bff79f29fc3ae6a55cc72352056dfff61e3ff8bb7129476d44b23aa" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.58" +version = "1.0.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" +checksum = "d1cd413b5d558b4c5bf3680e324a6fa5014e7b7c067a51e69dbdf47eb7148b66" dependencies = [ "proc-macro2", "quote", @@ -3942,7 +3961,7 @@ dependencies = [ "naga", "parking_lot", "profiling", - "raw-window-handle 0.6.0", + "raw-window-handle 0.6.1", "smallvec", "static_assertions", "wasm-bindgen", @@ -3970,7 +3989,7 @@ dependencies = [ "once_cell", "parking_lot", "profiling", - "raw-window-handle 0.6.0", + "raw-window-handle 0.6.1", "rustc-hash", "smallvec", "thiserror", @@ -4013,7 +4032,7 @@ dependencies = [ "parking_lot", "profiling", "range-alloc", - "raw-window-handle 0.6.0", + "raw-window-handle 0.6.1", "renderdoc-sys", "rustc-hash", "smallvec", @@ -4385,7 +4404,7 @@ dependencies = [ "once_cell", "orbclient", "percent-encoding", - "raw-window-handle 0.6.0", + "raw-window-handle 0.6.1", "redox_syscall 0.3.5", "rustix", "sctk-adwaita", diff --git a/Cargo.toml b/Cargo.toml index efb8bbf..56fee5e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,11 +1,9 @@ -[package] -name = "that-has-no-name" -version = "0.1.0" -edition = "2021" +[workspace] +members = ["app", "editor", "game"] +# default-members = ["app", "game"] +resolver = "2" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] +[workspace.dependencies] bevy = "0.13.2" bevy-inspector-egui = "0.24.0" diff --git a/README.md b/README.md index 6a14d4a..8043ab6 100644 --- a/README.md +++ b/README.md @@ -4,3 +4,18 @@ original concept sketched out for QGJam, 2023 Oct -- [beginning of godot impleme building with [bevy](https://bevyengine.org/) +## developing +this project is structured with two binaries: +- an app entrypoint in which to run the game +- an editor entrypoint in which to edit assets to be included in the game +and one library: +- a game lib that contains most of the game logic, data and assets + +### running +```sh +cargo run # launches from "app" binary +``` +```sh +cargo run --bin editor # launches from "editor" binary +``` + diff --git a/app/Cargo.toml b/app/Cargo.toml new file mode 100644 index 0000000..0ce1686 --- /dev/null +++ b/app/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "app" +version = "0.1.0" +edition = "2021" +# it is strange to me that this lives in the bin and not the workspace virtual manifest +default-run = "app" + +[dependencies] +bevy = "0.13.2" +bevy-inspector-egui = "0.24.0" +game = { version = "0.1.0", path = "../game" } diff --git a/src/main.rs b/app/src/main.rs similarity index 77% rename from src/main.rs rename to app/src/main.rs index ff859d3..71783c4 100644 --- a/src/main.rs +++ b/app/src/main.rs @@ -1,5 +1,12 @@ -use bevy::prelude::* +use bevy::{ + prelude::*, + input::{common_conditions::input_toggle_active, keyboard::KeyboardInput}, + window::{ReceivedCharacter, WindowResolution}, +}; use bevy_inspector_egui::quick::WorldInspectorPlugin; + +use game::{camera, ui}; + const VERSION: &str = "0.1.0"; // display constants const WINDOW_WIDTH: f32 = 1024.0; @@ -12,6 +19,10 @@ enum AppState { InGame, } +fn start_game(mut next_state: ResMut>) { + next_state.set(AppState::InGame) +} + fn start_app() { println!("starting app!"); } @@ -31,6 +42,8 @@ fn main() { primary_window: app_window, ..default() }), + camera::CameraPlugin, + ui::UIPlugin, StartAppPlugin, )) .add_plugins( @@ -46,4 +59,3 @@ impl Plugin for StartAppPlugin { app.init_state::().add_systems(Startup, start_app); } } - diff --git a/editor/Cargo.toml b/editor/Cargo.toml new file mode 100644 index 0000000..7dc9ea4 --- /dev/null +++ b/editor/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "editor" +version = "0.1.0" +edition = "2021" + +[dependencies] +bevy = "0.13.2" +bevy-inspector-egui = "0.24.0" +game = { version = "0.1.0", path = "../game" } diff --git a/editor/src/main.rs b/editor/src/main.rs new file mode 100644 index 0000000..4ec6992 --- /dev/null +++ b/editor/src/main.rs @@ -0,0 +1,26 @@ +use bevy::{input::common_conditions::input_toggle_active, prelude::*, window::WindowResolution}; +use bevy_inspector_egui::quick::WorldInspectorPlugin; + +const VERSION: &str = "0.1.0"; +// display constants +const WINDOW_WIDTH: f32 = 1024.0; +const WINDOW_HEIGHT: f32 = 768.0; + +fn main() { + let app_window = Some(Window { + title: format!("that-has-no-name--EDITOR:{}", VERSION).into(), + resolution: WindowResolution::new(WINDOW_WIDTH, WINDOW_HEIGHT), + resizable: true, + ..default() + }); + + App::new() + .add_plugins((DefaultPlugins.set(WindowPlugin { + primary_window: app_window, + ..default() + }),)) + .add_plugins( + WorldInspectorPlugin::default().run_if(input_toggle_active(true, KeyCode::Escape)), + ) + .run(); +} diff --git a/game/Cargo.toml b/game/Cargo.toml new file mode 100644 index 0000000..39993fc --- /dev/null +++ b/game/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "game" +version = "0.1.0" +edition = "2021" + +[dependencies] +bevy = "0.13.2" +bevy-inspector-egui = "0.24.0" \ No newline at end of file diff --git a/game/src/camera.rs b/game/src/camera.rs new file mode 100644 index 0000000..bf712ea --- /dev/null +++ b/game/src/camera.rs @@ -0,0 +1,16 @@ +use bevy::prelude::*; + +pub struct CameraPlugin; + +impl Plugin for CameraPlugin { + fn build(&self, app: &mut App) { + app.add_systems(Startup, setup); + } +} + +#[derive(Component)] +struct MainCamera; + +fn setup(mut commands: Commands) { + commands.spawn((Camera2dBundle::default(), MainCamera)); +} diff --git a/game/src/lib.rs b/game/src/lib.rs new file mode 100644 index 0000000..9de171f --- /dev/null +++ b/game/src/lib.rs @@ -0,0 +1,2 @@ +pub mod ui; +pub mod camera; diff --git a/game/src/ui/mod.rs b/game/src/ui/mod.rs new file mode 100644 index 0000000..b789126 --- /dev/null +++ b/game/src/ui/mod.rs @@ -0,0 +1,185 @@ +use bevy::prelude::*; + +pub struct UIPlugin; + +impl Plugin for UIPlugin { + fn build(&self, app: &mut App) { + app.add_systems(Startup, spawn_ui); + } +} + +fn spawn_ui(mut commands: Commands) { + commands + .spawn(( + NodeBundle { + style: Style { ..default() }, + ..default() + }, + Name::new("UI Root"), + )) + .with_children(|commands| { + commands.spawn(( + NodeBundle { + background_color: BackgroundColor(Color::Rgba { + red: 255.0, + green: 0.0, + blue: 0.0, + alpha: 200.0, + }), + style: Style { + position_type: PositionType::Absolute, + min_width: Val::Px(216.0), + min_height: Val::Px(288.0), + ..default() + }, + ..default() + }, + Name::new("Visual Container"), + VisualContainer, + )); + commands.spawn(( + NodeBundle { + background_color: BackgroundColor(Color::Rgba { + red: 0.0, + green: 255.0, + blue: 255.0, + alpha: 200.0, + }), + style: Style { + position_type: PositionType::Absolute, + left: Val::Px(216.0), + min_width: Val::Px(504.0), + min_height: Val::Px(480.0), + ..default() + }, + ..default() + }, + Name::new("Main Container"), + MainContainer, + )); + commands.spawn(( + NodeBundle { + background_color: BackgroundColor(Color::Rgba { + red: 255.0, + green: 255.0, + blue: 0.0, + alpha: 200.0, + }), + style: Style { + position_type: PositionType::Absolute, + left: Val::Px(720.0), + min_width: Val::Px(304.0), + min_height: Val::Px(384.0), + ..default() + }, + ..default() + }, + Name::new("Overlay Container"), + OverlayContainer, + )); + commands.spawn(( + NodeBundle { + background_color: BackgroundColor(Color::Rgba { + red: 255.0, + green: 0.0, + blue: 255.0, + alpha: 200.0, + }), + style: Style { + position_type: PositionType::Absolute, + top: Val::Px(288.0), + min_width: Val::Px(216.0), + min_height: Val::Px(192.0), + ..default() + }, + ..default() + }, + Name::new("Help Container"), + HelpContainer, + )); + commands.spawn(( + NodeBundle { + background_color: BackgroundColor(Color::Rgba { + red: 0.0, + green: 0.0, + blue: 255.0, + alpha: 200.0, + }), + style: Style { + position_type: PositionType::Absolute, + top: Val::Px(384.0), + left: Val::Px(720.0), + min_width: Val::Px(394.0), + min_height: Val::Px(96.0), + ..default() + }, + ..default() + }, + Name::new("Input Container"), + InputContainer, + )); + commands.spawn(( + NodeBundle { + background_color: BackgroundColor(Color::Rgba { + red: 0.0, + green: 255.0, + blue: 0.0, + alpha: 200.0, + }), + style: Style { + position_type: PositionType::Absolute, + top: Val::Px(512.0), + min_width: Val::Px(720.0), + min_height: Val::Px(256.0), + ..default() + }, + ..default() + }, + Name::new("Jumper Container"), + JumperContainer, + )); + commands.spawn(( + NodeBundle { + background_color: BackgroundColor(Color::Rgba { + red: 127.0, + green: 127.0, + blue: 127.0, + alpha: 200.0, + }), + style: Style { + position_type: PositionType::Absolute, + left: Val::Px(720.0), + top: Val::Px(512.0), + min_width: Val::Px(394.0), + min_height: Val::Px(256.0), + ..default() + }, + ..default() + }, + Name::new("Id Container"), + IdContainer, + )); + }); +} + +#[derive(Component)] +pub struct VisualContainer; + +#[derive(Component)] +pub struct MainContainer; + +#[derive(Component)] +pub struct OverlayContainer; + +#[derive(Component)] +pub struct HelpContainer; + +#[derive(Component)] +pub struct InputContainer; + +#[derive(Component)] +pub struct JumperContainer; + +#[derive(Component)] +pub struct IdContainer; +//