From 9b8918d43ed823c59495f1a0b21a8a99e962656e Mon Sep 17 00:00:00 2001 From: Daniel Flanagan Date: Wed, 20 Dec 2023 13:24:16 -0600 Subject: [PATCH] Cleanup and add assets and camera modules --- Cargo.lock | 210 +------------------------------------------------- Cargo.toml | 5 +- src/assets.rs | 28 +++++++ src/camera.rs | 15 ++++ src/main.rs | 63 ++++++--------- 5 files changed, 69 insertions(+), 252 deletions(-) create mode 100644 src/assets.rs create mode 100644 src/camera.rs diff --git a/Cargo.lock b/Cargo.lock index 4c042fd..ea3113a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -265,25 +265,6 @@ dependencies = [ "futures-lite 1.13.0", ] -[[package]] -name = "async-io" -version = "2.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6afaa937395a620e33dc6a742c593c01aced20aa376ffb0f628121198578ccc7" -dependencies = [ - "async-lock 3.2.0", - "cfg-if", - "concurrent-queue", - "futures-io", - "futures-lite 2.1.0", - "parking", - "polling", - "rustix", - "slab", - "tracing", - "windows-sys 0.52.0", -] - [[package]] name = "async-lock" version = "2.8.0" @@ -355,7 +336,6 @@ version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e4bc7e09282a82a48d70ade0c4c1154b0fd7882a735a39c66766a5d0f4718ea9" dependencies = [ - "bevy_dylib", "bevy_internal", ] @@ -429,7 +409,6 @@ dependencies = [ "futures-io", "futures-lite 1.13.0", "js-sys", - "notify-debouncer-full", "parking_lot", "ron", "serde", @@ -482,7 +461,6 @@ dependencies = [ "bevy_tasks", "bevy_utils", "bytemuck", - "serde", ] [[package]] @@ -533,15 +511,6 @@ dependencies = [ "sysinfo", ] -[[package]] -name = "bevy_dylib" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45b99001eb4837c78d9c63cc8b32fda61ea96b194a2cda54b569aeee69a9853c" -dependencies = [ - "bevy_internal", -] - [[package]] name = "bevy_ecs" version = "0.12.1" @@ -677,7 +646,6 @@ dependencies = [ "bevy_math", "bevy_reflect", "bevy_utils", - "serde", "thiserror", ] @@ -731,7 +699,6 @@ dependencies = [ "bevy_ecs", "bevy_utils", "console_error_panic_hook", - "tracing-error", "tracing-log 0.1.4", "tracing-subscriber", "tracing-wasm", @@ -869,7 +836,6 @@ dependencies = [ "ktx2", "naga", "naga_oil", - "profiling", "ruzstd", "serde", "smallvec", @@ -947,7 +913,6 @@ checksum = "f4fefa7fe0da8923525f7500e274f1bd60dbd79918a25cf7d0dfa0a6ba15c1cf" dependencies = [ "async-channel 1.9.0", "async-executor", - "async-io", "async-task", "concurrent-queue", "futures-lite 1.13.0", @@ -987,7 +952,6 @@ dependencies = [ "bevy_reflect", "bevy_utils", "crossbeam-channel", - "serde", "thiserror", ] @@ -1002,7 +966,6 @@ dependencies = [ "bevy_hierarchy", "bevy_math", "bevy_reflect", - "serde", "thiserror", ] @@ -1079,7 +1042,6 @@ dependencies = [ "bevy_reflect", "bevy_utils", "raw-window-handle", - "serde", ] [[package]] @@ -1593,16 +1555,6 @@ dependencies = [ "serde", ] -[[package]] -name = "errno" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" -dependencies = [ - "libc", - "windows-sys 0.52.0", -] - [[package]] name = "euclid" version = "0.22.9" @@ -1663,27 +1615,6 @@ dependencies = [ "simd-adler32", ] -[[package]] -name = "file-id" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6584280525fb2059cba3db2c04abf947a1a29a45ddae89f3870f8281704fafc9" -dependencies = [ - "windows-sys 0.48.0", -] - -[[package]] -name = "filetime" -version = "0.2.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ee447700ac8aa0b2f2bd7bc4462ad686ba06baa6727ac149a2d6277f0d240fd" -dependencies = [ - "cfg-if", - "libc", - "redox_syscall 0.4.1", - "windows-sys 0.52.0", -] - [[package]] name = "fixedbitset" version = "0.4.2" @@ -1748,15 +1679,6 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aa9a19cbb55df58761df49b23516a86d432839add4af60fc256da840f66ed35b" -[[package]] -name = "fsevent-sys" -version = "4.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76ee7a02da4d231650c7cea31349b889be2f45ddb3ef3032d2ec8185f6313fd2" -dependencies = [ - "libc", -] - [[package]] name = "futures-core" version = "0.3.29" @@ -1830,7 +1752,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0af1827b7dd2f36d740ae804c1b3ea0d64c12533fb61ff91883005143a0e8c5a" dependencies = [ "core-foundation", - "inotify 0.10.2", + "inotify", "io-kit-sys", "js-sys", "libc", @@ -2081,17 +2003,6 @@ version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a257582fdcde896fd96463bf2d40eefea0580021c0712a0e2b028b60b47a837a" -[[package]] -name = "inotify" -version = "0.9.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8069d3ec154eb856955c1c0fbffefbf5f3c40a104ec912d4797314c1801abff" -dependencies = [ - "bitflags 1.3.2", - "inotify-sys", - "libc", -] - [[package]] name = "inotify" version = "0.10.2" @@ -2210,26 +2121,6 @@ dependencies = [ "bevy", ] -[[package]] -name = "kqueue" -version = "1.0.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7447f1ca1b7b563588a205fe93dea8df60fd981423a768bc1c0ded35ed147d0c" -dependencies = [ - "kqueue-sys", - "libc", -] - -[[package]] -name = "kqueue-sys" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed9625ffda8729b85e45cf04090035ac368927b8cebc34898e7c120f52e4838b" -dependencies = [ - "bitflags 1.3.2", - "libc", -] - [[package]] name = "ktx2" version = "0.3.0" @@ -2309,12 +2200,6 @@ dependencies = [ "pkg-config", ] -[[package]] -name = "linux-raw-sys" -version = "0.4.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4cd1a83af159aa67994778be9070f0ae1bd732942279cabb14f86f986a21456" - [[package]] name = "lock_api" version = "0.4.11" @@ -2547,39 +2432,6 @@ version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "610a5acd306ec67f907abe5567859a3c693fb9886eb1f012ab8f2a47bef3db51" -[[package]] -name = "notify" -version = "6.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6205bd8bb1e454ad2e27422015fb5e4f2bcc7e08fa8f27058670d208324a4d2d" -dependencies = [ - "bitflags 2.4.1", - "crossbeam-channel", - "filetime", - "fsevent-sys", - "inotify 0.9.6", - "kqueue", - "libc", - "log", - "mio", - "walkdir", - "windows-sys 0.48.0", -] - -[[package]] -name = "notify-debouncer-full" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49f5dab59c348b9b50cf7f261960a20e389feb2713636399cd9082cd4b536154" -dependencies = [ - "crossbeam-channel", - "file-id", - "log", - "notify", - "parking_lot", - "walkdir", -] - [[package]] name = "ntapi" version = "0.4.1" @@ -2891,20 +2743,6 @@ dependencies = [ "miniz_oxide", ] -[[package]] -name = "polling" -version = "3.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf63fa624ab313c11656b4cda960bfc46c410187ad493c41f6ba2d8c1e991c9e" -dependencies = [ - "cfg-if", - "concurrent-queue", - "pin-project-lite", - "rustix", - "tracing", - "windows-sys 0.52.0", -] - [[package]] name = "pp-rs" version = "0.2.1" @@ -2938,20 +2776,6 @@ name = "profiling" version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1de09527cd2ea2c2d59fb6c2f8c1ab8c71709ed9d1b6d60b0e1c9fbb6fdcb33c" -dependencies = [ - "profiling-procmacros", - "tracing", -] - -[[package]] -name = "profiling-procmacros" -version = "1.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d8f36e3c621a72254893ed5cc57d1a069162adb3f98bfef610788661db6ad8d" -dependencies = [ - "quote", - "syn 2.0.41", -] [[package]] name = "quote" @@ -3094,19 +2918,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" -[[package]] -name = "rustix" -version = "0.38.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72e572a5e8ca657d7366229cdde4bd14c4eb5499a9573d4d366fe1b599daa316" -dependencies = [ - "bitflags 2.4.1", - "errno", - "libc", - "linux-raw-sys", - "windows-sys 0.52.0", -] - [[package]] name = "ruzstd" version = "0.4.0" @@ -3500,16 +3311,6 @@ dependencies = [ "valuable", ] -[[package]] -name = "tracing-error" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d686ec1c0f384b1277f097b2f279a2ecc11afe8c133c1aabf036a27cb4cd206e" -dependencies = [ - "tracing", - "tracing-subscriber", -] - [[package]] name = "tracing-log" version = "0.1.4" @@ -4018,15 +3819,6 @@ dependencies = [ "windows-targets 0.48.5", ] -[[package]] -name = "windows-sys" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" -dependencies = [ - "windows-targets 0.52.0", -] - [[package]] name = "windows-targets" version = "0.42.2" diff --git a/Cargo.toml b/Cargo.toml index 06d15d8..19d8ab2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,12 +6,11 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -# TODO(dmf): @release remove `dynamic_linking` -bevy = { version = "0.12.1", features = ["wayland", "file_watcher", "async-io", "serialize", "trace", "dynamic_linking"] } +bevy = { version = "0.12.1", features = ["wayland"] } +# bevy = { version = "0.12.1", features = ["wayland", "file_watcher", "trace"] } [profile.dev] opt-level = 1 [profile.dev.package."*"] opt-level = 3 - diff --git a/src/assets.rs b/src/assets.rs new file mode 100644 index 0000000..66cab28 --- /dev/null +++ b/src/assets.rs @@ -0,0 +1,28 @@ +use bevy::prelude::*; + +#[derive(Resource, Debug, Default)] +pub struct Assets { + pub sprites: Sprites, +} + +#[derive(Resource, Debug, Default)] +pub struct Sprites { + pub square: Handle, +} + +pub struct AssetLoader; + +impl Plugin for AssetLoader { + fn build(&self, app: &mut App) { + app.init_resource::() + .add_systems(Startup, load_assets); + } +} + +fn load_assets(mut sprite_assets: ResMut, asset_server: Res) { + *sprite_assets = Assets { + sprites: Sprites { + square: asset_server.load("assets/img/square.png"), + }, + }; +} diff --git a/src/camera.rs b/src/camera.rs new file mode 100644 index 0000000..deaf733 --- /dev/null +++ b/src/camera.rs @@ -0,0 +1,15 @@ +use bevy::prelude::*; + +pub struct Camera; + +impl Plugin for Camera { + fn build(&self, app: &mut App) { + app.add_systems(Startup, spawn_camera); + } +} + +fn spawn_camera(mut commands: Commands) { + let mut bundle = Camera2dBundle::default(); + bundle.projection.scale = 1.; + commands.spawn(bundle); +} diff --git a/src/main.rs b/src/main.rs index 4b81d3a..9b6dcd8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,51 +1,34 @@ use bevy::prelude::*; -#[derive(Component)] -struct Person; +mod assets; +mod camera; -#[derive(Component)] -struct Name(String); - -#[derive(Component)] -struct Position { - x: f32, - y: f32, -} - -#[derive(Resource)] -struct GreetTimer(Timer); - -struct Entity(u64); - -pub struct HelloPlugin; - -impl Plugin for HelloPlugin { - fn build(&self, app: &mut App) { - // add things to your app here - } -} - -fn add_people(mut commands: Commands) { - commands.spawn((Person, Name("Elaina Proctor".to_string()))); - commands.spawn((Person, Name("Renzo Hume".to_string()))); - commands.spawn((Person, Name("Zayna Nieves".to_string()))); -} fn main() { let mut app = App::new(); - app.add_plugins((DefaultPlugins, HelloPlugin)) - .add_systems(Startup, add_people) - .add_systems(Update, greet_people) - .insert_resource(GreetTimer(Timer::from_seconds(0.2, TimerMode::Repeating))); + app.add_plugins(DefaultPlugins.set(WindowPlugin { + primary_window: Some(Window { + title: "Kodo Tag".into(), + resolution: (800., 600.).into(), + ..Default::default() + }), + ..Default::default() + })) + .add_plugins((camera::Camera, assets::AssetLoader)) + .add_systems(Update, keyboard_input_system) + .insert_resource(ClearColor(Color::rgb(0.3, 0., 0.5))) + .insert_resource(AmbientLight { + color: Color::rgb(1., 1., 1.), + brightness: 1., + }); app.run() } -fn greet_people(time: Res