Merge branch 'master' of https://git.txmn.tk/tuxmain/bevyjam into nixon-main

This commit is contained in:
Nixon 2022-08-23 23:14:51 +08:00
commit 05ef42d8c3
10 changed files with 571 additions and 223 deletions

551
Cargo.lock generated
View file

@ -4,9 +4,9 @@ version = 3
[[package]] [[package]]
name = "ab_glyph" name = "ab_glyph"
version = "0.2.15" version = "0.2.16"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "24606928a235e73cdef55a0c909719cadd72fce573e5713d58cb2952d8f5794c" checksum = "846ffacb9d0c8b879ef9e565b59e18fb76d6a61013e5bd24ecc659864e6b1a1f"
dependencies = [ dependencies = [
"ab_glyph_rasterizer", "ab_glyph_rasterizer",
"owned_ttf_parser", "owned_ttf_parser",
@ -110,9 +110,9 @@ dependencies = [
[[package]] [[package]]
name = "anyhow" name = "anyhow"
version = "1.0.61" version = "1.0.62"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "508b352bb5c066aac251f6daf6b36eccd03e8a88e8081cd44959ea277a3af9a8" checksum = "1485d4d2cc45e7b201ee3767015c96faa5904387c9d87c6efdd0fb511f12d305"
[[package]] [[package]]
name = "approx" name = "approx"
@ -188,15 +188,6 @@ version = "4.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a40729d2133846d9ed0ea60a8b9541bccddab49cd30f0715a1da672fe9a2524" checksum = "7a40729d2133846d9ed0ea60a8b9541bccddab49cd30f0715a1da672fe9a2524"
[[package]]
name = "atomic"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b88d82667eca772c4aa12f0f1348b3ae643424c8876448f3f7bd5787032e234c"
dependencies = [
"autocfg",
]
[[package]] [[package]]
name = "atomic_refcell" name = "atomic_refcell"
version = "0.1.8" version = "0.1.8"
@ -436,17 +427,6 @@ dependencies = [
"encase_derive_impl", "encase_derive_impl",
] ]
[[package]]
name = "bevy_fundsp"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a6e13dc15f060f68e5742139d63d31e472df1b271f0a5f854499e3c9c067e20"
dependencies = [
"atomic",
"bevy",
"fundsp",
]
[[package]] [[package]]
name = "bevy_gilrs" name = "bevy_gilrs"
version = "0.8.0" version = "0.8.0"
@ -491,9 +471,9 @@ dependencies = [
[[package]] [[package]]
name = "bevy_hanabi" name = "bevy_hanabi"
version = "0.3.0" version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fe35e3c7a5c8b9c26093b62551929581ada6da514e8c8e1ad01c939565916d1a" checksum = "371c5bd9edcf42721cd4e769354c221f3c4090e7a1dba0eb0bd6ca29e7828142"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bevy", "bevy",
@ -615,9 +595,9 @@ dependencies = [
[[package]] [[package]]
name = "bevy_pbr" name = "bevy_pbr"
version = "0.8.0" version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed9a81bbd02f5e0a57899a41aec37d9cb14965e1e4d510547f3f680323d05c0f" checksum = "176073021a4caeb8b448f24ce790fb57fde74b114f345064a8b102d2f7bed905"
dependencies = [ dependencies = [
"bevy_app", "bevy_app",
"bevy_asset", "bevy_asset",
@ -642,9 +622,9 @@ checksum = "d92d5679e89602a18682a37846573dcd1979410179e14204280460ba9fb8713a"
[[package]] [[package]]
name = "bevy_rapier2d" name = "bevy_rapier2d"
version = "0.16.0" version = "0.16.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e941caacdd45fcfc0fe0be661d5aaca0392dabfa6595a96ef7f18716587195f" checksum = "e94ea9324a836efedf4b3673a3c5e2011490fa440478d244fe6b1783557ab4fd"
dependencies = [ dependencies = [
"bevy", "bevy",
"bitflags", "bitflags",
@ -764,9 +744,9 @@ dependencies = [
[[package]] [[package]]
name = "bevy_sprite" name = "bevy_sprite"
version = "0.8.0" version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1f83dfe8897d6c0d9d5ce3818d49a13e58ae2b9b9ecf4f4bb85aa31bb0678f68" checksum = "69c419f3db09d7ac1f4d45e0874d349d5d6f47f48bc10d55cd0da36413e2331e"
dependencies = [ dependencies = [
"bevy_app", "bevy_app",
"bevy_asset", "bevy_asset",
@ -854,9 +834,9 @@ dependencies = [
[[package]] [[package]]
name = "bevy_ui" name = "bevy_ui"
version = "0.8.0" version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac181a7b637da61fad72981ff9d2e5b899283ca7d54b2b7ea49c431121331c53" checksum = "062ce086de1a4a470e5df48cb5c16a1dc97ab610e635cafabdef26c4a1ef5756"
dependencies = [ dependencies = [
"bevy_app", "bevy_app",
"bevy_asset", "bevy_asset",
@ -896,16 +876,16 @@ dependencies = [
[[package]] [[package]]
name = "bevy_window" name = "bevy_window"
version = "0.8.0" version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a3bdc3a220a9bb2fad9bd30d5f44c6645725398fe1bc588fc87abf09f092696e" checksum = "707dbbebfac72b1e63e874e7a11a345feab8c440355c0bd71e6dff26709fba9a"
dependencies = [ dependencies = [
"bevy_app", "bevy_app",
"bevy_ecs", "bevy_ecs",
"bevy_input", "bevy_input",
"bevy_math", "bevy_math",
"bevy_utils", "bevy_utils",
"raw-window-handle", "raw-window-handle 0.4.3",
"web-sys", "web-sys",
] ]
@ -923,7 +903,7 @@ dependencies = [
"bevy_utils", "bevy_utils",
"bevy_window", "bevy_window",
"crossbeam-channel", "crossbeam-channel",
"raw-window-handle", "raw-window-handle 0.4.3",
"wasm-bindgen", "wasm-bindgen",
"web-sys", "web-sys",
"winit", "winit",
@ -935,9 +915,12 @@ version = "0.1.0"
dependencies = [ dependencies = [
"bevy", "bevy",
"bevy-inspector-egui", "bevy-inspector-egui",
"bevy_fundsp",
"bevy_hanabi", "bevy_hanabi",
"bevy_rapier2d", "bevy_rapier2d",
"cpal 0.14.0",
"crossbeam-channel",
"hexodsp",
"ticktock",
] ]
[[package]] [[package]]
@ -988,9 +971,9 @@ checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a"
[[package]] [[package]]
name = "bumpalo" name = "bumpalo"
version = "3.10.0" version = "3.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "37ccbd214614c6783386c1af30caf03192f17891059cecc394b4fb119e363de3" checksum = "c1ad822118d20d2c234f427000d5acc36eabe1e29a348c89b63dd60b13f28e5d"
[[package]] [[package]]
name = "bytemuck" name = "bytemuck"
@ -1309,6 +1292,146 @@ dependencies = [
"winapi", "winapi",
] ]
[[package]]
name = "cpal"
version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7d466b47cf0ea4100186a7c12d7d0166813dda7cf648553554c9c39c6324841b"
dependencies = [
"alsa",
"core-foundation-sys 0.8.3",
"coreaudio-rs",
"jni",
"js-sys",
"libc",
"mach",
"ndk 0.7.0",
"ndk-context",
"nix 0.23.1",
"oboe",
"once_cell",
"parking_lot 0.12.1",
"stdweb",
"thiserror",
"web-sys",
"windows",
]
[[package]]
name = "cranelift"
version = "0.86.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bd96bba738454eb373087df6d6891b18009361123fef90930def4978e3837448"
dependencies = [
"cranelift-codegen",
"cranelift-frontend",
]
[[package]]
name = "cranelift-bforest"
version = "0.86.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "529ffacce2249ac60edba2941672dfedf3d96558b415d0d8083cd007456e0f55"
dependencies = [
"cranelift-entity",
]
[[package]]
name = "cranelift-codegen"
version = "0.86.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "427d105f617efc8cb55f8d036a7fded2e227892d8780b4985e5551f8d27c4a92"
dependencies = [
"cranelift-bforest",
"cranelift-codegen-meta",
"cranelift-codegen-shared",
"cranelift-entity",
"cranelift-isle",
"gimli",
"log",
"regalloc2",
"smallvec",
"target-lexicon",
]
[[package]]
name = "cranelift-codegen-meta"
version = "0.86.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "551674bed85b838d45358e3eab4f0ffaa6790c70dc08184204b9a54b41cdb7d1"
dependencies = [
"cranelift-codegen-shared",
]
[[package]]
name = "cranelift-codegen-shared"
version = "0.86.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2b3a63ae57498c3eb495360944a33571754241e15e47e3bcae6082f40fec5866"
[[package]]
name = "cranelift-entity"
version = "0.86.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "11aa8aa624c72cc1c94ea3d0739fa61248260b5b14d3646f51593a88d67f3e6e"
[[package]]
name = "cranelift-frontend"
version = "0.86.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "544ee8f4d1c9559c9aa6d46e7aaeac4a13856d620561094f35527356c7d21bd0"
dependencies = [
"cranelift-codegen",
"log",
"smallvec",
"target-lexicon",
]
[[package]]
name = "cranelift-isle"
version = "0.86.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed16b14363d929b8c37e3c557d0a7396791b383ecc302141643c054343170aad"
[[package]]
name = "cranelift-jit"
version = "0.86.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0308e7418208639fb96c1a3dc04955fa41c4bc92dfce9106635185f71d5caf46"
dependencies = [
"anyhow",
"cranelift-codegen",
"cranelift-entity",
"cranelift-module",
"cranelift-native",
"libc",
"log",
"region",
"target-lexicon",
"windows-sys",
]
[[package]]
name = "cranelift-module"
version = "0.86.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "76979aac10dbcf0c222cd5902565bc93597ac30bbe9d879a2aa5f2402d1561f2"
dependencies = [
"anyhow",
"cranelift-codegen",
]
[[package]]
name = "cranelift-native"
version = "0.86.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "51617cf8744634f2ed3c989c3c40cd6444f63377c6d994adab0d85807f3eb682"
dependencies = [
"cranelift-codegen",
"libc",
"target-lexicon",
]
[[package]] [[package]]
name = "crc32fast" name = "crc32fast"
version = "1.3.2" version = "1.3.2"
@ -1470,16 +1593,6 @@ version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650" checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650"
[[package]]
name = "duplicate"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a0a4be4cd710e92098de6ad258e6e7c24af11c29c5142f3c6f2a545652480ff8"
dependencies = [
"heck",
"proc-macro-error",
]
[[package]] [[package]]
name = "egui" name = "egui"
version = "0.18.1" version = "0.18.1"
@ -1493,9 +1606,9 @@ dependencies = [
[[package]] [[package]]
name = "either" name = "either"
version = "1.7.0" version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f107b87b6afc2a64fd13cac55fe06d6c8859f12d4b14cbcdd2c67d0976781be" checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797"
[[package]] [[package]]
name = "emath" name = "emath"
@ -1664,33 +1777,17 @@ dependencies = [
"libc", "libc",
] ]
[[package]]
name = "fundsp"
version = "0.6.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c82c389e6a1394463627e5df8777a9350968e8828e8074d629bc65a0d54165e"
dependencies = [
"duplicate",
"generic-array",
"lazy_static",
"num-complex",
"numeric-array",
"rsor",
"rustfft",
"tinyvec",
]
[[package]] [[package]]
name = "futures-core" name = "futures-core"
version = "0.3.21" version = "0.3.23"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c09fd04b7e4073ac7156a9539b57a484a8ea920f79c7c675d05d289ab6110d3" checksum = "d2acedae88d38235936c3922476b10fced7b2b68136f5e3c03c2d5be348a1115"
[[package]] [[package]]
name = "futures-io" name = "futures-io"
version = "0.3.21" version = "0.3.23"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc4045962a5a5e935ee2fdedaa4e08284547402885ab326734432bed5d12966b" checksum = "93a66fc6d035a26a3ae255a6d2bca35eda63ae4c5512bef54449113f7a1228e5"
[[package]] [[package]]
name = "futures-lite" name = "futures-lite"
@ -1716,16 +1813,6 @@ dependencies = [
"byteorder", "byteorder",
] ]
[[package]]
name = "generic-array"
version = "0.14.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9"
dependencies = [
"typenum",
"version_check",
]
[[package]] [[package]]
name = "gethostname" name = "gethostname"
version = "0.2.3" version = "0.2.3"
@ -1783,6 +1870,15 @@ dependencies = [
"winapi", "winapi",
] ]
[[package]]
name = "gimli"
version = "0.26.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "22030e2c5a68ec659fde1e949a745124b48e6fa8b045b7ed5bd1fe4ccc5c4e5d"
dependencies = [
"indexmap",
]
[[package]] [[package]]
name = "glam" name = "glam"
version = "0.21.3" version = "0.21.3"
@ -1936,12 +2032,6 @@ dependencies = [
"serde", "serde",
] ]
[[package]]
name = "heck"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9"
[[package]] [[package]]
name = "hermit-abi" name = "hermit-abi"
version = "0.1.19" version = "0.1.19"
@ -1973,6 +2063,21 @@ version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dfa686283ad6dd069f105e5ab091b04c62850d3e4cf5d67debad1933f55023df" checksum = "dfa686283ad6dd069f105e5ab091b04c62850d3e4cf5d67debad1933f55023df"
[[package]]
name = "hexodsp"
version = "0.2.0"
source = "git+https://github.com/WeirdConstructor/HexoDSP#be4e9232cc05b96588b156d1c9f995f7eda41ec0"
dependencies = [
"hound",
"lazy_static",
"ringbuf",
"serde",
"serde_json",
"synfx-dsp",
"synfx-dsp-jit",
"triple_buffer",
]
[[package]] [[package]]
name = "hound" name = "hound"
version = "3.4.0" version = "3.4.0"
@ -2197,9 +2302,9 @@ dependencies = [
[[package]] [[package]]
name = "libc" name = "libc"
version = "0.2.131" version = "0.2.132"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "04c3b4822ccebfa39c02fc03d1534441b22ead323fa0f48bb7ddd8e6ba076a40" checksum = "8371e4e5341c3a96db127eb2465ac681ced4c433e01dd0e938adbef26ba93ba5"
[[package]] [[package]]
name = "libloading" name = "libloading"
@ -2439,6 +2544,20 @@ dependencies = [
"thiserror", "thiserror",
] ]
[[package]]
name = "ndk"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "451422b7e4718271c8b5b3aadf5adedba43dc76312454b387e98fae0fc951aa0"
dependencies = [
"bitflags",
"jni-sys",
"ndk-sys 0.4.0",
"num_enum",
"raw-window-handle 0.5.0",
"thiserror",
]
[[package]] [[package]]
name = "ndk-context" name = "ndk-context"
version = "0.1.1" version = "0.1.1"
@ -2504,6 +2623,15 @@ dependencies = [
"jni-sys", "jni-sys",
] ]
[[package]]
name = "ndk-sys"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "21d83ec9c63ec5bf950200a8e508bdad6659972187b625469f58ef8c08e29046"
dependencies = [
"jni-sys",
]
[[package]] [[package]]
name = "nix" name = "nix"
version = "0.22.3" version = "0.22.3"
@ -2679,16 +2807,6 @@ dependencies = [
"syn", "syn",
] ]
[[package]]
name = "numeric-array"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2c59a9b227913a685ed84aa0de5ded58274e8bcfa55760faae07bc82aee64ccf"
dependencies = [
"generic-array",
"num-traits",
]
[[package]] [[package]]
name = "objc" name = "objc"
version = "0.2.7" version = "0.2.7"
@ -2762,9 +2880,9 @@ dependencies = [
[[package]] [[package]]
name = "once_cell" name = "once_cell"
version = "1.13.0" version = "1.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "18a6dbe30758c9f83eb00cbea4ac95966305f5a7772f3f42ebfc7fc7eddbd8e1" checksum = "074864da206b4973b84eb91683020dbefd6a8c3f0f38e054d93954e891935e4e"
[[package]] [[package]]
name = "optional" name = "optional"
@ -2941,15 +3059,6 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a8815d101cfb4cb491154896bdab292a395a7ac9ab185a9941a2f5be0135900d" checksum = "a8815d101cfb4cb491154896bdab292a395a7ac9ab185a9941a2f5be0135900d"
[[package]]
name = "primal-check"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b264861209b0641a9b7571695029f516698bd3f2bf46eb61fca408675630b8c"
dependencies = [
"num-integer",
]
[[package]] [[package]]
name = "proc-macro-crate" name = "proc-macro-crate"
version = "1.2.1" version = "1.2.1"
@ -2961,30 +3070,6 @@ dependencies = [
"toml", "toml",
] ]
[[package]]
name = "proc-macro-error"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c"
dependencies = [
"proc-macro-error-attr",
"proc-macro2",
"quote",
"syn",
"version_check",
]
[[package]]
name = "proc-macro-error-attr"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869"
dependencies = [
"proc-macro2",
"quote",
"version_check",
]
[[package]] [[package]]
name = "proc-macro2" name = "proc-macro2"
version = "1.0.43" version = "1.0.43"
@ -3089,6 +3174,15 @@ dependencies = [
"cty", "cty",
] ]
[[package]]
name = "raw-window-handle"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed7e3d950b66e19e0c372f3fa3fbbcf85b1746b571f74e0c2af6042a5c93420a"
dependencies = [
"cty",
]
[[package]] [[package]]
name = "rawpointer" name = "rawpointer"
version = "0.2.1" version = "0.2.1"
@ -3110,6 +3204,18 @@ dependencies = [
"bitflags", "bitflags",
] ]
[[package]]
name = "regalloc2"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d43a209257d978ef079f3d446331d0f1794f5e0fc19b306a199983857833a779"
dependencies = [
"fxhash",
"log",
"slice-group-by",
"smallvec",
]
[[package]] [[package]]
name = "regex" name = "regex"
version = "1.6.0" version = "1.6.0"
@ -3136,12 +3242,33 @@ version = "0.6.27"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244" checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244"
[[package]]
name = "region"
version = "2.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "877e54ea2adcd70d80e9179344c97f93ef0dffd6b03e1f4529e6e83ab2fa9ae0"
dependencies = [
"bitflags",
"libc",
"mach",
"winapi",
]
[[package]] [[package]]
name = "renderdoc-sys" name = "renderdoc-sys"
version = "0.7.1" version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f1382d1f0a252c4bf97dc20d979a2fdd05b024acd7c2ed0f7595d7817666a157" checksum = "f1382d1f0a252c4bf97dc20d979a2fdd05b024acd7c2ed0f7595d7817666a157"
[[package]]
name = "ringbuf"
version = "0.2.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f65af18d50f789e74aaf23bbb3f65dcd22a3cb6e029b5bced149f6bd57c5c2a2"
dependencies = [
"cache-padded",
]
[[package]] [[package]]
name = "robust" name = "robust"
version = "0.2.3" version = "0.2.3"
@ -3154,8 +3281,7 @@ version = "0.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec0939e9f626e6c6f1989adb6226a039c855ca483053f0ee7c98b90e41cf731e" checksum = "ec0939e9f626e6c6f1989adb6226a039c855ca483053f0ee7c98b90e41cf731e"
dependencies = [ dependencies = [
"cpal", "cpal 0.13.5",
"hound",
"lewton", "lewton",
] ]
@ -3170,32 +3296,12 @@ dependencies = [
"serde", "serde",
] ]
[[package]]
name = "rsor"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4b57e3964dc31a38416366d2e8f7675755402a10832d5cf4e4112d66ac77cdda"
[[package]] [[package]]
name = "rustc-hash" name = "rustc-hash"
version = "1.1.0" version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
[[package]]
name = "rustfft"
version = "6.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1d089e5c57521629a59f5f39bca7434849ff89bd6873b521afe389c1c602543"
dependencies = [
"num-complex",
"num-integer",
"num-traits",
"primal-check",
"strength_reduce",
"transpose",
]
[[package]] [[package]]
name = "rusty-xinput" name = "rusty-xinput"
version = "1.2.0" version = "1.2.0"
@ -3245,18 +3351,18 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
[[package]] [[package]]
name = "serde" name = "serde"
version = "1.0.143" version = "1.0.144"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "53e8e5d5b70924f74ff5c6d64d9a5acd91422117c60f48c4e07855238a254553" checksum = "0f747710de3dcd43b88c9168773254e809d8ddbdf9653b84e2554ab219f17860"
dependencies = [ dependencies = [
"serde_derive", "serde_derive",
] ]
[[package]] [[package]]
name = "serde_derive" name = "serde_derive"
version = "1.0.143" version = "1.0.144"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d3d8e8de557aee63c26b85b947f5e59b690d0454c753f3adeb5cd7835ab88391" checksum = "94ed3a816fb1d101812f83e789f888322c34e291f894f19590dc310963e87a00"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -3265,9 +3371,9 @@ dependencies = [
[[package]] [[package]]
name = "serde_json" name = "serde_json"
version = "1.0.83" version = "1.0.85"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "38dd04e3c8279e75b31ef29dbdceebfe5ad89f4d0937213c53f7d49d01b3d5a7" checksum = "e55a28e3aaef9d5ce0506d0a14dbba8054ddc7e499ef522dd8b26859ec9d4a44"
dependencies = [ dependencies = [
"itoa", "itoa",
"ryu", "ryu",
@ -3311,6 +3417,12 @@ dependencies = [
"autocfg", "autocfg",
] ]
[[package]]
name = "slice-group-by"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "03b634d87b960ab1a38c4fe143b508576f075e7c978bfad18217645ebfdfa2ec"
[[package]] [[package]]
name = "slotmap" name = "slotmap"
version = "1.0.6" version = "1.0.6"
@ -3363,12 +3475,6 @@ version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9e08d8363704e6c71fc928674353e6b7c23dcea9d82d7012c8faf2a3a025f8d0" checksum = "9e08d8363704e6c71fc928674353e6b7c23dcea9d82d7012c8faf2a3a025f8d0"
[[package]]
name = "strength_reduce"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a3ff2f71c82567c565ba4b3009a9350a96a7269eaa4001ebedae926230bc2254"
[[package]] [[package]]
name = "strsim" name = "strsim"
version = "0.10.0" version = "0.10.0"
@ -3392,6 +3498,29 @@ dependencies = [
"unicode-ident", "unicode-ident",
] ]
[[package]]
name = "synfx-dsp"
version = "0.5.3"
source = "git+https://github.com/WeirdConstructor/synfx-dsp#3334a91ee48c009707c0147434a3fc14a929c079"
dependencies = [
"num-traits",
]
[[package]]
name = "synfx-dsp-jit"
version = "0.5.3"
source = "git+https://github.com/WeirdConstructor/synfx-dsp-jit#f199ec697292ed59e92976d7404d6988e0a8d6b0"
dependencies = [
"anyhow",
"cranelift",
"cranelift-codegen",
"cranelift-jit",
"cranelift-module",
"cranelift-native",
"ringbuf",
"synfx-dsp",
]
[[package]] [[package]]
name = "taffy" name = "taffy"
version = "0.1.0" version = "0.1.0"
@ -3405,6 +3534,12 @@ dependencies = [
"typenum", "typenum",
] ]
[[package]]
name = "target-lexicon"
version = "0.12.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c02424087780c9b71cc96799eaeddff35af2bc513278cda5c99fc1f5d026d3c1"
[[package]] [[package]]
name = "termcolor" name = "termcolor"
version = "1.1.3" version = "1.1.3"
@ -3443,6 +3578,12 @@ dependencies = [
"once_cell", "once_cell",
] ]
[[package]]
name = "ticktock"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d226b8341a5d130e3446024468efab6d150ba656e086b793ac37a3d17669e626"
[[package]] [[package]]
name = "tiff" name = "tiff"
version = "0.6.1" version = "0.6.1"
@ -3552,13 +3693,12 @@ dependencies = [
] ]
[[package]] [[package]]
name = "transpose" name = "triple_buffer"
version = "0.2.1" version = "5.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "95f9c900aa98b6ea43aee227fd680550cdec726526aab8ac801549eadb25e39f" checksum = "803966e5a8397a70d3d8111afa1597ba8381346d7de4720e9f539471d371a1a3"
dependencies = [ dependencies = [
"num-integer", "cache-padded",
"strength_reduce",
] ]
[[package]] [[package]]
@ -3776,7 +3916,7 @@ dependencies = [
"log", "log",
"naga", "naga",
"parking_lot 0.12.1", "parking_lot 0.12.1",
"raw-window-handle", "raw-window-handle 0.4.3",
"smallvec", "smallvec",
"wasm-bindgen", "wasm-bindgen",
"wasm-bindgen-futures", "wasm-bindgen-futures",
@ -3803,7 +3943,7 @@ dependencies = [
"naga", "naga",
"parking_lot 0.12.1", "parking_lot 0.12.1",
"profiling", "profiling",
"raw-window-handle", "raw-window-handle 0.4.3",
"smallvec", "smallvec",
"thiserror", "thiserror",
"web-sys", "web-sys",
@ -3841,7 +3981,7 @@ dependencies = [
"parking_lot 0.12.1", "parking_lot 0.12.1",
"profiling", "profiling",
"range-alloc", "range-alloc",
"raw-window-handle", "raw-window-handle 0.4.3",
"renderdoc-sys", "renderdoc-sys",
"thiserror", "thiserror",
"wasm-bindgen", "wasm-bindgen",
@ -3915,17 +4055,30 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
name = "windows"
version = "0.37.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57b543186b344cc61c85b5aab0d2e3adf4e0f99bc076eff9aa5927bcc0b8a647"
dependencies = [
"windows_aarch64_msvc 0.37.0",
"windows_i686_gnu 0.37.0",
"windows_i686_msvc 0.37.0",
"windows_x86_64_gnu 0.37.0",
"windows_x86_64_msvc 0.37.0",
]
[[package]] [[package]]
name = "windows-sys" name = "windows-sys"
version = "0.36.1" version = "0.36.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ea04155a16a59f9eab786fe12a4a450e75cdb175f9e0d80da1e17db09f55b8d2" checksum = "ea04155a16a59f9eab786fe12a4a450e75cdb175f9e0d80da1e17db09f55b8d2"
dependencies = [ dependencies = [
"windows_aarch64_msvc", "windows_aarch64_msvc 0.36.1",
"windows_i686_gnu", "windows_i686_gnu 0.36.1",
"windows_i686_msvc", "windows_i686_msvc 0.36.1",
"windows_x86_64_gnu", "windows_x86_64_gnu 0.36.1",
"windows_x86_64_msvc", "windows_x86_64_msvc 0.36.1",
] ]
[[package]] [[package]]
@ -3934,30 +4087,60 @@ version = "0.36.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47" checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47"
[[package]]
name = "windows_aarch64_msvc"
version = "0.37.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2623277cb2d1c216ba3b578c0f3cf9cdebeddb6e66b1b218bb33596ea7769c3a"
[[package]] [[package]]
name = "windows_i686_gnu" name = "windows_i686_gnu"
version = "0.36.1" version = "0.36.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6" checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6"
[[package]]
name = "windows_i686_gnu"
version = "0.37.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d3925fd0b0b804730d44d4b6278c50f9699703ec49bcd628020f46f4ba07d9e1"
[[package]] [[package]]
name = "windows_i686_msvc" name = "windows_i686_msvc"
version = "0.36.1" version = "0.36.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024" checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024"
[[package]]
name = "windows_i686_msvc"
version = "0.37.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ce907ac74fe331b524c1298683efbf598bb031bc84d5e274db2083696d07c57c"
[[package]] [[package]]
name = "windows_x86_64_gnu" name = "windows_x86_64_gnu"
version = "0.36.1" version = "0.36.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1" checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1"
[[package]]
name = "windows_x86_64_gnu"
version = "0.37.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2babfba0828f2e6b32457d5341427dcbb577ceef556273229959ac23a10af33d"
[[package]] [[package]]
name = "windows_x86_64_msvc" name = "windows_x86_64_msvc"
version = "0.36.1" version = "0.36.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680"
[[package]]
name = "windows_x86_64_msvc"
version = "0.37.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f4dd6dc7df2d84cf7b33822ed5b86318fb1781948e9663bacd047fc9dd52259d"
[[package]] [[package]]
name = "winit" name = "winit"
version = "0.26.1" version = "0.26.1"
@ -3981,7 +4164,7 @@ dependencies = [
"objc", "objc",
"parking_lot 0.11.2", "parking_lot 0.11.2",
"percent-encoding", "percent-encoding",
"raw-window-handle", "raw-window-handle 0.4.3",
"wasm-bindgen", "wasm-bindgen",
"web-sys", "web-sys",
"winapi", "winapi",

View file

@ -7,10 +7,13 @@ edition = "2021"
[dependencies] [dependencies]
bevy = "0.8.0" bevy = "0.8.0"
bevy_fundsp = "0.1.0" bevy_hanabi = "0.3.1"
bevy_hanabi = "0.3.0"
bevy-inspector-egui = "0.12.1" bevy-inspector-egui = "0.12.1"
bevy_rapier2d = "0.16.0" bevy_rapier2d = "0.16.2"
cpal = "0.14.0"
crossbeam-channel = "0.5.6"
hexodsp = { git = "https://github.com/WeirdConstructor/HexoDSP" }
ticktock = "0.8.0"
[profile.dev.package."*"] [profile.dev.package."*"]
opt-level = 3 opt-level = 3

View file

@ -9,13 +9,13 @@
## TODO ## TODO
* name * name
* stream audio (with HexoSynthDSP)
* color filters * color filters
* level design * level design
* (?) can jump only from a surface (no mid-air jump) * (?) can jump only from a surface (no mid-air jump)
* (?) multiplayer * (?) multiplayer
* make WASM build work again (replace hanabi) * make WASM build work again (replace hanabi)
* level reset * level reset
* more audio
## Build ## Build
@ -37,6 +37,12 @@ sh build-wasm.sh
python3 -m http.server python3 -m http.server
``` ```
## Audio
This game uses [HexoDSP](https://github.com/WeirdConstructor/HexoDSP) for audio synthesis.
The synthetizer matrix can be edited using [HexoSynth](https://github.com/WeirdConstructor/HexoSynth) visual editor.
## License ## License
GNU AGPL v3, CopyLeft 2022 Pascal Engélibert GNU AGPL v3, CopyLeft 2022 Pascal Engélibert

1
assets/init.hxy Normal file

File diff suppressed because one or more lines are too long

150
src/audio.rs Normal file
View file

@ -0,0 +1,150 @@
// https://github.com/WeirdConstructor/HexoDSP/blob/master/examples/cpal_demo_node_api.rs
use cpal::traits::{DeviceTrait, HostTrait, StreamTrait};
use crossbeam_channel::Receiver;
use hexodsp::{matrix_repr::MatrixRepr, *};
use std::io::Read;
use ticktock::Clock;
pub enum AudioMsg {
Color([f32; 3]),
Jump,
}
pub fn setup(event_channel: Receiver<AudioMsg>) {
let mut buf = String::new();
std::fs::File::open("assets/init.hxy")
.unwrap()
.read_to_string(&mut buf)
.unwrap();
let matrix_repr: MatrixRepr = MatrixRepr::deserialize(&buf).unwrap();
let (node_conf, node_exec) = new_node_engine();
let mut matrix = Matrix::new(node_conf, 64, 64);
matrix.from_repr(&matrix_repr).unwrap();
start_backend(node_exec, move || {
let color_mix = NodeId::Mix3(0);
let color_mix_r_gain = color_mix.inp_param("gain1").unwrap();
let color_mix_g_gain = color_mix.inp_param("gain2").unwrap();
let color_mix_b_gain = color_mix.inp_param("gain3").unwrap();
let jump_ad = NodeId::Ad(0);
let jump_ad_trig = jump_ad.inp_param("trig").unwrap();
for (_tick, _now) in Clock::framerate(10.0).iter() {
matrix.set_param(jump_ad_trig, (0.0).into());
if let Ok(msg) = event_channel.try_recv() {
match msg {
AudioMsg::Color([r, g, b]) => {
matrix.set_param(color_mix_r_gain, r.into());
matrix.set_param(color_mix_g_gain, g.into());
matrix.set_param(color_mix_b_gain, b.into());
}
AudioMsg::Jump => matrix.set_param(jump_ad_trig, (1.0).into()),
}
}
}
});
}
pub fn run<T, F: FnMut()>(
device: &cpal::Device,
config: &cpal::StreamConfig,
mut node_exec: NodeExecutor,
mut frontend_loop: F,
) where
T: cpal::Sample,
{
let sample_rate = config.sample_rate.0 as f32;
let channels = config.channels as usize;
node_exec.set_sample_rate(sample_rate);
let input_bufs = [[0.0; hexodsp::dsp::MAX_BLOCK_SIZE]; 2];
let mut outputbufs = [[0.0; hexodsp::dsp::MAX_BLOCK_SIZE]; 2];
let err_fn = |err| eprintln!("an error occurred on stream: {}", err);
let stream = device
.build_output_stream(
config,
move |data: &mut [T], _: &cpal::OutputCallbackInfo| {
let mut frames_left = data.len() / channels;
let mut out_iter = data.chunks_mut(channels);
node_exec.process_graph_updates();
while frames_left > 0 {
let cur_nframes = if frames_left >= hexodsp::dsp::MAX_BLOCK_SIZE {
hexodsp::dsp::MAX_BLOCK_SIZE
} else {
frames_left
};
let input = &[
&input_bufs[0][0..cur_nframes],
&input_bufs[1][0..cur_nframes],
];
let split = outputbufs.split_at_mut(1);
let mut output = [
&mut ((split.0[0])[0..cur_nframes]),
&mut ((split.1[0])[0..cur_nframes]),
];
let mut context = Context {
nframes: cur_nframes,
output: &mut output[..],
input,
};
context.output[0].fill(0.0);
context.output[1].fill(0.0);
node_exec.process(&mut context);
for i in 0..cur_nframes {
if let Some(frame) = out_iter.next() {
let mut ctx_chan = 0;
for sample in frame.iter_mut() {
let value: T =
cpal::Sample::from::<f32>(&context.output[ctx_chan][i]);
*sample = value;
ctx_chan += 1;
if ctx_chan > context.output.len() {
ctx_chan = context.output.len() - 1;
}
}
}
}
frames_left -= cur_nframes;
}
},
err_fn,
)
.unwrap();
stream.play().unwrap();
frontend_loop();
}
fn start_backend<F: FnMut()>(node_exec: NodeExecutor, frontend_loop: F) {
let host = cpal::default_host();
let device = host
.default_output_device()
.expect("Finding useable audio device");
let config = device
.default_output_config()
.expect("A workable output config");
match config.sample_format() {
cpal::SampleFormat::F32 => run::<f32, F>(&device, &config.into(), node_exec, frontend_loop),
cpal::SampleFormat::I16 => run::<i16, F>(&device, &config.into(), node_exec, frontend_loop),
cpal::SampleFormat::U16 => run::<u16, F>(&device, &config.into(), node_exec, frontend_loop),
};
}

View file

@ -1,6 +1,8 @@
#![allow(clippy::precedence)] #![allow(clippy::precedence)]
#![allow(clippy::too_many_arguments)] #![allow(clippy::too_many_arguments)]
pub use crate::audio::AudioMsg;
use crate::AppState; use crate::AppState;
use bevy::{ use bevy::{
@ -8,7 +10,6 @@ use bevy::{
prelude::{shape::Quad, *}, prelude::{shape::Quad, *},
sprite::Mesh2dHandle, sprite::Mesh2dHandle,
}; };
use bevy_fundsp::prelude::*;
use bevy_hanabi::*; use bevy_hanabi::*;
use bevy_rapier2d::prelude::*; use bevy_rapier2d::prelude::*;
use std::collections::BTreeSet; use std::collections::BTreeSet;
@ -104,6 +105,7 @@ pub fn spawn_character(
materials: &mut ResMut<Assets<ColorMaterial>>, materials: &mut ResMut<Assets<ColorMaterial>>,
selected_character_id: &mut Mut<SelectedCharacterId>, selected_character_id: &mut Mut<SelectedCharacterId>,
character_id_list: &mut Mut<CharacterIdList>, character_id_list: &mut Mut<CharacterIdList>,
audio: &Res<crossbeam_channel::Sender<AudioMsg>>,
transform: Transform, transform: Transform,
color: Color, color: Color,
) { ) {
@ -187,6 +189,9 @@ pub fn spawn_character(
// If no character is selected, then select this one // If no character is selected, then select this one
if selected_character_id.0.is_none() { if selected_character_id.0.is_none() {
selected_character_id.0 = Some(character_id); selected_character_id.0 = Some(character_id);
audio
.send(AudioMsg::Color([color.r(), color.g(), color.b()]))
.ok();
} }
} }
@ -199,6 +204,7 @@ fn collision_event_system(
character_query: Query<(&CharacterId, &CharacterColor, &Transform)>, character_query: Query<(&CharacterId, &CharacterColor, &Transform)>,
mut level_query: Query<(&mut SelectedCharacterId, &mut CharacterIdList)>, mut level_query: Query<(&mut SelectedCharacterId, &mut CharacterIdList)>,
mut app_state: ResMut<State<AppState>>, mut app_state: ResMut<State<AppState>>,
audio: Res<crossbeam_channel::Sender<AudioMsg>>,
) { ) {
for collision_event in collision_events.iter() { for collision_event in collision_events.iter() {
if let CollisionEvent::Started(e1, e2, flags) = collision_event { if let CollisionEvent::Started(e1, e2, flags) = collision_event {
@ -233,6 +239,7 @@ fn collision_event_system(
&mut materials, &mut materials,
&mut selected_character_id, &mut selected_character_id,
&mut character_id_list, &mut character_id_list,
&audio,
*c1_transform, *c1_transform,
new_color.into(), new_color.into(),
); );
@ -244,27 +251,18 @@ fn collision_event_system(
fn keyboard_input_system( fn keyboard_input_system(
keyboard_input: Res<Input<KeyCode>>, keyboard_input: Res<Input<KeyCode>>,
mut characters: Query<( mut characters: Query<(&CharacterId, &mut Velocity, &CharacterColor, &Children)>,
&CharacterId,
&mut Velocity,
&mut ExternalImpulse,
&mut ExternalForce,
&Children,
)>,
mut level_query: Query<(&mut SelectedCharacterId, &CharacterIdList)>, mut level_query: Query<(&mut SelectedCharacterId, &CharacterIdList)>,
mut effect: Query<&mut ParticleEffect>, mut effect: Query<&mut ParticleEffect>,
dsp_assets: Res<DspAssets>,
audio: Res<Audio>,
mut app_state: ResMut<State<AppState>>, mut app_state: ResMut<State<AppState>>,
audio: Res<crossbeam_channel::Sender<AudioMsg>>,
) { ) {
if let Ok((mut selected_character_id, character_id_list)) = level_query.get_single_mut() { if let Ok((mut selected_character_id, character_id_list)) = level_query.get_single_mut() {
if keyboard_input.just_pressed(KeyCode::Tab) { if keyboard_input.just_pressed(KeyCode::Tab) {
audio.play(dsp_assets.graph(&sine_wave));
let selected = if let Some(selected_character_id) = &mut selected_character_id.0 { let selected = if let Some(selected_character_id) = &mut selected_character_id.0 {
if let Some((_character_id, _velocity, _impulse, _force, children)) = characters if let Some((_character_id, _velocity, _color, children)) = characters
.iter_mut() .iter_mut()
.find(|(character_id, _velocity, _impulse, _force, _children)| { .find(|(character_id, _velocity, _color, _children)| {
*character_id == selected_character_id *character_id == selected_character_id
}) { }) {
effect effect
@ -286,17 +284,19 @@ fn keyboard_input_system(
CharacterId(0) CharacterId(0)
}; };
if let Some((_character_id, _velocity, _impulse, _force, children)) = characters if let Some((_character_id, _velocity, color, children)) = characters
.iter_mut() .iter_mut()
.find(|(character_id, _velocity, _impulse, _force, _children)| { .find(|(character_id, _velocity, _color, _children)| **character_id == selected)
**character_id == selected {
}) {
effect effect
.get_mut(children[0]) .get_mut(children[0])
.unwrap() .unwrap()
.maybe_spawner() .maybe_spawner()
.unwrap() .unwrap()
.set_active(true); .set_active(true);
audio
.send(AudioMsg::Color([color.0.r(), color.0.g(), color.0.b()]))
.ok();
} }
} }
@ -306,14 +306,15 @@ fn keyboard_input_system(
keyboard_input.pressed(KeyCode::Left) || keyboard_input.pressed(KeyCode::A); keyboard_input.pressed(KeyCode::Left) || keyboard_input.pressed(KeyCode::A);
if let Some(selected_character_id) = &selected_character_id.0 { if let Some(selected_character_id) = &selected_character_id.0 {
if let Some((_character_id, mut velocity, _impulse, _force, _children)) = characters if let Some((_character_id, mut velocity, _color, _children)) = characters
.iter_mut() .iter_mut()
.find(|(character_id, _velocity, _impulse, _force, _children)| { .find(|(character_id, _velocity, _color, _children)| {
*character_id == selected_character_id *character_id == selected_character_id
}) { }) {
velocity.linvel.x = 200. * (right_pressed as i8 - left_pressed as i8) as f32; velocity.linvel.x = 200. * (right_pressed as i8 - left_pressed as i8) as f32;
if keyboard_input.just_pressed(KeyCode::Space) { if keyboard_input.just_pressed(KeyCode::Space) {
audio.send(AudioMsg::Jump).ok();
velocity.linvel.y = 500.; velocity.linvel.y = 500.;
} }
} }
@ -342,9 +343,3 @@ fn win_setup(mut commands: Commands, asset_server: Res<AssetServer>) {
}) })
.insert(Level); .insert(Level);
} }
// Sounds
pub fn sine_wave() -> impl AudioUnit32 {
sine_hz(440.0) >> split::<U2>() * 0.2
}

View file

@ -43,6 +43,7 @@ pub fn post_setup_level(
mut level_query: Query<(&mut SelectedCharacterId, &mut CharacterIdList)>, mut level_query: Query<(&mut SelectedCharacterId, &mut CharacterIdList)>,
mut level_startup_event: EventReader<LevelStartupEvent>, mut level_startup_event: EventReader<LevelStartupEvent>,
asset_server: Res<AssetServer>, asset_server: Res<AssetServer>,
audio: Res<crossbeam_channel::Sender<AudioMsg>>,
) { ) {
for LevelStartupEvent(level_entity) in level_startup_event.iter() { for LevelStartupEvent(level_entity) in level_startup_event.iter() {
if let Ok((mut selected_character_id, mut character_id_list)) = if let Ok((mut selected_character_id, mut character_id_list)) =
@ -57,6 +58,7 @@ pub fn post_setup_level(
&mut materials, &mut materials,
&mut selected_character_id, &mut selected_character_id,
&mut character_id_list, &mut character_id_list,
&audio,
), ),
1 => level1::setup( 1 => level1::setup(
&mut commands, &mut commands,
@ -65,6 +67,7 @@ pub fn post_setup_level(
&mut materials, &mut materials,
&mut selected_character_id, &mut selected_character_id,
&mut character_id_list, &mut character_id_list,
&audio,
), ),
_ => game_over::setup(&mut commands, &asset_server), _ => game_over::setup(&mut commands, &asset_server),
} }

View file

@ -11,6 +11,7 @@ pub fn setup(
materials: &mut ResMut<Assets<ColorMaterial>>, materials: &mut ResMut<Assets<ColorMaterial>>,
selected_character_id: &mut Mut<SelectedCharacterId>, selected_character_id: &mut Mut<SelectedCharacterId>,
character_id_list: &mut Mut<CharacterIdList>, character_id_list: &mut Mut<CharacterIdList>,
audio: &Res<crossbeam_channel::Sender<AudioMsg>>,
) { ) {
commands commands
.spawn_bundle(TransformBundle::from(Transform::from_xyz(0.0, -256.0, 0.0))) .spawn_bundle(TransformBundle::from(Transform::from_xyz(0.0, -256.0, 0.0)))
@ -24,6 +25,7 @@ pub fn setup(
materials, materials,
selected_character_id, selected_character_id,
character_id_list, character_id_list,
audio,
Transform::from_xyz(-128., -64., 0.), Transform::from_xyz(-128., -64., 0.),
Color::RED, Color::RED,
); );
@ -34,6 +36,7 @@ pub fn setup(
materials, materials,
selected_character_id, selected_character_id,
character_id_list, character_id_list,
audio,
Transform::from_xyz(0., -64., 0.), Transform::from_xyz(0., -64., 0.),
Color::GREEN, Color::GREEN,
); );
@ -44,6 +47,7 @@ pub fn setup(
materials, materials,
selected_character_id, selected_character_id,
character_id_list, character_id_list,
audio,
Transform::from_xyz(128., -64., 0.), Transform::from_xyz(128., -64., 0.),
Color::BLUE, Color::BLUE,
); );

View file

@ -11,6 +11,7 @@ pub fn setup(
materials: &mut ResMut<Assets<ColorMaterial>>, materials: &mut ResMut<Assets<ColorMaterial>>,
selected_character_id: &mut Mut<SelectedCharacterId>, selected_character_id: &mut Mut<SelectedCharacterId>,
character_id_list: &mut Mut<CharacterIdList>, character_id_list: &mut Mut<CharacterIdList>,
audio: &Res<crossbeam_channel::Sender<AudioMsg>>,
) { ) {
commands commands
.spawn_bundle(TransformBundle::from(Transform::from_xyz(0.0, -256.0, 0.0))) .spawn_bundle(TransformBundle::from(Transform::from_xyz(0.0, -256.0, 0.0)))
@ -30,6 +31,7 @@ pub fn setup(
materials, materials,
selected_character_id, selected_character_id,
character_id_list, character_id_list,
audio,
Transform::from_xyz(128., 64., 0.), Transform::from_xyz(128., 64., 0.),
Color::BLUE, Color::BLUE,
); );
@ -40,6 +42,7 @@ pub fn setup(
materials, materials,
selected_character_id, selected_character_id,
character_id_list, character_id_list,
audio,
Transform::from_xyz(-128., -128., 0.), Transform::from_xyz(-128., -128., 0.),
Color::RED, Color::RED,
); );
@ -50,6 +53,7 @@ pub fn setup(
materials, materials,
selected_character_id, selected_character_id,
character_id_list, character_id_list,
audio,
Transform::from_xyz(0., -128., 0.), Transform::from_xyz(0., -128., 0.),
Color::GREEN, Color::GREEN,
); );

View file

@ -1,3 +1,4 @@
mod audio;
mod game; mod game;
mod levels; mod levels;
mod menu; mod menu;
@ -8,7 +9,6 @@ use bevy::{
prelude::*, prelude::*,
render::settings::{WgpuFeatures, WgpuSettings}, render::settings::{WgpuFeatures, WgpuSettings},
}; };
use bevy_fundsp::prelude::*;
use bevy_hanabi::*; use bevy_hanabi::*;
use bevy_rapier2d::prelude::*; use bevy_rapier2d::prelude::*;
@ -20,15 +20,19 @@ enum AppState {
} }
fn main() { fn main() {
let (audio_event_sender, audio_event_receiver) = crossbeam_channel::bounded(512);
std::thread::spawn(move || audio::setup(audio_event_receiver));
let mut options = WgpuSettings::default(); let mut options = WgpuSettings::default();
options options
.features .features
.set(WgpuFeatures::VERTEX_WRITABLE_STORAGE, true); .set(WgpuFeatures::VERTEX_WRITABLE_STORAGE, true);
App::new() App::new()
.insert_resource(options) .insert_resource(options)
.insert_resource(audio_event_sender)
.add_state(AppState::Menu) .add_state(AppState::Menu)
.add_plugins(DefaultPlugins) .add_plugins(DefaultPlugins)
.add_plugin(DspPlugin)
.add_plugin(HanabiPlugin) .add_plugin(HanabiPlugin)
.add_plugin(RapierPhysicsPlugin::<NoUserData>::pixels_per_meter(64.0)) .add_plugin(RapierPhysicsPlugin::<NoUserData>::pixels_per_meter(64.0))
.add_plugin(RapierDebugRenderPlugin::default()) .add_plugin(RapierDebugRenderPlugin::default())
@ -39,11 +43,7 @@ fn main() {
.run(); .run();
} }
fn setup( fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
mut commands: Commands,
mut dsp_manager: ResMut<DspManager>,
asset_server: Res<AssetServer>,
) {
let font: Handle<Font> = asset_server.load("UacariLegacy-Thin.ttf"); let font: Handle<Font> = asset_server.load("UacariLegacy-Thin.ttf");
commands.insert_resource(font); commands.insert_resource(font);
@ -57,5 +57,4 @@ fn setup(
color: Color::WHITE, color: Color::WHITE,
brightness: 0.6, brightness: 0.6,
}); });
dsp_manager.add_graph(game::sine_wave, 1.0);
} }