Compare commits

..

6 commits

Author SHA1 Message Date
431789189a
fix(wasm): request permission for media autoplay if needed 2022-08-28 19:45:38 +02:00
Nixon
32c67d46d5 center camera while zoomed out 2022-08-28 19:40:36 +02:00
Nixon
492c4238cb added initial zoom out timer
- to view the overall level
2022-08-28 19:40:36 +02:00
Nixon
5b22e84952 game is now independent of hexodsp/cpal 2022-08-28 19:40:35 +02:00
Nixon
7d28ccfb88 only platform jumpable! 2022-08-28 19:39:18 +02:00
Nixon
dd34c412dd uses target translation for camera movement (prevent hard hit when moving beyond lower margin) 2022-08-28 19:34:56 +02:00
23 changed files with 144 additions and 653 deletions

573
Cargo.lock generated
View file

@ -123,25 +123,6 @@ dependencies = [
"num-traits", "num-traits",
] ]
[[package]]
name = "arboard"
version = "2.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc120354d1b5ec6d7aaf4876b602def75595937b5e15d356eb554ab5177e08bb"
dependencies = [
"clipboard-win",
"core-graphics 0.22.3",
"image 0.23.14",
"log",
"objc",
"objc-foundation",
"objc_id",
"parking_lot 0.12.1",
"thiserror",
"winapi",
"x11rb",
]
[[package]] [[package]]
name = "arrayvec" name = "arrayvec"
version = "0.7.2" version = "0.7.2"
@ -188,12 +169,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_refcell"
version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "73b5e5f48b927f04e952dedc932f31995a65a0bf65ec971c74436e51bf6e970d"
[[package]] [[package]]
name = "autocfg" name = "autocfg"
version = "1.1.0" version = "1.1.0"
@ -215,30 +190,6 @@ dependencies = [
"bevy_internal", "bevy_internal",
] ]
[[package]]
name = "bevy-inspector-egui"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f0c53ed1cad011e33ea145d2c1f649a966e7457453f3768ddff39bc5064bd525"
dependencies = [
"bevy",
"bevy-inspector-egui-derive",
"bevy_egui",
"image 0.23.14",
"pretty-type-name",
]
[[package]]
name = "bevy-inspector-egui-derive"
version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "48ef6260a46924d40781bcb9da157c110d5166bbd573795e4a16f2505913d0d0"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]] [[package]]
name = "bevy_animation" name = "bevy_animation"
version = "0.8.1" version = "0.8.1"
@ -416,19 +367,6 @@ dependencies = [
"syn", "syn",
] ]
[[package]]
name = "bevy_egui"
version = "0.15.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "acbf44ff770566dca66b805a6829df783f64700bd01d35aec1034dff31b531a4"
dependencies = [
"arboard",
"bevy",
"egui",
"thread_local",
"webbrowser",
]
[[package]] [[package]]
name = "bevy_encase_derive" name = "bevy_encase_derive"
version = "0.8.1" version = "0.8.1"
@ -710,7 +648,7 @@ dependencies = [
"futures-lite", "futures-lite",
"hex", "hex",
"hexasphere", "hexasphere",
"image 0.24.3", "image",
"naga", "naga",
"once_cell", "once_cell",
"parking_lot 0.12.1", "parking_lot 0.12.1",
@ -899,7 +837,7 @@ dependencies = [
"bevy_input", "bevy_input",
"bevy_math", "bevy_math",
"bevy_utils", "bevy_utils",
"raw-window-handle 0.4.3", "raw-window-handle",
"web-sys", "web-sys",
] ]
@ -917,7 +855,7 @@ dependencies = [
"bevy_utils", "bevy_utils",
"bevy_window", "bevy_window",
"crossbeam-channel", "crossbeam-channel",
"raw-window-handle 0.4.3", "raw-window-handle",
"wasm-bindgen", "wasm-bindgen",
"web-sys", "web-sys",
"winit", "winit",
@ -1066,17 +1004,6 @@ dependencies = [
"libloading", "libloading",
] ]
[[package]]
name = "clipboard-win"
version = "4.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c4ab1b92798304eedc095b53942963240037c0516452cb11aeba709d420b2219"
dependencies = [
"error-code",
"str-buf",
"winapi",
]
[[package]] [[package]]
name = "cocoa" name = "cocoa"
version = "0.24.0" version = "0.24.0"
@ -1292,31 +1219,6 @@ 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]] [[package]]
name = "crc32fast" name = "crc32fast"
version = "1.3.2" version = "1.3.2"
@ -1447,16 +1349,6 @@ dependencies = [
"syn", "syn",
] ]
[[package]]
name = "deflate"
version = "0.8.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "73770f8e1fe7d64df17ca66ad28994a0a623ea497fa69486e14984e715c5d174"
dependencies = [
"adler32",
"byteorder",
]
[[package]] [[package]]
name = "deflate" name = "deflate"
version = "1.0.0" version = "1.0.0"
@ -1478,32 +1370,12 @@ 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 = "egui"
version = "0.18.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eb095a8b9feb9b7ff8f00b6776dffcef059538a3f4a91238e03c900e9c9ad9a2"
dependencies = [
"ahash",
"epaint",
"nohash-hasher",
]
[[package]] [[package]]
name = "either" name = "either"
version = "1.8.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 = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797" checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797"
[[package]]
name = "emath"
version = "0.18.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c223f58c7e38abe1770f367b969f1b3fbd4704b67666bcb65dbb1adb0980ba72"
dependencies = [
"bytemuck",
]
[[package]] [[package]]
name = "encase" name = "encase"
version = "0.3.0" version = "0.3.0"
@ -1546,21 +1418,6 @@ dependencies = [
"regex", "regex",
] ]
[[package]]
name = "epaint"
version = "0.18.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c29567088888e8ac3e8f61bbb2ddc820207ebb8d69eefde5bcefa06d65e4e89"
dependencies = [
"ab_glyph",
"ahash",
"atomic_refcell",
"bytemuck",
"emath",
"nohash-hasher",
"parking_lot 0.12.1",
]
[[package]] [[package]]
name = "erased-serde" name = "erased-serde"
version = "0.3.23" version = "0.3.23"
@ -1570,16 +1427,6 @@ dependencies = [
"serde", "serde",
] ]
[[package]]
name = "error-code"
version = "2.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "64f18991e7bf11e7ffee451b5318b5c1a73c52d0d0ada6e5a3017c8c1ced6a21"
dependencies = [
"libc",
"str-buf",
]
[[package]] [[package]]
name = "euclid" name = "euclid"
version = "0.22.7" version = "0.22.7"
@ -1643,16 +1490,6 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"
[[package]]
name = "form_urlencoded"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5fc25a87fa4fd2094bffb06925852034d90a17f0d1e05197d4956d3555752191"
dependencies = [
"matches",
"percent-encoding",
]
[[package]] [[package]]
name = "fsevent-sys" name = "fsevent-sys"
version = "4.1.0" version = "4.1.0"
@ -1698,16 +1535,6 @@ dependencies = [
"byteorder", "byteorder",
] ]
[[package]]
name = "gethostname"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c1ebd34e35c46e00bb73e81363248d627782724609fe1b6396f553f68fe3862e"
dependencies = [
"libc",
"winapi",
]
[[package]] [[package]]
name = "getrandom" name = "getrandom"
version = "0.2.7" version = "0.2.7"
@ -1939,59 +1766,12 @@ 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",
"triple_buffer",
]
[[package]]
name = "hound"
version = "3.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a164bb2ceaeff4f42542bdb847c41517c78a60f5649671b2a07312b6e117549"
[[package]] [[package]]
name = "ident_case" name = "ident_case"
version = "1.0.1" version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39"
[[package]]
name = "idna"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "418a0a6fab821475f634efe3ccc45c013f742efe03d853e8d3355d5cb850ecf8"
dependencies = [
"matches",
"unicode-bidi",
"unicode-normalization",
]
[[package]]
name = "image"
version = "0.23.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "24ffcb7e7244a9bf19d35bf2883b9c080c4ced3c07a9895572178cdb8f13f6a1"
dependencies = [
"bytemuck",
"byteorder",
"color_quant",
"num-iter",
"num-rational 0.3.2",
"num-traits",
"png 0.16.8",
"tiff",
]
[[package]] [[package]]
name = "image" name = "image"
version = "0.24.3" version = "0.24.3"
@ -2001,9 +1781,9 @@ dependencies = [
"bytemuck", "bytemuck",
"byteorder", "byteorder",
"color_quant", "color_quant",
"num-rational 0.4.1", "num-rational",
"num-traits", "num-traits",
"png 0.17.5", "png",
"scoped_threadpool", "scoped_threadpool",
] ]
@ -2106,12 +1886,6 @@ dependencies = [
"libc", "libc",
] ]
[[package]]
name = "jpeg-decoder"
version = "0.1.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "229d53d58899083193af11e15917b5640cd40b29ff475a1fe4ef725deb02d0f2"
[[package]] [[package]]
name = "js-sys" name = "js-sys"
version = "0.3.59" version = "0.3.59"
@ -2209,9 +1983,9 @@ dependencies = [
[[package]] [[package]]
name = "lock_api" name = "lock_api"
version = "0.4.7" version = "0.4.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "327fa5b6a6940e4699ec49a9beae1ea4845c6bab9314e4f84ac68742139d8c53" checksum = "9f80bf5aacaf25cbfc8210d1cfb718f2bf3b11c4c54e5afe36c236853a8ec390"
dependencies = [ dependencies = [
"autocfg", "autocfg",
"scopeguard", "scopeguard",
@ -2231,19 +2005,14 @@ name = "lux-synthese"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"bevy", "bevy",
"bevy-inspector-egui",
"bevy_common_assets", "bevy_common_assets",
"bevy_mod_picking", "bevy_mod_picking",
"bevy_rapier2d", "bevy_rapier2d",
"cpal 0.14.0",
"crossbeam-channel",
"hexodsp",
"rand", "rand",
"rand_distr", "rand_distr",
"rapier2d", "rapier2d",
"serde", "serde",
"serde_json", "serde_json",
"ticktock",
] ]
[[package]] [[package]]
@ -2273,12 +2042,6 @@ dependencies = [
"regex-automata", "regex-automata",
] ]
[[package]]
name = "matches"
version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f"
[[package]] [[package]]
name = "matrixmultiply" name = "matrixmultiply"
version = "0.3.2" version = "0.3.2"
@ -2323,25 +2086,6 @@ 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 = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
[[package]]
name = "miniz_oxide"
version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "791daaae1ed6889560f8c4359194f56648355540573244a5448a83ba1ecc7435"
dependencies = [
"adler32",
]
[[package]]
name = "miniz_oxide"
version = "0.4.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a92518e98c078586bc6c934028adcca4c92a53d6a958196de835170a01d84e4b"
dependencies = [
"adler",
"autocfg",
]
[[package]] [[package]]
name = "miniz_oxide" name = "miniz_oxide"
version = "0.5.3" version = "0.5.3"
@ -2396,7 +2140,7 @@ dependencies = [
"matrixmultiply", "matrixmultiply",
"nalgebra-macros", "nalgebra-macros",
"num-complex", "num-complex",
"num-rational 0.4.1", "num-rational",
"num-traits", "num-traits",
"simba", "simba",
"typenum", "typenum",
@ -2439,20 +2183,6 @@ 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"
@ -2518,28 +2248,6 @@ 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]]
name = "nix"
version = "0.22.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e4916f159ed8e5de0082076562152a76b7a1f64a01fd9d1e0fea002c37624faf"
dependencies = [
"bitflags",
"cc",
"cfg-if 1.0.0",
"libc",
"memoffset",
]
[[package]] [[package]]
name = "nix" name = "nix"
version = "0.23.1" version = "0.23.1"
@ -2564,12 +2272,6 @@ dependencies = [
"libc", "libc",
] ]
[[package]]
name = "nohash-hasher"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451"
[[package]] [[package]]
name = "nom" name = "nom"
version = "7.1.1" version = "7.1.1"
@ -2628,28 +2330,6 @@ dependencies = [
"num-traits", "num-traits",
] ]
[[package]]
name = "num-iter"
version = "0.1.43"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7d03e6c028c5dc5cac6e2dec0efda81fc887605bb3d884578bb6d6bf7514e252"
dependencies = [
"autocfg",
"num-integer",
"num-traits",
]
[[package]]
name = "num-rational"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "12ac428b1cb17fce6f731001d307d351ec70a6d202fc2e60f7d4c5e42d8f4f07"
dependencies = [
"autocfg",
"num-integer",
"num-traits",
]
[[package]] [[package]]
name = "num-rational" name = "num-rational"
version = "0.4.1" version = "0.4.1"
@ -2712,17 +2392,6 @@ dependencies = [
"objc_exception", "objc_exception",
] ]
[[package]]
name = "objc-foundation"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1add1b659e36c9607c7aab864a76c7a4c2760cd0cd2e120f3fb8b952c7e22bf9"
dependencies = [
"block",
"objc",
"objc_id",
]
[[package]] [[package]]
name = "objc_exception" name = "objc_exception"
version = "0.1.2" version = "0.1.2"
@ -2732,15 +2401,6 @@ dependencies = [
"cc", "cc",
] ]
[[package]]
name = "objc_id"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c92d4ddb4bd7b50d730c215ff871754d0da6b2178849f8a2a2ab69712d0c073b"
dependencies = [
"objc",
]
[[package]] [[package]]
name = "oboe" name = "oboe"
version = "0.4.6" version = "0.4.6"
@ -2909,18 +2569,6 @@ version = "0.3.25"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1df8c4ec4b0627e53bdf214615ad287367e482558cf84b109250b37464dc03ae" checksum = "1df8c4ec4b0627e53bdf214615ad287367e482558cf84b109250b37464dc03ae"
[[package]]
name = "png"
version = "0.16.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3c3287920cb847dee3de33d301c463fba14dda99db24214ddf93f83d3021f4c6"
dependencies = [
"bitflags",
"crc32fast",
"deflate 0.8.6",
"miniz_oxide 0.3.7",
]
[[package]] [[package]]
name = "png" name = "png"
version = "0.17.5" version = "0.17.5"
@ -2929,8 +2577,8 @@ checksum = "dc38c0ad57efb786dd57b9864e5b18bae478c00c824dc55a38bbc9da95dde3ba"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"crc32fast", "crc32fast",
"deflate 1.0.0", "deflate",
"miniz_oxide 0.5.3", "miniz_oxide",
] ]
[[package]] [[package]]
@ -2948,12 +2596,6 @@ 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 = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872"
[[package]]
name = "pretty-type-name"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a8815d101cfb4cb491154896bdab292a395a7ac9ab185a9941a2f5be0135900d"
[[package]] [[package]]
name = "proc-macro-crate" name = "proc-macro-crate"
version = "1.2.1" version = "1.2.1"
@ -3070,15 +2712,6 @@ 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"
@ -3132,15 +2765,6 @@ 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"
@ -3153,7 +2777,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 0.13.5", "cpal",
"lewton", "lewton",
] ]
@ -3335,12 +2959,6 @@ version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ef5430c8e36b713e13b48a9f709cc21e046723fe44ce34587b73a830203b533e" checksum = "ef5430c8e36b713e13b48a9f709cc21e046723fe44ce34587b73a830203b533e"
[[package]]
name = "str-buf"
version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9e08d8363704e6c71fc928674353e6b7c23dcea9d82d7012c8faf2a3a025f8d0"
[[package]] [[package]]
name = "strsim" name = "strsim"
version = "0.10.0" version = "0.10.0"
@ -3364,14 +2982,6 @@ 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]] [[package]]
name = "taffy" name = "taffy"
version = "0.1.0" version = "0.1.0"
@ -3423,23 +3033,6 @@ 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]]
name = "tiff"
version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a53f4706d65497df0c4349241deddf35f84cee19c87ed86ea8ca590f4464437"
dependencies = [
"jpeg-decoder",
"miniz_oxide 0.4.4",
"weezl",
]
[[package]] [[package]]
name = "tinyvec" name = "tinyvec"
version = "1.6.0" version = "1.6.0"
@ -3537,15 +3130,6 @@ dependencies = [
"wasm-bindgen", "wasm-bindgen",
] ]
[[package]]
name = "triple_buffer"
version = "5.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "803966e5a8397a70d3d8111afa1597ba8381346d7de4720e9f539471d371a1a3"
dependencies = [
"cache-padded",
]
[[package]] [[package]]
name = "ttf-parser" name = "ttf-parser"
version = "0.15.2" version = "0.15.2"
@ -3558,27 +3142,12 @@ version = "1.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987"
[[package]]
name = "unicode-bidi"
version = "0.3.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "099b7128301d285f79ddd55b9a83d5e6b9e97c92e0ea0daebee7263e932de992"
[[package]] [[package]]
name = "unicode-ident" name = "unicode-ident"
version = "1.0.3" version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c4f5b37a154999a8f3f98cc23a628d850e154479cd94decf3414696e12e31aaf" checksum = "c4f5b37a154999a8f3f98cc23a628d850e154479cd94decf3414696e12e31aaf"
[[package]]
name = "unicode-normalization"
version = "0.1.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "854cbdc4f7bc6ae19c820d44abdc3277ac3e1b2b93db20a636825d9322fb60e6"
dependencies = [
"tinyvec",
]
[[package]] [[package]]
name = "unicode-width" name = "unicode-width"
version = "0.1.9" version = "0.1.9"
@ -3591,18 +3160,6 @@ version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "957e51f3646910546462e67d5f7599b9e4fb8acdd304b087a6494730f9eebf04" checksum = "957e51f3646910546462e67d5f7599b9e4fb8acdd304b087a6494730f9eebf04"
[[package]]
name = "url"
version = "2.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a507c383b2d33b5fc35d1861e77e6b383d158b2da5e14fe51b83dfedf6fd578c"
dependencies = [
"form_urlencoded",
"idna",
"matches",
"percent-encoding",
]
[[package]] [[package]]
name = "uuid" name = "uuid"
version = "1.1.2" version = "1.1.2"
@ -3730,26 +3287,6 @@ dependencies = [
"wasm-bindgen", "wasm-bindgen",
] ]
[[package]]
name = "webbrowser"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc6a3cffdb686fbb24d9fb8f03a213803277ed2300f11026a3afe1f108dc021b"
dependencies = [
"jni",
"ndk-glue 0.6.2",
"url",
"web-sys",
"widestring",
"winapi",
]
[[package]]
name = "weezl"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9193164d4de03a926d909d3bc7c30543cecb35400c02114792c2cae20d5e2dbb"
[[package]] [[package]]
name = "wgpu" name = "wgpu"
version = "0.13.1" version = "0.13.1"
@ -3760,7 +3297,7 @@ dependencies = [
"log", "log",
"naga", "naga",
"parking_lot 0.12.1", "parking_lot 0.12.1",
"raw-window-handle 0.4.3", "raw-window-handle",
"smallvec", "smallvec",
"wasm-bindgen", "wasm-bindgen",
"wasm-bindgen-futures", "wasm-bindgen-futures",
@ -3786,7 +3323,7 @@ dependencies = [
"naga", "naga",
"parking_lot 0.12.1", "parking_lot 0.12.1",
"profiling", "profiling",
"raw-window-handle 0.4.3", "raw-window-handle",
"smallvec", "smallvec",
"thiserror", "thiserror",
"web-sys", "web-sys",
@ -3823,7 +3360,7 @@ dependencies = [
"parking_lot 0.12.1", "parking_lot 0.12.1",
"profiling", "profiling",
"range-alloc", "range-alloc",
"raw-window-handle 0.4.3", "raw-window-handle",
"renderdoc-sys", "renderdoc-sys",
"thiserror", "thiserror",
"wasm-bindgen", "wasm-bindgen",
@ -3850,12 +3387,6 @@ dependencies = [
"safe_arch", "safe_arch",
] ]
[[package]]
name = "widestring"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "17882f045410753661207383517a6f62ec3dbeb6a4ed2acce01f0728238d1983"
[[package]] [[package]]
name = "winapi" name = "winapi"
version = "0.3.9" version = "0.3.9"
@ -3881,45 +3412,23 @@ dependencies = [
"winapi", "winapi",
] ]
[[package]]
name = "winapi-wsapoll"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "44c17110f57155602a80dca10be03852116403c9ff3cd25b079d666f2aa3df6e"
dependencies = [
"winapi",
]
[[package]] [[package]]
name = "winapi-x86_64-pc-windows-gnu" name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0" 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 0.36.1", "windows_aarch64_msvc",
"windows_i686_gnu 0.36.1", "windows_i686_gnu",
"windows_i686_msvc 0.36.1", "windows_i686_msvc",
"windows_x86_64_gnu 0.36.1", "windows_x86_64_gnu",
"windows_x86_64_msvc 0.36.1", "windows_x86_64_msvc",
] ]
[[package]] [[package]]
@ -3928,60 +3437,30 @@ 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"
@ -4005,7 +3484,7 @@ dependencies = [
"objc", "objc",
"parking_lot 0.11.2", "parking_lot 0.11.2",
"percent-encoding", "percent-encoding",
"raw-window-handle 0.4.3", "raw-window-handle",
"wasm-bindgen", "wasm-bindgen",
"web-sys", "web-sys",
"winapi", "winapi",
@ -4023,18 +3502,6 @@ dependencies = [
"pkg-config", "pkg-config",
] ]
[[package]]
name = "x11rb"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6e99be55648b3ae2a52342f9a870c0e138709a3493261ce9b469afe6e4df6d8a"
dependencies = [
"gethostname",
"nix 0.22.3",
"winapi",
"winapi-wsapoll",
]
[[package]] [[package]]
name = "xi-unicode" name = "xi-unicode"
version = "0.3.0" version = "0.3.0"

