From ad2a30445542e10928336790d6fb0d0a6792ca0f Mon Sep 17 00:00:00 2001 From: Dane Johnson Date: Tue, 17 Oct 2023 11:08:31 -0500 Subject: [PATCH] Make characters visible --- Cargo.lock | 172 ++++++++++++++++++++++++---------------------- Cargo.toml | 2 +- src/characters.rs | 18 ----- src/main.rs | 77 +++++++++++---------- 4 files changed, 134 insertions(+), 135 deletions(-) delete mode 100644 src/characters.rs diff --git a/Cargo.lock b/Cargo.lock index 06a3b50..9b2c0d9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -290,18 +290,19 @@ checksum = "9ba43ea6f343b788c8764558649e08df62f86c6ef251fdaeb1ffd010a9ae50a2" [[package]] name = "bevy" -version = "0.11.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18e71a9143ac21bed247c30129399af8be170309e7ff5983a1bd37e87d3da520" +checksum = "91c6d3ec4f89e85294dc97334c5b271ddc301fdf67ac9bb994fe44d9273e6ed7" dependencies = [ + "bevy_dylib", "bevy_internal", ] [[package]] name = "bevy_a11y" -version = "0.11.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d87d5753cefaeb5f5c5d5e937844f5386eabaf9ab95f3013e86d8fb438d424e" +checksum = "132c9e35a77c5395951f6d25fa2c52ee92296353426df4f961e60f3ff47e2e42" dependencies = [ "accesskit", "bevy_app", @@ -311,9 +312,9 @@ dependencies = [ [[package]] name = "bevy_animation" -version = "0.11.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc510d47ec4813359b7e715edc6976380d4244833feae124977468994554a0ab" +checksum = "f44eae3f1c35a87e38ad146f72317f19ce7616dad8bbdfb88ee752c1282d28c5" dependencies = [ "bevy_app", "bevy_asset", @@ -330,9 +331,9 @@ dependencies = [ [[package]] name = "bevy_app" -version = "0.11.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3cb660188d5d4ceaead6d5861ce22ecedc08b68c385cc8edf0a3c0c0285560bf" +checksum = "f557a7d59e1e16892d7544fc37316506ee598cb5310ef0365125a30783c11531" dependencies = [ "bevy_derive", "bevy_ecs", @@ -346,9 +347,9 @@ dependencies = [ [[package]] name = "bevy_asset" -version = "0.11.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6733d20a22bb10da928785fdbf6fad6cfb1c7da4a8c170ab3adbba5862c375d5" +checksum = "9714af523da4cdf58c42a317e5ed40349708ad954a18533991fd64c8ae0a6f68" dependencies = [ "anyhow", "async-channel", @@ -375,9 +376,9 @@ dependencies = [ [[package]] name = "bevy_audio" -version = "0.11.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8f505704c3a8396c2d9dde898e19aee114143584b11bdb7189fcafc231b6e7a" +checksum = "4de308bd63a2f7a0b77ffeb7cf00cc185ec01393c5db2091fe03964f97152749" dependencies = [ "anyhow", "bevy_app", @@ -395,9 +396,9 @@ dependencies = [ [[package]] name = "bevy_core" -version = "0.11.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1d47b435bdebeefedda95de98a419c4d3b4c160ed8ce3470ea358a16aad6038" +checksum = "3d5272321be5fcf5ce2fb16023bc825bb10dfcb71611117296537181ce950f48" dependencies = [ "bevy_app", "bevy_ecs", @@ -410,9 +411,9 @@ dependencies = [ [[package]] name = "bevy_core_pipeline" -version = "0.11.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a01c2652f5a6d24e0ab465e6feca8a034dfb33dfefbcdc19e436fec879a362a8" +checksum = "67382fa9c96ce4f4e5833ed7cedd9886844a8f3284b4a717bd4ac738dcdea0c3" dependencies = [ "bevy_app", "bevy_asset", @@ -431,9 +432,9 @@ dependencies = [ [[package]] name = "bevy_derive" -version = "0.11.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5cc78985f4d0ad1fd7b8ead06dcfaa192685775a7b1be158191c788c7d52298" +checksum = "a44e4e2784a81430199e4157e02903a987a32127c773985506f020e7d501b62e" dependencies = [ "bevy_macro_utils", "quote", @@ -442,9 +443,9 @@ dependencies = [ [[package]] name = "bevy_diagnostic" -version = "0.11.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee4e366724d233fdc7e282e1415f4cd570e97fbb8443e5a8ff3f8cc5ae253ffd" +checksum = "6babb230dc383c98fdfc9603e3a7a2a49e1e2879dbe8291059ef37dca897932e" dependencies = [ "bevy_app", "bevy_core", @@ -456,10 +457,19 @@ dependencies = [ ] [[package]] -name = "bevy_ecs" -version = "0.11.2" +name = "bevy_dylib" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb6fd0ec64cd32b8fcf16157173431ba0e675b29c4643a8d6c9a9eeef6f93c32" +checksum = "22ea11f830028e1c9d37f8bc88c5873f1c4c0346661209c2ba015f899c51863c" +dependencies = [ + "bevy_internal", +] + +[[package]] +name = "bevy_ecs" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "266144b36df7e834d5198049e037ecdf2a2310a76ce39ed937d1b0a6a2c4e8c6" dependencies = [ "async-channel", "bevy_ecs_macros", @@ -478,9 +488,9 @@ dependencies = [ [[package]] name = "bevy_ecs_macros" -version = "0.11.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e13b0fd864433db6ff825efd0eb86b2690e208151905b184cc9bfd2c3ac66c3b" +checksum = "7157a9c3be038d5008ee3f114feb6cf6b39c1d3d32ee21a7cacb8f81fccdfa80" dependencies = [ "bevy_macro_utils", "proc-macro2", @@ -490,9 +500,9 @@ dependencies = [ [[package]] name = "bevy_encase_derive" -version = "0.11.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da8ffb3d214ee4d8b7e851bc8409768a0f18c872c3a25065c248611ff832180e" +checksum = "d0ac0f55ad6bca1be7b0f35bbd5fc95ed3d31e4e9db158fee8e5327f59006001" dependencies = [ "bevy_macro_utils", "encase_derive_impl", @@ -500,9 +510,9 @@ dependencies = [ [[package]] name = "bevy_gilrs" -version = "0.11.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b84a2fbca3811261bcf02908132096595b81e5ec033169f922d6077f57baabb7" +checksum = "65f4d79c55829f8016014593a42453f61a564ffb06ef79460d25696ccdfac67b" dependencies = [ "bevy_app", "bevy_ecs", @@ -516,9 +526,9 @@ dependencies = [ [[package]] name = "bevy_gizmos" -version = "0.11.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64c08196fcb36b7175577443cbe2c1193d596a15eb0fa210bae378e6e1478876" +checksum = "e286a3e7276431963f4aa29165ea5429fa7dbbc6d5c5ba0c531e7dd44ecc88a2" dependencies = [ "bevy_app", "bevy_asset", @@ -536,9 +546,9 @@ dependencies = [ [[package]] name = "bevy_gltf" -version = "0.11.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "478c832d8b132198ca9485c636c97eaea7a1fe393dabadbcabc693ef4437e0db" +checksum = "f07494a733dca032e71a20f4b1f423de765da49cbff34406ae6cd813f9b50c41" dependencies = [ "anyhow", "base64 0.13.1", @@ -567,9 +577,9 @@ dependencies = [ [[package]] name = "bevy_hierarchy" -version = "0.11.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "402789ee53acf345243cf2c86a895d6cf8631e533780ed261c6ecf891eb050b8" +checksum = "103f8f58416ac6799b8c7f0b418f1fac9eba44fa924df3b0e16b09256b897e3d" dependencies = [ "bevy_app", "bevy_core", @@ -582,9 +592,9 @@ dependencies = [ [[package]] name = "bevy_input" -version = "0.11.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9dfd9c768cf153f3fc807661996b2db44b824299860ba198fb3b92dd731bdd8" +checksum = "ffbd935401101ac8003f3c3aea70788c65ad03f7a32716a10608bedda7a648bc" dependencies = [ "bevy_app", "bevy_ecs", @@ -596,9 +606,9 @@ dependencies = [ [[package]] name = "bevy_internal" -version = "0.11.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1006f2c501bceb1aef5cc18ed07eb822f295763227b83ba6887e6743698af9f8" +checksum = "e0e35a9b2bd29aa784b3cc416bcbf2a298f69f00ca51fd042ea39d9af7fad37e" dependencies = [ "bevy_a11y", "bevy_animation", @@ -635,9 +645,9 @@ dependencies = [ [[package]] name = "bevy_log" -version = "0.11.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0b1e5ca5b217dd384a3bf9186df0d0da757035f9f06d8eec0ebe62cffc05c34" +checksum = "07dcc615ff4f617b06c3f9522fca3c55d56f9644db293318f8ab68fcdea5d4fe" dependencies = [ "android_log-sys", "bevy_app", @@ -651,9 +661,9 @@ dependencies = [ [[package]] name = "bevy_macro_utils" -version = "0.11.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1cd460205fe05634d58b32d9bb752b1b4eaf32b2d29cbd4161ba35eb44a2f8c" +checksum = "23ddc18d489b4e57832d4958cde7cd2f349f0ad91e5892ac9e2f2ee16546b981" dependencies = [ "quote", "rustc-hash", @@ -663,9 +673,9 @@ dependencies = [ [[package]] name = "bevy_math" -version = "0.11.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "267f2ec44aa948051768b1320c2dbff0871799e0a3b746f5fe5b6ee7258fbaf5" +checksum = "78286a81fead796dc4b45ab14f4f02fe29a94423d3587bcfef872b2a8e0a474b" dependencies = [ "glam", "serde", @@ -673,18 +683,18 @@ dependencies = [ [[package]] name = "bevy_mikktspace" -version = "0.11.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d98eaa7f40b97bb9b2d681ecf9fd439830a7eb88ad2846680d4f4acd285cf84" +checksum = "6cfc2a21ea47970a9b1f0f4735af3256a8f204815bd756110051d10f9d909497" dependencies = [ "glam", ] [[package]] name = "bevy_pbr" -version = "0.11.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9386944248ac8fcaaabec2302b0e7cd8196ef5d7b7a2e63b10ace3eeb813d3de" +checksum = "63ca796a619e61cd43a0a3b11fde54644f7f0732a1fba1eef5d406248c6eba85" dependencies = [ "bevy_app", "bevy_asset", @@ -705,15 +715,15 @@ dependencies = [ [[package]] name = "bevy_ptr" -version = "0.11.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15702dff420fac72c2ab92428a8600e079ae89c5845401c4e39b843665a3d2d0" +checksum = "72c7586401a46f7d8e436028225c1df5288f2e0082d066b247a82466fea155c6" [[package]] name = "bevy_reflect" -version = "0.11.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ac66cccbf1457c5cfc004a0e83569bd4ddc5d6310701f4af6aa81001fe2964a" +checksum = "0778197a1eb3e095a71417c74b7152ede02975cdc95b5ea4ddc5251ed00a2eb5" dependencies = [ "bevy_math", "bevy_ptr", @@ -732,9 +742,9 @@ dependencies = [ [[package]] name = "bevy_reflect_derive" -version = "0.11.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5a2a1fa784e9a22560b9de350246a159cd59239eb61c7b66824031b3b28abb0" +checksum = "342a4b2d09db22c48607d23ad59a056aff1ee004549050a51d490d375ba29528" dependencies = [ "bevy_macro_utils", "bit-set", @@ -746,9 +756,9 @@ dependencies = [ [[package]] name = "bevy_render" -version = "0.11.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2e125de06ffaed8100623843b447fb524dc16f2a2120adce81143d7307278be" +checksum = "39df4824b760928c27afc7b00fb649c7a63c9d76661ab014ff5c86537ee906cb" dependencies = [ "anyhow", "async-channel", @@ -796,9 +806,9 @@ dependencies = [ [[package]] name = "bevy_render_macros" -version = "0.11.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e283eb4156285d0d4b85ce9b959d080b652165848f0b3f1a8770af6cfad41c34" +checksum = "0bd08c740aac73363e32fb45af869b10cec65bcb76fe3e6cd0f8f7eebf4c36c9" dependencies = [ "bevy_macro_utils", "proc-macro2", @@ -808,9 +818,9 @@ dependencies = [ [[package]] name = "bevy_scene" -version = "0.11.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a77172c572239e741283e585433e986dd7f1bfdd7f7489ff10933f59e93cbb04" +checksum = "bd47e1263506153bef3a8be97fe2d856f206d315668c4f97510ca6cc181d9681" dependencies = [ "anyhow", "bevy_app", @@ -830,9 +840,9 @@ dependencies = [ [[package]] name = "bevy_sprite" -version = "0.11.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7811ade4df81ffa6bae0e293c42d784ad88ce84d2b10fa05801e3c368714581" +checksum = "68a8ca824fad75c6ef74cfbbba0a4ce3ccc435fa23d6bf3f003f260548813397" dependencies = [ "bevy_app", "bevy_asset", @@ -855,9 +865,9 @@ dependencies = [ [[package]] name = "bevy_tasks" -version = "0.11.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9200e7b42d49c787d9a08675c425d8bd6393ba3beed2eac64be6027a44a01870" +checksum = "c73bbb847c83990d3927005090df52f8ac49332e1643d2ad9aac3cd2974e66bf" dependencies = [ "async-channel", "async-executor", @@ -869,9 +879,9 @@ dependencies = [ [[package]] name = "bevy_text" -version = "0.11.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "822e2cdb1c46338b85b7648d866f0b631cab23bd8f24395bb8ee7842dde024f0" +checksum = "692288ab7b0a9f8b38058964c52789fc6bcb63703b23de51cce90ec41bfca355" dependencies = [ "ab_glyph", "anyhow", @@ -892,9 +902,9 @@ dependencies = [ [[package]] name = "bevy_time" -version = "0.11.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ba50bf25c4dc40296b744f77de10d39c8981b710d8dce609da9de5e54ef164b" +checksum = "3d58d6dbae9c8225d8c0e0f04d2c5dbb71d22adc01ecd5ab3cebc364139e4a6d" dependencies = [ "bevy_app", "bevy_ecs", @@ -906,9 +916,9 @@ dependencies = [ [[package]] name = "bevy_transform" -version = "0.11.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86043ec5cc3cf406d33c0e4d6920171601e186b1288e9b4f5ae54682a0564032" +checksum = "3b9b0ac0149a57cd846cb357a35fc99286f9848e53d4481954608ac9552ed2d4" dependencies = [ "bevy_app", "bevy_ecs", @@ -919,9 +929,9 @@ dependencies = [ [[package]] name = "bevy_ui" -version = "0.11.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "105c82a79df1dfcdb75941fa1f58dbdbd8f702a740bc39e7bf719c3d51d55286" +checksum = "59b6d295a755e5b79e869a09e087029d72974562a521ec7ccfba7141fa948a32" dependencies = [ "bevy_a11y", "bevy_app", @@ -949,9 +959,9 @@ dependencies = [ [[package]] name = "bevy_utils" -version = "0.11.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "829eb8d0d06a0baeabc2e8bad74136ed3329b055aa1e11c5d9df09ebb9be3d85" +checksum = "08d9484e32434ea84dc548cff246ce0c6f756c1336f5ea03f24ac120a48595c7" dependencies = [ "ahash 0.8.3", "bevy_utils_proc_macros", @@ -966,9 +976,9 @@ dependencies = [ [[package]] name = "bevy_utils_proc_macros" -version = "0.11.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d104f29e231123c703e8b394e2341d2425c33c5a2e9ab8cc8d0a554bdb62a41" +checksum = "5391b242c36f556db01d5891444730c83aa9dd648b6a8fd2b755d22cb3bddb57" dependencies = [ "proc-macro2", "quote", @@ -977,9 +987,9 @@ dependencies = [ [[package]] name = "bevy_window" -version = "0.11.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a66f9963152093220fc5ffd2244cadcc7f79cf2c23dd02076f4d0cbb7f5162f" +checksum = "bd584c0da7c4ada6557b09f57f30fb7cff21ccedc641473fc391574b4c9b7944" dependencies = [ "bevy_app", "bevy_ecs", @@ -992,9 +1002,9 @@ dependencies = [ [[package]] name = "bevy_winit" -version = "0.11.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "003e20cff652a364f1f98b0d5ba24f53140dc77643241afe4a9b848bdde66184" +checksum = "bfdc044abdb95790c20053e6326760f0a2985f0dcd78613d397bf35f16039d53" dependencies = [ "accesskit_winit", "approx", diff --git a/Cargo.toml b/Cargo.toml index e9f3ac8..81d7a6f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,5 +6,5 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -bevy = "0.11.2" +bevy = { version = "0.11.3", features = ["dynamic_linking"] } rand = "0.8.5" diff --git a/src/characters.rs b/src/characters.rs deleted file mode 100644 index 6a13849..0000000 --- a/src/characters.rs +++ /dev/null @@ -1,18 +0,0 @@ -use bevy::prelude::Commands; - -use crate::components::*; -use crate::util::*; - -pub fn spawn_player_character(mut commands: Commands) { - let (hp, _) = roll("1d6 + 3"); - commands.spawn(Creature { - health: Health { - hp, - max: hp, - }, - armor: Armor { - ac: 10, - }, - spatial: Default::default(), - }).insert(PlayerCharacter); -} diff --git a/src/main.rs b/src/main.rs index d9e9842..32d157d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,47 +3,54 @@ use bevy::prelude::*; pub mod util; pub mod components; pub mod systems; -pub mod characters; use components::*; -use characters::*; - -fn setup( - query: Query<&Transform, With>, - mut commands: Commands, - mut meshes: ResMut>, - mut materials: ResMut>, -) { - for transform in query.iter() { - commands.spawn(PbrBundle { - mesh: meshes.add(Mesh::from(shape::Capsule{ - radius: 1.0, - rings: 32, - depth: 2.0, - ..Default::default() - })), - material: materials.add(StandardMaterial { - unlit: true, - ..Default::default() - }), - transform: Transform::clone(transform), - ..Default::default() - }); - commands.spawn(DirectionalLightBundle::default()); - commands.spawn(Camera3dBundle{ - transform: Transform::from_xyz(0.0, 10.0, 0.0).looking_at(Vec3::default(), Vec3::Y), - projection: OrthographicProjection::default().into(), - ..Default::default() - }); - } -} +use util::roll; fn main() { App::new() .add_plugins(DefaultPlugins) - // Add systems, whatnot - .add_systems(Startup, spawn_player_character) - .add_systems(Startup, spawn_player_character) .add_systems(Startup, setup) .run(); } + + +fn setup( + mut commands: Commands, + mut meshes: ResMut>, + mut materials: ResMut>, +) { + for i in 0..2 { + let (hp, _) = roll("1d6 + 3"); + commands.spawn(Creature { + health: Health { + hp, + max: hp, + }, + armor: Armor { + ac: 10, + }, + spatial: SpatialBundle { + transform: Transform::from_xyz(i as f32 * 2.0, 0.0, 0.0), + ..default() + }, + }) + .insert(PlayerCharacter) + .with_children(|parent| { + parent.spawn(PbrBundle { + mesh: meshes.add(shape::Capsule::default().into()), + material: materials.add(Color::WHITE.into()), + ..default() + }); + }); + } + + commands.spawn(DirectionalLightBundle { + transform: Transform::default().looking_at(Vec3::new(3.0, -50.0, 1.0), Vec3::Y), + ..default() + }); + commands.spawn(Camera3dBundle{ + transform: Transform::from_xyz(1.0, 15.0, 2.0).looking_at(Vec3::ZERO, Vec3::Y), + ..default() + }); +}