View file

@ -9,19 +9,19 @@ edition = "2021"
bevy = "0.8.1" bevy = "0.8.1"
bevy_common_assets = { version = "0.3.0", features = ["json"] } bevy_common_assets = { version = "0.3.0", features = ["json"] }
bevy_rapier2d = "0.16.2" bevy_rapier2d = "0.16.2"
crossbeam-channel = "0.5.6" #crossbeam-channel = "0.5.6"
rand = "0.8.5" rand = "0.8.5"
rand_distr = "0.4.3" rand_distr = "0.4.3"
rapier2d = "0.14.0" rapier2d = "0.14.0"
serde = { version = "1.0.144", features = ["derive"] } serde = { version = "1.0.144", features = ["derive"] }
[target."cfg(not(target_arch = \"wasm32\"))".dependencies] [target."cfg(not(target_arch = \"wasm32\"))".dependencies]
bevy-inspector-egui = "0.12.1" #bevy-inspector-egui = "0.12.1"
bevy_mod_picking = "0.9.0" bevy_mod_picking = "0.9.0"
cpal = "0.14.0" # cpal = "0.14.0"
hexodsp = { git = "https://github.com/WeirdConstructor/HexoDSP", default-features = false } # hexodsp = { git = "https://github.com/WeirdConstructor/HexoDSP", default-features = false }
serde_json = "1.0.85" serde_json = "1.0.85"
ticktock = "0.8.0" #ticktock = "0.8.0"
[target."cfg(target_arch = \"wasm32\")".dependencies] [target."cfg(target_arch = \"wasm32\")".dependencies]
#cpal = { version = "0.14.0", features = ["wasm-bindgen"] } #cpal = { version = "0.14.0", features = ["wasm-bindgen"] }

View file

@ -30,8 +30,6 @@ cargo build --release
### WASM ### WASM
**Audio does not work in WASM!**
```bash ```bash
rustup target add wasm32-unknown-unknown rustup target add wasm32-unknown-unknown
cargo install wasm-bindgen-cli cargo install wasm-bindgen-cli
@ -44,10 +42,12 @@ python3 -m http.server
## Audio ## Audio
This game uses [HexoDSP](https://github.com/WeirdConstructor/HexoDSP) for audio synthesis. This game used [HexoDSP](https://github.com/WeirdConstructor/HexoDSP) for audio synthesis.
The synthetizer matrix can be edited using [HexoSynth](https://github.com/WeirdConstructor/HexoSynth) visual editor. The synthetizer matrix can be edited using [HexoSynth](https://github.com/WeirdConstructor/HexoSynth) visual editor.
However we could not get this working in WASM, hence we used simple playback audio instead for the jam. The concept of procedural audio is not abandonned but it will be for another time.
## Develop ## Develop
Skip to level `N: u32` with the command `bevyjam <N>`. Skip to level `N: u32` with the command `bevyjam <N>`.

0
assets/silence.wav Normal file
View file

BIN
assets/sound/notes/a5.ogg Normal file

Binary file not shown.

BIN
assets/sound/notes/cs6.ogg Normal file

Binary file not shown.

BIN
assets/sound/notes/e6.ogg Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -57,10 +57,12 @@ a, a:visited {
import init from './target/lux-synthese.js' import init from './target/lux-synthese.js'
init() init()
</script> </script>
<!-- workaround to be sure the browser will request permission to autoplay audio -->
<audio autoplay src="assets/silence.wav"></audio>
<div id="readme"> <div id="readme">
<h1>Lux synthesĕ</h1> <h1>Lux synthesĕ</h1>
<p> <p>
<strong>Note</strong>: audio does not work in the WASM build. <strong>If audio does not work, please allow media autoplay in browser, then refresh this page.</strong>
</p> </p>
<h2>Controls</h2> <h2>Controls</h2>
<ul> <ul>

View file

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Before After
Before After

BIN
res/notes.flp Normal file

Binary file not shown.

View file

@ -1,5 +1,6 @@
// https://github.com/WeirdConstructor/HexoDSP/blob/master/examples/cpal_demo_node_api.rs // https://github.com/WeirdConstructor/HexoDSP/blob/master/examples/cpal_demo_node_api.rs
// use bevy::{prelude::*, asset::HandleId};
use crate::game::AudioMsg; use crate::game::AudioMsg;
use cpal::traits::{DeviceTrait, HostTrait, StreamTrait}; use cpal::traits::{DeviceTrait, HostTrait, StreamTrait};

48
src/audio_system.rs Normal file
View file

@ -0,0 +1,48 @@
use bevy::prelude::*;
pub struct AudioSystemPlugin;
impl Plugin for AudioSystemPlugin {
fn build(&self, app: &mut App) {
app.init_resource::<AudioAssets>()
.add_startup_system(load_audio);
}
}
#[derive(Default)]
pub struct AudioAssets {
pub notes: [Handle<AudioSource>; 3],
pub reverb_notes: [Handle<AudioSource>; 3],
pub warp_notes: [Handle<AudioSource>; 3],
}
pub fn play_audio(
audio_set: &[Handle<AudioSource>; 3],
audio: &Res<Audio>,
color: Vec4,
volume: f32,
) {
for i in 0..3 {
audio.play_with_settings(
audio_set[i].clone(),
PlaybackSettings::ONCE.with_volume(color[i] * volume),
);
}
}
fn load_audio(mut audio_assets: ResMut<AudioAssets>, asset_server: Res<AssetServer>) {
audio_assets.notes[0] = asset_server.load::<AudioSource, &str>("sound/notes/a5.ogg");
audio_assets.notes[1] = asset_server.load::<AudioSource, &str>("sound/notes/cs6.ogg");
audio_assets.notes[2] = asset_server.load::<AudioSource, &str>("sound/notes/e6.ogg");
audio_assets.reverb_notes[0] =
asset_server.load::<AudioSource, &str>("sound/reverb_notes/a5.ogg");
audio_assets.reverb_notes[1] =
asset_server.load::<AudioSource, &str>("sound/reverb_notes/cs6.ogg");
audio_assets.reverb_notes[2] =
asset_server.load::<AudioSource, &str>("sound/reverb_notes/e6.ogg");
audio_assets.warp_notes[0] = asset_server.load::<AudioSource, &str>("sound/warp_notes/a5.ogg");
audio_assets.warp_notes[1] = asset_server.load::<AudioSource, &str>("sound/warp_notes/cs6.ogg");
audio_assets.warp_notes[2] = asset_server.load::<AudioSource, &str>("sound/warp_notes/e6.ogg");
}

View file

@ -2,8 +2,8 @@
#![allow(clippy::too_many_arguments)] #![allow(clippy::too_many_arguments)]
pub use crate::filters::*; pub use crate::filters::*;
use crate::levels;
use crate::AppState; use crate::{audio_system, AppState};
use bevy::{ use bevy::{
ecs::system::EntityCommands, ecs::system::EntityCommands,
@ -15,13 +15,6 @@ use bevy_rapier2d::prelude::*;
use rapier2d::geometry::CollisionEventFlags; use rapier2d::geometry::CollisionEventFlags;
use std::collections::BTreeSet; use std::collections::BTreeSet;
pub enum AudioMsg {
Color([f32; 3]),
Fusion,
Jump,
Switch,
}
pub struct FirstLevel(pub LevelId); pub struct FirstLevel(pub LevelId);
#[derive(Clone, Copy, Eq, Hash, PartialEq)] #[derive(Clone, Copy, Eq, Hash, PartialEq)]
@ -35,6 +28,7 @@ impl Plugin for GamePlugin {
.init_resource::<CharacterMeshes>() .init_resource::<CharacterMeshes>()
.insert_resource(CurrentLevel(None)) .insert_resource(CurrentLevel(None))
.init_resource::<CharacterList>() .init_resource::<CharacterList>()
.init_resource::<levels::ZoomTimer>()
.add_system_set(SystemSet::on_enter(AppState::Game).with_system(setup)) .add_system_set(SystemSet::on_enter(AppState::Game).with_system(setup))
.add_system_set(SystemSet::on_enter(AppState::Win).with_system(win_setup)) .add_system_set(SystemSet::on_enter(AppState::Win).with_system(win_setup))
.add_system_set( .add_system_set(
@ -46,14 +40,14 @@ impl Plugin for GamePlugin {
.with_system(change_character_system) .with_system(change_character_system)
.with_system(player_movement_system) .with_system(player_movement_system)
.with_system(level_keyboard_system) .with_system(level_keyboard_system)
.with_system(move_camera) .with_system(camera_system)
.with_system(character_particle_effect_system), .with_system(character_particle_effect_system),
) )
.add_system_set( .add_system_set(
SystemSet::on_update(AppState::Win) SystemSet::on_update(AppState::Win)
.with_system(player_movement_system) .with_system(player_movement_system)
.with_system(level_keyboard_system) .with_system(level_keyboard_system)
.with_system(move_camera) .with_system(camera_system)
.with_system(character_particle_effect_system) .with_system(character_particle_effect_system)
.with_system(move_win_text_system), .with_system(move_win_text_system),
) )
@ -144,19 +138,19 @@ fn setup(
mut current_level: ResMut<CurrentLevel>, mut current_level: ResMut<CurrentLevel>,
mut level_startup_event: EventWriter<LevelStartupEvent>, mut level_startup_event: EventWriter<LevelStartupEvent>,
mut camera_query: Query<&mut Transform, With<Camera>>, mut camera_query: Query<&mut Transform, With<Camera>>,
mut zoom_timer: ResMut<levels::ZoomTimer>,
) { ) {
if current_level.0.is_none() { if current_level.0.is_none() {
current_level.0 = Some(first_level.0); current_level.0 = Some(first_level.0);
} }
crate::levels::setup_level(&mut level_startup_event, &mut camera_query); crate::levels::setup_level(&mut level_startup_event, &mut camera_query, &mut zoom_timer);
} }
pub fn spawn_characters<I: IntoIterator<Item = (Transform, Color)>>( pub fn spawn_characters<I: IntoIterator<Item = (Transform, Color)>>(
commands: &mut Commands, commands: &mut Commands,
character_meshes: &Res<CharacterMeshes>, character_meshes: &Res<CharacterMeshes>,
materials: &mut ResMut<Assets<ColorMaterial>>, materials: &mut ResMut<Assets<ColorMaterial>>,
audio: &Res<crossbeam_channel::Sender<AudioMsg>>,
character_list: &mut ResMut<CharacterList>, character_list: &mut ResMut<CharacterList>,
characters: I, characters: I,
@ -166,7 +160,6 @@ pub fn spawn_characters<I: IntoIterator<Item = (Transform, Color)>>(
commands, commands,
character_meshes, character_meshes,
materials, materials,
audio,
character_list, character_list,
transform, transform,
color, color,
@ -179,7 +172,6 @@ pub fn spawn_character(
commands: &mut Commands, commands: &mut Commands,
character_meshes: &Res<CharacterMeshes>, character_meshes: &Res<CharacterMeshes>,
materials: &mut ResMut<Assets<ColorMaterial>>, materials: &mut ResMut<Assets<ColorMaterial>>,
audio: &Res<crossbeam_channel::Sender<AudioMsg>>,
character_list: &mut ResMut<CharacterList>, character_list: &mut ResMut<CharacterList>,
mut transform: Transform, mut transform: Transform,
color: Color, color: Color,
@ -224,9 +216,6 @@ pub fn spawn_character(
if is_player { if is_player {
entity_commands.insert(Player); entity_commands.insert(Player);
audio
.send(AudioMsg::Color([color.r(), color.g(), color.b()]))
.ok();
} }
} }
@ -305,8 +294,9 @@ fn char_char_collision_event_system(
mut character_list: ResMut<CharacterList>, mut character_list: ResMut<CharacterList>,
mut app_state: ResMut<State<AppState>>, mut app_state: ResMut<State<AppState>>,
character_meshes: Res<CharacterMeshes>, character_meshes: Res<CharacterMeshes>,
audio: Res<crossbeam_channel::Sender<AudioMsg>>,
mut materials: ResMut<Assets<ColorMaterial>>, mut materials: ResMut<Assets<ColorMaterial>>,
audio_assets: Res<audio_system::AudioAssets>,
audio: Res<Audio>,
) { ) {
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 {
@ -333,7 +323,6 @@ fn char_char_collision_event_system(
&mut commands, &mut commands,
&character_meshes, &character_meshes,
&mut materials, &mut materials,
&audio,
&mut character_list, &mut character_list,
if c1_player.is_some() { if c1_player.is_some() {
*c1_transform *c1_transform
@ -348,7 +337,7 @@ fn char_char_collision_event_system(
c1_player.is_some() || c2_player.is_some(), c1_player.is_some() || c2_player.is_some(),
); );
audio.send(AudioMsg::Fusion).ok(); audio_system::play_audio(&audio_assets.warp_notes, &audio, new_color, 1.0);
} }
} }
} }
@ -405,7 +394,6 @@ fn collision_event_system(
)>, )>,
pass_through_filter_query: Query<&PassThroughFilter>, pass_through_filter_query: Query<&PassThroughFilter>,
melty_query: Query<&Melty>, melty_query: Query<&Melty>,
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 {
@ -424,25 +412,14 @@ fn collision_event_system(
} }
} }
} else if *flags == CollisionEventFlags::SENSOR { } else if *flags == CollisionEventFlags::SENSOR {
if let (Ok((mut c_color, _c_transform, mut c_material, c_player)), Ok(filter)) = ( if let (Ok((mut c_color, _c_transform, mut c_material, _c_player)), Ok(filter)) = (
character_query.get_mut(*e1), character_query.get_mut(*e1),
pass_through_filter_query.get(*e2), pass_through_filter_query.get(*e2),
) { ) {
c_color.0 = filter.apply(c_color.0); c_color.0 = filter.apply(c_color.0);
*c_material = materials.add(ColorMaterial::from(c_color.0)); *c_material = materials.add(ColorMaterial::from(c_color.0));
if c_player.is_some() {
audio
.send(AudioMsg::Color([
c_color.0.r(),
c_color.0.g(),
c_color.0.b(),
]))
.ok();
audio.send(AudioMsg::Switch).ok();
}
} else if let ( } else if let (
Ok((mut c_color, _c_transform, mut c_material, c_player)), Ok((mut c_color, _c_transform, mut c_material, _c_player)),
Ok(filter), Ok(filter),
) = ( ) = (
character_query.get_mut(*e2), character_query.get_mut(*e2),
@ -450,17 +427,6 @@ fn collision_event_system(
) { ) {
c_color.0 = filter.apply(c_color.0); c_color.0 = filter.apply(c_color.0);
*c_material = materials.add(ColorMaterial::from(c_color.0)); *c_material = materials.add(ColorMaterial::from(c_color.0));
if c_player.is_some() {
audio
.send(AudioMsg::Color([
c_color.0.r(),
c_color.0.g(),
c_color.0.b(),
]))
.ok();
audio.send(AudioMsg::Switch).ok();
}
} }
} }
} }
@ -472,8 +438,9 @@ fn change_character_system(
keyboard_input: Res<Input<KeyCode>>, keyboard_input: Res<Input<KeyCode>>,
characters: Query<(Entity, &CharacterColor, Option<&Player>)>, characters: Query<(Entity, &CharacterColor, Option<&Player>)>,
audio: Res<crossbeam_channel::Sender<AudioMsg>>,
character_list: Res<CharacterList>, character_list: Res<CharacterList>,
audio_assets: Res<audio_system::AudioAssets>,
audio: Res<Audio>,
) { ) {
if !keyboard_input.just_pressed(KeyCode::Tab) { if !keyboard_input.just_pressed(KeyCode::Tab) {
return; return;
@ -493,10 +460,7 @@ fn change_character_system(
{ {
commands.entity(*new_player_entity).insert(Player); commands.entity(*new_player_entity).insert(Player);
if let Ok((_entity, color, _player)) = characters.get(*new_player_entity) { if let Ok((_entity, color, _player)) = characters.get(*new_player_entity) {
audio audio_system::play_audio(&audio_assets.reverb_notes, &audio, color.0.into(), 1.0);
.send(AudioMsg::Color([color.0.r(), color.0.g(), color.0.b()]))
.ok();
audio.send(AudioMsg::Switch).ok();
} }
} }
} }
@ -504,22 +468,23 @@ fn change_character_system(
fn player_movement_system( fn player_movement_system(
keyboard_input: Res<Input<KeyCode>>, keyboard_input: Res<Input<KeyCode>>,
mut characters: Query<(&mut Velocity, &Children), With<Player>>, mut characters: Query<(&mut Velocity, &Children, &CharacterColor), With<Player>>,
mut platform_count_query: Query<&mut PlatformCount>, mut platform_count_query: Query<&mut PlatformCount>,
audio: Res<crossbeam_channel::Sender<AudioMsg>>, audio_assets: Res<audio_system::AudioAssets>,
audio: Res<Audio>,
) { ) {
let right_pressed: bool = let right_pressed: bool =
keyboard_input.pressed(KeyCode::Right) || keyboard_input.pressed(KeyCode::D); keyboard_input.pressed(KeyCode::Right) || keyboard_input.pressed(KeyCode::D);
let left_pressed: bool = let left_pressed: bool =
keyboard_input.pressed(KeyCode::Left) || keyboard_input.pressed(KeyCode::A); keyboard_input.pressed(KeyCode::Left) || keyboard_input.pressed(KeyCode::A);
for (mut velocity, children) in characters.iter_mut() { for (mut velocity, children, color) in characters.iter_mut() {
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;
let mut platform_count: Mut<PlatformCount> = let mut platform_count: Mut<PlatformCount> =
platform_count_query.get_mut(children[0]).unwrap(); platform_count_query.get_mut(children[0]).unwrap();
if keyboard_input.just_pressed(KeyCode::Space) && platform_count.is_landed() { if keyboard_input.just_pressed(KeyCode::Space) && platform_count.is_landed() {
audio.send(AudioMsg::Jump).ok(); audio_system::play_audio(&audio_assets.notes, &audio, color.0.into(), 0.5);
velocity.linvel.y = 700.; velocity.linvel.y = 700.;
platform_count.reset(); platform_count.reset();
} }
@ -575,16 +540,22 @@ fn win_setup(
.insert(WinText); .insert(WinText);
} }
fn move_camera( fn camera_system(
mut camera_query: Query<(&Camera, &mut Transform)>, mut camera_query: Query<(&Camera, &mut OrthographicProjection, &mut Transform)>,
characters: Query<&Transform, (Without<Camera>, With<Player>)>, characters: Query<&Transform, (Without<Camera>, With<Player>)>,
time: Res<Time>, time: Res<Time>,
mut zoom_timer: ResMut<levels::ZoomTimer>,
) { ) {
fn lerp(x: f32, y: f32, t: f32) -> f32 {
((y - x) * t) + x
}
const MARGIN: f32 = 300.0; const MARGIN: f32 = 300.0;
const FOLLOW_SPEED: f32 = std::f32::consts::PI; const FOLLOW_SPEED: f32 = std::f32::consts::PI;
const ZOOM_SPEED: f32 = std::f32::consts::E;
for character_transform in characters.iter() { for character_transform in characters.iter() {
let (camera, mut camera_transform) = camera_query.single_mut(); let (camera, mut projection, mut camera_transform) = camera_query.single_mut();
let size: Vec2 = camera.logical_viewport_size().unwrap(); let size: Vec2 = camera.logical_viewport_size().unwrap();
let half_height: f32 = size.y * 0.5; let half_height: f32 = size.y * 0.5;
@ -596,6 +567,14 @@ fn move_camera(
.translation .translation
.lerp(target_translation, time.delta_seconds() * FOLLOW_SPEED); .lerp(target_translation, time.delta_seconds() * FOLLOW_SPEED);
if zoom_timer.0.finished() {
projection.scale = lerp(projection.scale, 1.0, time.delta_seconds() * ZOOM_SPEED);
} else {
projection.scale = 3.0;
camera_transform.translation = Vec3::ZERO;
zoom_timer.0.tick(time.delta());
}
// always make sure that camera is away from the object in order to render them // always make sure that camera is away from the object in order to render them
camera_transform.translation.z = 999.0; camera_transform.translation.z = 999.0;
} }
@ -621,6 +600,7 @@ fn level_keyboard_system(
mut character_list: ResMut<CharacterList>, mut character_list: ResMut<CharacterList>,
level_query: Query<Entity, With<Level>>, level_query: Query<Entity, With<Level>>,
mut app_state: ResMut<State<AppState>>, mut app_state: ResMut<State<AppState>>,
mut zoom_timer: ResMut<levels::ZoomTimer>,
) { ) {
if app_state.current() == &AppState::Win && keyboard_input.just_pressed(KeyCode::Return) { if app_state.current() == &AppState::Win && keyboard_input.just_pressed(KeyCode::Return) {
current_level.0 = Some(LevelId( current_level.0 = Some(LevelId(
@ -635,7 +615,11 @@ fn level_keyboard_system(
commands.entity(entity).despawn_recursive(); commands.entity(entity).despawn_recursive();
} }
if app_state.replace(AppState::Game).is_err() { if app_state.replace(AppState::Game).is_err() {
crate::levels::setup_level(&mut level_startup_event, &mut camera_query); crate::levels::setup_level(
&mut level_startup_event,
&mut camera_query,
&mut zoom_timer,
);
} }
} }
} }

View file

@ -1,5 +1,7 @@
#![allow(clippy::too_many_arguments)] #![allow(clippy::too_many_arguments)]
use std::time::Duration;
pub use stored::*; pub use stored::*;
use crate::game::*; use crate::game::*;
@ -7,11 +9,24 @@ use crate::game::*;
use bevy::{prelude::*, reflect::TypeUuid}; use bevy::{prelude::*, reflect::TypeUuid};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[derive(Component)]
pub struct ZoomTimer(pub Timer);
impl Default for ZoomTimer {
fn default() -> Self {
Self(Timer::new(Duration::new(2, 0), false))
}
}
pub fn setup_level( pub fn setup_level(
level_startup_event: &mut EventWriter<LevelStartupEvent>, level_startup_event: &mut EventWriter<LevelStartupEvent>,
camera_query: &mut Query<&mut Transform, With<Camera>>, camera_query: &mut Query<&mut Transform, With<Camera>>,
zoom_timer: &mut ResMut<ZoomTimer>,
) { ) {
camera_query.single_mut().translation = Default::default(); let mut transform = camera_query.single_mut();
transform.translation = Default::default();
zoom_timer.0.reset();
level_startup_event.send(LevelStartupEvent); level_startup_event.send(LevelStartupEvent);
} }
@ -36,7 +51,6 @@ pub fn post_setup_level(
current_level: Res<CurrentLevel>, current_level: Res<CurrentLevel>,
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>>,
mut character_list: ResMut<CharacterList>, mut character_list: ResMut<CharacterList>,
stored_levels_assets: Res<Assets<StoredLevels>>, stored_levels_assets: Res<Assets<StoredLevels>>,
stored_levels_handle: Res<Handle<StoredLevels>>, stored_levels_handle: Res<Handle<StoredLevels>>,
@ -55,7 +69,6 @@ pub fn post_setup_level(
&mut meshes, &mut meshes,
&mut materials, &mut materials,
&asset_server, &asset_server,
&audio,
&mut character_list, &mut character_list,
stored_level, stored_level,
); );
@ -70,7 +83,6 @@ pub fn spawn_stored_level(
meshes: &mut ResMut<Assets<Mesh>>, meshes: &mut ResMut<Assets<Mesh>>,
materials: &mut ResMut<Assets<ColorMaterial>>, materials: &mut ResMut<Assets<ColorMaterial>>,
asset_server: &Res<AssetServer>, asset_server: &Res<AssetServer>,
audio: &Res<crossbeam_channel::Sender<AudioMsg>>,
character_list: &mut ResMut<CharacterList>, character_list: &mut ResMut<CharacterList>,
stored_level: &StoredLevel, stored_level: &StoredLevel,
@ -91,7 +103,6 @@ pub fn spawn_stored_level(
commands, commands,
character_meshes, character_meshes,
materials, materials,
audio,
character_list, character_list,
stored_level.characters.iter().map(|character| { stored_level.characters.iter().map(|character| {
( (

View file

@ -1,9 +1,9 @@
#![allow(clippy::too_many_arguments)] #![allow(clippy::too_many_arguments)]
#[cfg(not(target_arch = "wasm32"))]
mod audio;
#[cfg(not(target_arch = "wasm32"))] #[cfg(not(target_arch = "wasm32"))]
mod editor; mod editor;
mod audio_system;
mod filters; mod filters;
mod game; mod game;
mod levels; mod levels;
@ -39,12 +39,6 @@ impl LoadingAssets {
} }
fn main() { fn main() {
let (audio_event_sender, audio_event_receiver) =
crossbeam_channel::bounded::<game::AudioMsg>(512);
#[cfg(not(target_arch = "wasm32"))]
std::thread::spawn(move || audio::setup(audio_event_receiver));
#[cfg(not(target_arch = "wasm32"))] #[cfg(not(target_arch = "wasm32"))]
let (first_level, use_editor) = { let (first_level, use_editor) = {
let mut args = std::env::args().skip(1); let mut args = std::env::args().skip(1);
@ -71,14 +65,14 @@ fn main() {
title: "Lux synthesĕ".into(), title: "Lux synthesĕ".into(),
..Default::default() ..Default::default()
}) })
.insert_resource(audio_event_sender)
.insert_resource(UseEditor(use_editor)) .insert_resource(UseEditor(use_editor))
.add_state(AppState::Loading) .add_state(AppState::Loading)
.insert_resource(game::FirstLevel(first_level)) .insert_resource(game::FirstLevel(first_level))
.insert_resource(ClearColor(Color::BLACK)) .insert_resource(ClearColor(Color::BLACK))
.add_plugins(DefaultPlugins) .add_plugins(DefaultPlugins)
.add_plugin(audio_system::AudioSystemPlugin)
//.add_plugin(RapierDebugRenderPlugin::default()) //.add_plugin(RapierDebugRenderPlugin::default())
//.add_plugin(bevy_inspector_egui::WorldInspectorPlugin::new()) // .add_plugin(bevy_inspector_egui::WorldInspectorPlugin::new())
.add_plugin(JsonAssetPlugin::<levels::StoredLevels>::new(&[ .add_plugin(JsonAssetPlugin::<levels::StoredLevels>::new(&[
"levels.json", "levels.json",
])); ]));

View file

@ -20,22 +20,6 @@ impl Plugin for MenuPlugin {
fn setup(mut commands: Commands, asset_server: Res<AssetServer>) { fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
let font = asset_server.get_handle("UacariLegacy-Thin.ttf"); let font = asset_server.get_handle("UacariLegacy-Thin.ttf");
#[cfg(target_arch = "wasm32")]
commands
.spawn_bundle(Text2dBundle {
text: Text::from_section(
"Note:\nAudio is NOT available in the WASM build.",
TextStyle {
font: font.clone(),
font_size: 24.0,
color: Color::rgba(1., 0.4, 0.4, 1.),
},
)
.with_alignment(TextAlignment::CENTER),
transform: Transform::from_xyz(0., -128.0, 0.),
..Default::default()
})
.insert(Menu);
commands commands
.spawn_bundle(Text2dBundle { .spawn_bundle(Text2dBundle {
text: Text::from_section( text: Text::from_section(