Compare commits

..

No commits in common. "master" and "wasm" have entirely different histories.
master ... wasm

22 changed files with 4489 additions and 3389 deletions

532
Cargo.lock generated
View file

@ -89,15 +89,9 @@ checksum = "94a45b455c14666b85fc40a019e8ab9eb75e3a124e05494f5397122bc9eb06e0"
[[package]]
name = "autocfg"
version = "1.1.0"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
[[package]]
name = "base-x"
version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4cbbc9d0964165b47557570cce6c952866c2678457aca742aafc9fb771d30270"
checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
[[package]]
name = "bindgen"
@ -145,7 +139,7 @@ version = "0.8.2"
source = "git+https://github.com/amethyst/bracket-lib#cf8eec60ae17f2534a14f3ae643c871202aed192"
dependencies = [
"lazy_static",
"parking_lot 0.11.2",
"parking_lot",
]
[[package]]
@ -154,7 +148,7 @@ version = "0.8.0"
source = "git+https://github.com/amethyst/bracket-lib#cf8eec60ae17f2534a14f3ae643c871202aed192"
dependencies = [
"lazy_static",
"parking_lot 0.11.2",
"parking_lot",
]
[[package]]
@ -239,7 +233,7 @@ dependencies = [
"image",
"lazy_static",
"object-pool",
"parking_lot 0.11.2",
"parking_lot",
"rand",
"spin_sleep",
"ultraviolet",
@ -349,7 +343,7 @@ dependencies = [
"bitflags",
"block",
"cocoa-foundation",
"core-foundation 0.9.3",
"core-foundation 0.9.2",
"core-graphics 0.22.3",
"foreign-types",
"libc",
@ -364,7 +358,7 @@ checksum = "7ade49b65d560ca58c403a479bb396592b155c0185eada742ee323d1d68d6318"
dependencies = [
"bitflags",
"block",
"core-foundation 0.9.3",
"core-foundation 0.9.2",
"core-graphics-types",
"foreign-types",
"libc",
@ -409,9 +403,9 @@ dependencies = [
[[package]]
name = "core-foundation"
version = "0.9.3"
version = "0.9.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146"
checksum = "6888e10551bb93e424d8df1d07f1a8b4fceb0001a3a4b048bfc47554946f47b3"
dependencies = [
"core-foundation-sys 0.8.3",
"libc",
@ -448,7 +442,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2581bbab3b8ffc6fcbd550bf46c355135d16e9ff2a6ea032ad6b9bf1d7efe4fb"
dependencies = [
"bitflags",
"core-foundation 0.9.3",
"core-foundation 0.9.2",
"core-graphics-types",
"foreign-types",
"libc",
@ -461,7 +455,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3a68b68b3446082644c91ac778bf50cd4104bfb002b5a6a7c44cca5a2c70788b"
dependencies = [
"bitflags",
"core-foundation 0.9.3",
"core-foundation 0.9.2",
"foreign-types",
"libc",
]
@ -500,35 +494,35 @@ dependencies = [
[[package]]
name = "cpal"
version = "0.14.1"
version = "0.13.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e73413ddcb69c398125f5529714492e070c64c6a090ad5b01d8c082b320a0809"
checksum = "74117836a5124f3629e4b474eed03e479abaf98988b4bb317e29f08cfe0e4116"
dependencies = [
"alsa",
"core-foundation-sys 0.8.3",
"coreaudio-rs",
"jni",
"js-sys",
"lazy_static",
"libc",
"mach",
"ndk 0.7.0",
"ndk-context",
"nix 0.25.0",
"ndk 0.6.0",
"ndk-glue 0.6.0",
"nix 0.23.1",
"oboe",
"once_cell",
"parking_lot 0.12.1",
"parking_lot",
"stdweb",
"thiserror",
"wasm-bindgen",
"web-sys",
"windows",
"winapi 0.3.9",
]
[[package]]
name = "crc32fast"
version = "1.3.2"
version = "1.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d"
checksum = "a2209c310e29876f7f0b2721e7e26b84aff178aa3da5d091f9bfbf47669e60e3"
dependencies = [
"cfg-if 1.0.0",
]
@ -544,7 +538,7 @@ dependencies = [
"crossbeam-deque",
"crossbeam-epoch",
"crossbeam-queue",
"crossbeam-utils 0.8.7",
"crossbeam-utils 0.8.6",
]
[[package]]
@ -554,7 +548,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e54ea8bc3fb1ee042f5aace6e3c6e025d3874866da222930f70ce62aceba0bfa"
dependencies = [
"cfg-if 1.0.0",
"crossbeam-utils 0.8.7",
"crossbeam-utils 0.8.6",
]
[[package]]
@ -565,17 +559,17 @@ checksum = "6455c0ca19f0d2fbf751b908d5c55c1f5cbc65e03c4225427254b46890bdde1e"
dependencies = [
"cfg-if 1.0.0",
"crossbeam-epoch",
"crossbeam-utils 0.8.7",
"crossbeam-utils 0.8.6",
]
[[package]]
name = "crossbeam-epoch"
version = "0.9.7"
version = "0.9.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c00d6d2ea26e8b151d99093005cb442fb9a37aeaca582a03ec70946f49ab5ed9"
checksum = "97242a70df9b89a65d0b6df3c4bf5b9ce03c5b7309019777fbde37e7537f8762"
dependencies = [
"cfg-if 1.0.0",
"crossbeam-utils 0.8.7",
"crossbeam-utils 0.8.6",
"lazy_static",
"memoffset",
"scopeguard",
@ -583,12 +577,12 @@ dependencies = [
[[package]]
name = "crossbeam-queue"
version = "0.3.4"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4dd435b205a4842da59efd07628f921c096bc1cc0a156835b4fa0bcb9a19bcce"
checksum = "b979d76c9fcb84dffc80a73f7290da0f83e4c95773494674cb44b76d13a7a110"
dependencies = [
"cfg-if 1.0.0",
"crossbeam-utils 0.8.7",
"crossbeam-utils 0.8.6",
]
[[package]]
@ -604,9 +598,9 @@ dependencies = [
[[package]]
name = "crossbeam-utils"
version = "0.8.7"
version = "0.8.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b5e5bed1f1c269533fa816a0a5492b3545209a205ca1a54842be180eb63a16a6"
checksum = "cfcae03edb34f947e64acdb1c33ec169824e20657e9ecb61cef6c8c74dcb8120"
dependencies = [
"cfg-if 1.0.0",
"lazy_static",
@ -729,12 +723,6 @@ dependencies = [
"winapi 0.3.9",
]
[[package]]
name = "discard"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "212d0f5754cb6769937f4501cc0e67f4f4483c8d2c3e1e922ee9edbe4ab4c7c0"
[[package]]
name = "dispatch"
version = "0.2.0"
@ -814,12 +802,37 @@ version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7"
[[package]]
name = "fundsp"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "914385c9ea3226815d12f436c2c60b2e6f88a89af684ed9e24d62e55f1b0dba1"
dependencies = [
"generic-array",
"lazy_static",
"num-complex",
"numeric-array",
"rsor",
"rustfft",
"tinyvec",
]
[[package]]
name = "futures"
version = "0.1.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3a471a38ef8ed83cd6e40aa59c1ffe17db6855c18e3604d9c4ed8c08ebc28678"
[[package]]
name = "generic-array"
version = "0.14.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fd48d33ec7f05fbfa152300fdad764757cbded343c1aa1cff2fbaf4134851803"
dependencies = [
"typenum",
"version_check",
]
[[package]]
name = "getrandom"
version = "0.2.4"
@ -827,10 +840,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "418d37c8b1d42553c93648be529cb70f920d3baf8ef469b74b9638df426e0b4c"
dependencies = [
"cfg-if 1.0.0",
"js-sys",
"libc",
"wasi",
"wasm-bindgen",
]
[[package]]
@ -871,7 +882,7 @@ dependencies = [
"android_glue",
"cgl",
"cocoa",
"core-foundation 0.9.3",
"core-foundation 0.9.2",
"glutin_egl_sys",
"glutin_emscripten_sys",
"glutin_gles2_sys",
@ -882,7 +893,7 @@ dependencies = [
"log",
"objc",
"osmesa-sys",
"parking_lot 0.11.2",
"parking_lot",
"wayland-client",
"wayland-egl",
"winapi 0.3.9",
@ -936,21 +947,20 @@ dependencies = [
[[package]]
name = "hashbrown"
version = "0.12.3"
version = "0.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e"
dependencies = [
"ahash",
]
[[package]]
name = "hecs"
version = "0.9.0"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "11b81e962a0576ee276c1e6cbdce16bed83c7357ce8ff4e9efc8f49e43d2d1a1"
checksum = "ddd0e227c3f78ad06fcc590966b327a2f8fef03ef51812dad4fbff5b0a6424bd"
dependencies = [
"hashbrown",
"spin",
]
[[package]]
@ -996,12 +1006,6 @@ dependencies = [
"libc",
]
[[package]]
name = "itoa"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4217ad341ebadf8d8e724e264f13e593e0648f5b3e94b3896a5df283be015ecc"
[[package]]
name = "jni"
version = "0.19.0"
@ -1069,11 +1073,10 @@ dependencies = [
"bracket-lib",
"console_error_panic_hook",
"cpal",
"getrandom",
"fundsp",
"hecs",
"instant",
"oddio",
"rand",
"specs-derive",
"typenum",
"wasm-bindgen",
@ -1094,9 +1097,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
[[package]]
name = "libc"
version = "0.2.137"
version = "0.2.117"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc7fcc620a3bff7cdd7a365be3376c97191aeaccc2a603e600951e452615bf89"
checksum = "e74d72e0f9b65b5b4ca49a346af3976df0f9c61d550727f349ecd559f251a26c"
[[package]]
name = "libloading"
@ -1323,26 +1326,6 @@ dependencies = [
"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.1+23.1.7779620",
"num_enum 0.5.6",
"raw-window-handle 0.5.0",
"thiserror",
]
[[package]]
name = "ndk-context"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "27b02d87554356db9e9a873add8782d4ea6e3e58ea071a9adb9a2e8ddb884a8b"
[[package]]
name = "ndk-glue"
version = "0.2.1"
@ -1426,15 +1409,6 @@ dependencies = [
"jni-sys",
]
[[package]]
name = "ndk-sys"
version = "0.4.1+23.1.7779620"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3cf2aae958bd232cac5069850591667ad422d263686d75b52a065f9badeee5a3"
dependencies = [
"jni-sys",
]
[[package]]
name = "net2"
version = "0.2.37"
@ -1483,20 +1457,6 @@ dependencies = [
"memoffset",
]
[[package]]
name = "nix"
version = "0.25.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e322c04a9e3440c327fca7b6c8a63e6890a32fa2ad689db972425f07e0d22abb"
dependencies = [
"autocfg",
"bitflags",
"cfg-if 1.0.0",
"libc",
"memoffset",
"pin-utils",
]
[[package]]
name = "nom"
version = "5.1.2"
@ -1527,6 +1487,15 @@ dependencies = [
"winapi 0.3.9",
]
[[package]]
name = "num-complex"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "26873667bbbb7c5182d4a37c1add32cdf09f841af72da53318fdb81543c15085"
dependencies = [
"num-traits",
]
[[package]]
name = "num-derive"
version = "0.3.3"
@ -1633,6 +1602,16 @@ dependencies = [
"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]]
name = "objc"
version = "0.2.7"
@ -1648,7 +1627,7 @@ version = "0.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ee9a3e7196d09ec86002b939f1576e8e446d58def8fd48fe578e2c72d5328d68"
dependencies = [
"parking_lot 0.11.2",
"parking_lot",
]
[[package]]
@ -1676,18 +1655,18 @@ dependencies = [
[[package]]
name = "oddio"
version = "0.6.2"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f0f3379cc7e854d0b0d4a0e310f276faafc46896843b720efe4646faa1b0c734"
checksum = "33f6d5a128f26322b02ba2741cbdc9f14f1431e757db3b15fd893d5c416f3e20"
dependencies = [
"mint",
]
[[package]]
name = "once_cell"
version = "1.16.0"
version = "1.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "86f0b0d4bf799edbc74508c1e8bf170ff5f41238e5f8225603ca7caaae2b7860"
checksum = "da32515d9f6e6e489d7bc9d84c71b060db7247dc035bbe44eac88cf87486d8d5"
[[package]]
name = "osmesa-sys"
@ -1715,17 +1694,7 @@ checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99"
dependencies = [
"instant",
"lock_api",
"parking_lot_core 0.8.5",
]
[[package]]
name = "parking_lot"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f"
dependencies = [
"lock_api",
"parking_lot_core 0.9.4",
"parking_lot_core",
]
[[package]]
@ -1742,19 +1711,6 @@ dependencies = [
"winapi 0.3.9",
]
[[package]]
name = "parking_lot_core"
version = "0.9.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4dc9e0dc2adc1c69d09143aff38d3d30c5c3f0df0dad82e6d25547af174ebec0"
dependencies = [
"cfg-if 1.0.0",
"libc",
"redox_syscall",
"smallvec",
"windows-sys",
]
[[package]]
name = "peeking_take_while"
version = "0.1.2"
@ -1767,12 +1723,6 @@ version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e"
[[package]]
name = "pin-utils"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
[[package]]
name = "pkg-config"
version = "0.3.24"
@ -1792,10 +1742,13 @@ dependencies = [
]
[[package]]
name = "ppv-lite86"
version = "0.2.17"
name = "primal-check"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de"
checksum = "01419cee72c1a1ca944554e23d83e483e1bccf378753344e881de28b5487511d"
dependencies = [
"num-integer",
]
[[package]]
name = "proc-macro-crate"
@ -1836,22 +1789,10 @@ dependencies = [
[[package]]
name = "rand"
version = "0.8.5"
version = "0.8.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
checksum = "2e7573632e6454cf6b99d7aac4ccca54be06da05aca2ef7423d22d27d4d4bcd8"
dependencies = [
"libc",
"rand_chacha",
"rand_core",
]
[[package]]
name = "rand_chacha"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"
dependencies = [
"ppv-lite86",
"rand_core",
]
@ -1860,9 +1801,6 @@ name = "rand_core"
version = "0.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7"
dependencies = [
"getrandom",
]
[[package]]
name = "rand_xorshift"
@ -1892,15 +1830,6 @@ dependencies = [
"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]]
name = "redox_syscall"
version = "0.2.10"
@ -1937,6 +1866,12 @@ version = "0.6.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b"
[[package]]
name = "rsor"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4b57e3964dc31a38416366d2e8f7675755402a10832d5cf4e4112d66ac77cdda"
[[package]]
name = "rustc-hash"
version = "1.1.0"
@ -1944,12 +1879,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
[[package]]
name = "rustc_version"
version = "0.2.3"
name = "rustfft"
version = "6.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
checksum = "b1d089e5c57521629a59f5f39bca7434849ff89bd6873b521afe389c1c602543"
dependencies = [
"semver",
"num-complex",
"num-integer",
"num-traits",
"primal-check",
"strength_reduce",
"transpose",
]
[[package]]
@ -1962,12 +1902,6 @@ dependencies = [
"owned_ttf_parser",
]
[[package]]
name = "ryu"
version = "1.0.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09"
[[package]]
name = "safe_arch"
version = "0.5.2"
@ -1998,21 +1932,6 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
[[package]]
name = "semver"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403"
dependencies = [
"semver-parser",
]
[[package]]
name = "semver-parser"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
[[package]]
name = "send_wrapper"
version = "0.2.0"
@ -2025,43 +1944,6 @@ version = "1.0.136"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ce31e24b01e1e524df96f1c2fdd054405f8d7376249a5110886fb4b658484789"
[[package]]
name = "serde_derive"
version = "1.0.136"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08597e7152fcd306f41838ed3e37be9eaeed2b61c42e2117266a554fab4662f9"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "serde_json"
version = "1.0.89"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "020ff22c755c2ed3f8cf162dbb41a7268d934702f3ed3631656ea597e08fc3db"
dependencies = [
"itoa",
"ryu",
"serde",
]
[[package]]
name = "sha1"
version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c1da05c97445caa12d05e848c4a4fcbbea29e748ac28f7e80e9b010392063770"
dependencies = [
"sha1_smol",
]
[[package]]
name = "sha1_smol"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ae1a47186c03a32177042e55dbc5fd5aee900b8e0069a8d70fba96a9375cd012"
[[package]]
name = "shared_library"
version = "0.1.9"
@ -2129,12 +2011,6 @@ dependencies = [
"syn",
]
[[package]]
name = "spin"
version = "0.9.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f6002a767bff9e83f8eeecf883ecb8011875a21ae8da43bffb817a57e78cc09"
[[package]]
name = "spin_sleep"
version = "1.0.0"
@ -2147,52 +2023,15 @@ dependencies = [
[[package]]
name = "stdweb"
version = "0.4.20"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d022496b16281348b52d0e30ae99e01a73d737b2f45d38fed4edf79f9325a1d5"
dependencies = [
"discard",
"rustc_version",
"stdweb-derive",
"stdweb-internal-macros",
"stdweb-internal-runtime",
"wasm-bindgen",
]
checksum = "ef5430c8e36b713e13b48a9f709cc21e046723fe44ce34587b73a830203b533e"
[[package]]
name = "stdweb-derive"
version = "0.5.3"
name = "strength_reduce"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c87a60a40fccc84bef0652345bbbbbe20a605bf5d0ce81719fc476f5c03b50ef"
dependencies = [
"proc-macro2",
"quote",
"serde",
"serde_derive",
"syn",
]
[[package]]
name = "stdweb-internal-macros"
version = "0.2.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "58fa5ff6ad0d98d1ffa8cb115892b6e69d67799f6763e162a1c9db421dc22e11"
dependencies = [
"base-x",
"proc-macro2",
"quote",
"serde",
"serde_derive",
"serde_json",
"sha1",
"syn",
]
[[package]]
name = "stdweb-internal-runtime"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "213701ba3370744dcd1a12960caa4843b3d68b4d1c0a5d575e0d65b2ee9d16c0"
checksum = "a3ff2f71c82567c565ba4b3009a9350a96a7269eaa4001ebedae926230bc2254"
[[package]]
name = "strsim"
@ -2237,6 +2076,21 @@ dependencies = [
"syn",
]
[[package]]
name = "tinyvec"
version = "1.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2c1c1d5a42b6245520c249549ec267180beaffcc0615401ac8e31853d4b6d8d2"
dependencies = [
"tinyvec_macros",
]
[[package]]
name = "tinyvec_macros"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c"
[[package]]
name = "tokio-executor"
version = "0.1.10"
@ -2268,6 +2122,16 @@ dependencies = [
"serde",
]
[[package]]
name = "transpose"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "95f9c900aa98b6ea43aee227fd680550cdec726526aab8ac801549eadb25e39f"
dependencies = [
"num-integer",
"strength_reduce",
]
[[package]]
name = "ttf-parser"
version = "0.6.2"
@ -2532,106 +2396,6 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
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]]
name = "windows-sys"
version = "0.42.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7"
dependencies = [
"windows_aarch64_gnullvm",
"windows_aarch64_msvc 0.42.0",
"windows_i686_gnu 0.42.0",
"windows_i686_msvc 0.42.0",
"windows_x86_64_gnu 0.42.0",
"windows_x86_64_gnullvm",
"windows_x86_64_msvc 0.42.0",
]
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.42.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "41d2aa71f6f0cbe00ae5167d90ef3cfe66527d6f613ca78ac8024c3ccab9a19e"
[[package]]
name = "windows_aarch64_msvc"
version = "0.37.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2623277cb2d1c216ba3b578c0f3cf9cdebeddb6e66b1b218bb33596ea7769c3a"
[[package]]
name = "windows_aarch64_msvc"
version = "0.42.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd0f252f5a35cac83d6311b2e795981f5ee6e67eb1f9a7f64eb4500fbc4dcdb4"
[[package]]
name = "windows_i686_gnu"
version = "0.37.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d3925fd0b0b804730d44d4b6278c50f9699703ec49bcd628020f46f4ba07d9e1"
[[package]]
name = "windows_i686_gnu"
version = "0.42.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fbeae19f6716841636c28d695375df17562ca208b2b7d0dc47635a50ae6c5de7"
[[package]]
name = "windows_i686_msvc"
version = "0.37.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ce907ac74fe331b524c1298683efbf598bb031bc84d5e274db2083696d07c57c"
[[package]]
name = "windows_i686_msvc"
version = "0.42.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "84c12f65daa39dd2babe6e442988fc329d6243fdce47d7d2d155b8d874862246"
[[package]]
name = "windows_x86_64_gnu"
version = "0.37.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2babfba0828f2e6b32457d5341427dcbb577ceef556273229959ac23a10af33d"
[[package]]
name = "windows_x86_64_gnu"
version = "0.42.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bf7b1b21b5362cbc318f686150e5bcea75ecedc74dd157d874d754a2ca44b0ed"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.42.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09d525d2ba30eeb3297665bd434a54297e4170c7f1a44cad4ef58095b4cd2028"
[[package]]
name = "windows_x86_64_msvc"
version = "0.37.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f4dd6dc7df2d84cf7b33822ed5b86318fb1781948e9663bacd047fc9dd52259d"
[[package]]
name = "windows_x86_64_msvc"
version = "0.42.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f40009d85759725a34da6d89a94e63d7bdc50a862acf0dbc7c8e488f1edcb6f5"
[[package]]
name = "winit"
version = "0.24.0"
@ -2640,7 +2404,7 @@ checksum = "da4eda6fce0eb84bd0a33e3c8794eb902e1033d0a1d5a31bc4f19b1b4bbff597"
dependencies = [
"bitflags",
"cocoa",
"core-foundation 0.9.3",
"core-foundation 0.9.2",
"core-graphics 0.22.3",
"core-video-sys",
"dispatch",
@ -2654,7 +2418,7 @@ dependencies = [
"ndk-glue 0.2.1",
"ndk-sys 0.2.2",
"objc",
"parking_lot 0.11.2",
"parking_lot",
"percent-encoding",
"raw-window-handle 0.3.4",
"smithay-client-toolkit",
@ -2673,7 +2437,7 @@ checksum = "79610794594d5e86be473ef7763f604f2159cbac8c94debd00df8fb41e86c2f8"
dependencies = [
"bitflags",
"cocoa",
"core-foundation 0.9.3",
"core-foundation 0.9.2",
"core-graphics 0.22.3",
"core-video-sys",
"dispatch",
@ -2687,7 +2451,7 @@ dependencies = [
"ndk-glue 0.3.0",
"ndk-sys 0.2.2",
"objc",
"parking_lot 0.11.2",
"parking_lot",
"percent-encoding",
"raw-window-handle 0.3.4",
"scopeguard",

View file

@ -15,21 +15,15 @@ path = "src/main.rs"
[dependencies]
# bracket-lib = { path = "extern/bracket-lib" }
bracket-lib = { git = "https://github.com/amethyst/bracket-lib" }
hecs = "0.9.0"
hecs = "0.5.1"
specs-derive = "0.4.1"
cpal = { version = "0.14.1", features = ["wasm-bindgen"] }
oddio = "0.6.2"
cpal = { version = "0.13.0", features = ["wasm-bindgen"] }
oddio = "0.5"
fundsp = "0.1.0"
typenum = "1.15.0"
console_error_panic_hook = "0.1.7"
wasm-bindgen = "0.2.79"
instant = "0.1.12"
rand = "0.8.5"
getrandom = { version = "0.2.4", features = ["js"] }
[target.'cfg(windows)'.build-dependencies]
winres = "0.1.12"
[profile.release]
lto = true
opt-level = 's'
winres = "0.1"

6655
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -4,15 +4,15 @@
"version": "0.1.0",
"scripts": {
"build": "rimraf dist pkg && webpack",
"start": "rimraf dist pkg && webpack-dev-server --open",
"start": "rimraf dist pkg && webpack-dev-server --open -d",
"test": "cargo test && wasm-pack test --headless"
},
"devDependencies": {
"@wasm-tool/wasm-pack-plugin": "^1.1.0",
"copy-webpack-plugin": "^11.0.0",
"rimraf": "^3.0.0",
"webpack": "^5.75.0",
"webpack-cli": "^5.0.0",
"webpack-dev-server": "^4.11.1"
"copy-webpack-plugin": "^5.0.3",
"webpack": "^4.42.0",
"webpack-cli": "^3.3.3",
"webpack-dev-server": "^3.7.1",
"rimraf": "^3.0.0"
}
}

View file

@ -13,5 +13,3 @@ pub const MAP_SIZE: usize = MAP_WIDTH * MAP_HEIGHT;
pub const MAP_X: usize = 1;
pub const MAP_Y: usize = 1;
pub const BASE_WHIP_POWER: u32 = 2;

View file

@ -1,4 +1,4 @@
use crate::constants::*;
use crate::constants::{SIDEBAR_POS_X, SIDEBAR_POS_Y};
use crate::graphics::vga_color as vga;
use crate::resources::Resources;
use bracket_lib::prelude::*;
@ -48,15 +48,7 @@ pub fn draw(resources: &Resources, bterm: &mut BTerm) {
let stats = &resources.stats;
bterm.print_centered_at(SIDEBAR_POS_X + 6, SIDEBAR_POS_Y + 1, stats.score * 10);
bterm.print_centered_at(SIDEBAR_POS_X + 6, SIDEBAR_POS_Y + 7, stats.gems);
bterm.print_centered_at(
SIDEBAR_POS_X + 6,
SIDEBAR_POS_Y + 10,
if stats.whip_power <= BASE_WHIP_POWER {
stats.whips.to_string()
} else {
format!("{}+{}", stats.whips, stats.whip_power - BASE_WHIP_POWER)
},
);
bterm.print_centered_at(SIDEBAR_POS_X + 6, SIDEBAR_POS_Y + 10, stats.whips);
bterm.print_centered_at(SIDEBAR_POS_X + 6, SIDEBAR_POS_Y + 13, stats.teleports);
bterm.print_centered_at(SIDEBAR_POS_X + 6, SIDEBAR_POS_Y + 16, stats.keys);
@ -111,22 +103,12 @@ pub fn draw(resources: &Resources, bterm: &mut BTerm) {
&format!("{}", bterm.fps),
);
let mut debug_string = format!("{}", resources.clock.ticks);
if resources.speed_time_ticks > 0 {
debug_string += " SPEED"
}
if resources.slow_time_ticks > 0 {
debug_string += " SLOW"
}
bterm.print_color(
0,
0,
RGB::named(vga::YELLOW_BRIGHT),
RGB::named(vga::BLACK),
&debug_string,
&format!("{}", resources.clock.ticks),
);
}
}

View file

@ -25,9 +25,6 @@ pub fn handle_intent(bterm: &mut BTerm, _world: &mut World, resources: &mut Reso
FlashingMessageIntent::Save => todo!(),
FlashingMessageIntent::Restore => todo!(),
FlashingMessageIntent::Restart => todo!(),
&FlashingMessageIntent::NextLevel => {
resources.should_advance_level = true;
}
}
}
}

View file

@ -2,23 +2,21 @@ use instant::Instant;
use std::time::Duration;
use bracket_lib::prelude::*;
use hecs::{Entity, Without, World};
use hecs::{Entity, With, Without, World};
use crate::{
components::monster::*,
components::*,
constants::*,
resources::{flashing_message::FlashingMessageIntent, *},
systems,
tile_data::TileType,
components::monster::*, components::*, constants::*, resources::*, systems, tile_data::TileType,
};
pub fn try_move(delta_x: i32, delta_y: i32, world: &mut World, resources: &mut Resources) {
let mut to_kill: Vec<Entity> = Vec::new();
for (player_entity, (player, pos)) in
&mut world.query::<Without<(&mut Player, &mut Position), &WantsToWhip>>()
{
for (player_entity, (player, pos)) in &mut world.query::<(&mut Player, &mut Position)>() {
// The player shouldn't be able to move while whipping
if let Ok(_wants_to_whip) = world.get::<WantsToWhip>(player_entity) {
continue;
}
let now = Instant::now();
if now - player.last_moved > Duration::from_secs_f32(PLAYER_STEP_PERIOD) {
let destination = Point {
@ -29,7 +27,7 @@ pub fn try_move(delta_x: i32, delta_y: i32, world: &mut World, resources: &mut R
if resources.map.in_bounds(destination) {
if try_step(destination, world, resources) {
if let Some(monster_entity) = resources.map.get_tile_content_at(destination) {
if let Ok(monster) = world.get::<&Monster>(monster_entity) {
if let Ok(monster) = world.get::<Monster>(monster_entity) {
resources.stats.add_score(damage_for_kind(monster.kind));
resources.stats.take_gems(damage_for_kind(monster.kind));
if let (Some(sound_effects), Some(sound_output)) =
@ -62,12 +60,6 @@ pub fn try_move(delta_x: i32, delta_y: i32, world: &mut World, resources: &mut R
} else if let (Some(sound_effects), Some(sound_output)) =
(&mut resources.sound_effects, &mut resources.sound_output)
{
if !resources.message_shown.touched_boundary {
resources.flashing_message = Some(FlashingMessage::from(
"An Electrified Wall blocks your way.",
));
resources.message_shown.touched_boundary = true;
}
let static_sound = sound_effects.get_new_static_effect(sound_output);
sound_output.play_sound(static_sound);
}
@ -86,45 +78,16 @@ fn try_step(point: Point, _world: &World, resources: &mut Resources) -> bool {
crate::tile_data::TileType::Floor
| crate::tile_data::TileType::Slow
| crate::tile_data::TileType::Medium
| crate::tile_data::TileType::Fast
| crate::tile_data::TileType::Player => true,
crate::tile_data::TileType::Block => {
| crate::tile_data::TileType::Fast => true,
crate::tile_data::TileType::Block | crate::tile_data::TileType::Wall => {
if let (Some(sound_effects), Some(sound_output)) =
(&mut resources.sound_effects, &mut resources.sound_output)
{
sound_output.play_sound(sound_effects.blocked.clone());
}
if !resources.message_shown.touched_boundary {
resources.flashing_message = Some(FlashingMessage::from(
"An Electrified Wall blocks your way.",
));
resources.message_shown.touched_boundary = true;
}
if resources.stats.score > 2 {
resources.stats.take_score(2);
}
false
}
crate::tile_data::TileType::Wall => {
if let (Some(sound_effects), Some(sound_output)) =
(&mut resources.sound_effects, &mut resources.sound_output)
{
sound_output.play_sound(sound_effects.blocked.clone());
}
if !resources.message_shown.touched_boundary {
resources.flashing_message =
Some(FlashingMessage::from("A Solid Wall blocks your way."));
resources.message_shown.touched_boundary = true;
}
if resources.stats.score > 2 {
resources.stats.take_score(2);
}
false
}
crate::tile_data::TileType::Whip => {
@ -133,62 +96,23 @@ fn try_step(point: Point, _world: &World, resources: &mut Resources) -> bool {
{
sound_output.play_sound(sound_effects.grab.clone());
}
if !resources.message_shown.whip {
resources.flashing_message = Some(FlashingMessage::from("You found a Whip."));
resources.message_shown.whip = true;
}
resources.stats.give_whips(1);
resources.stats.add_score(1);
resources.map.set_tile_at(point, TileType::Floor);
true
}
crate::tile_data::TileType::Stairs => {
if !resources.message_shown.stairs {
resources.flashing_message = Some(FlashingMessage::new(
"Stairs take you to the next lower level.",
Some(FlashingMessageIntent::NextLevel),
));
resources.message_shown.stairs = true;
} else {
resources.should_advance_level = true;
}
true
}
crate::tile_data::TileType::Chest => todo!(),
crate::tile_data::TileType::SlowTime => {
if let (Some(sound_effects), Some(sound_output)) =
(&mut resources.sound_effects, &mut resources.sound_output)
{
sound_output.play_sound(sound_effects.slow_time.clone());
}
if !resources.message_shown.slow_time {
resources.flashing_message = Some(FlashingMessage::from(
"You activated a Slow Creature spell.",
));
resources.message_shown.slow_time = true;
}
resources.slow_time_ticks = 100;
resources.map.set_tile_at(point, TileType::Floor);
true
}
crate::tile_data::TileType::SlowTime => todo!(),
crate::tile_data::TileType::Gem => {
if let (Some(sound_effects), Some(sound_output)) =
(&mut resources.sound_effects, &mut resources.sound_output)
{
sound_output.play_sound(sound_effects.grab.clone());
}
if !resources.message_shown.gem {
resources.flashing_message = Some(FlashingMessage::from(
"Gems give you both points and strength.",
));
resources.message_shown.gem = true;
}
resources.stats.give_gems(1);
resources.stats.add_score(1);
resources.map.set_tile_at(point, TileType::Floor);
@ -201,13 +125,6 @@ fn try_step(point: Point, _world: &World, resources: &mut Resources) -> bool {
{
sound_output.play_sound(sound_effects.grab.clone());
}
if !resources.message_shown.teleport_scroll {
resources.flashing_message =
Some(FlashingMessage::from("You found a Teleport scroll."));
resources.message_shown.teleport_scroll = true;
}
resources.stats.give_teleports(1);
resources.stats.add_score(1);
resources.map.set_tile_at(point, TileType::Floor);
@ -215,24 +132,7 @@ fn try_step(point: Point, _world: &World, resources: &mut Resources) -> bool {
}
crate::tile_data::TileType::Key => todo!(),
crate::tile_data::TileType::Door => todo!(),
crate::tile_data::TileType::SpeedTime => {
if let (Some(sound_effects), Some(sound_output)) =
(&mut resources.sound_effects, &mut resources.sound_output)
{
sound_output.play_sound(sound_effects.speed_time.clone());
}
if !resources.message_shown.speed_time {
resources.flashing_message = Some(FlashingMessage::from(
"You activated a Speed Creature spell.",
));
resources.message_shown.speed_time = true;
}
resources.speed_time_ticks = 80;
resources.map.set_tile_at(point, TileType::Floor);
true
}
crate::tile_data::TileType::SpeedTime => todo!(),
crate::tile_data::TileType::Trap => todo!(),
crate::tile_data::TileType::River => todo!(),
crate::tile_data::TileType::Power => todo!(),
@ -265,6 +165,7 @@ fn try_step(point: Point, _world: &World, resources: &mut Resources) -> bool {
crate::tile_data::TileType::Trap11 => todo!(),
crate::tile_data::TileType::Trap12 => todo!(),
crate::tile_data::TileType::Trap13 => todo!(),
crate::tile_data::TileType::Player => true,
crate::tile_data::TileType::Punctuation => todo!(),
crate::tile_data::TileType::Letter(_) => todo!(),
}
@ -273,7 +174,7 @@ fn try_step(point: Point, _world: &World, resources: &mut Resources) -> bool {
pub fn whip(world: &mut World, resources: &mut Resources) {
let mut to_add: Vec<Entity> = Vec::new();
for (entity, _) in world.query_mut::<Without<(&Player, &Position), &WantsToWhip>>() {
for (entity, _) in world.query_mut::<With<Player, With<Position, Without<WantsToWhip, ()>>>>() {
if resources.stats.whips > 0 {
to_add.push(entity);
}

View file

@ -1,5 +1,3 @@
#![allow(clippy::unused_unit)]
use std::panic;
use bracket_lib::prelude::*;

View file

@ -1,14 +1,5 @@
use crate::constants::*;
pub enum Difficulty {
Novice,
Experienced,
Advanced,
Secret,
}
#[derive(Debug, Eq, PartialEq, Copy, Clone, Hash)]
pub struct DifficultySettings {
pub struct Difficulty {
pub value: u32,
pub starting_gems: u32,
pub starting_whips: u32,
@ -17,49 +8,38 @@ pub struct DifficultySettings {
pub starting_whip_power: u32,
}
impl From<&Difficulty> for DifficultySettings {
fn from(difficulty: &Difficulty) -> Self {
match difficulty {
Difficulty::Novice => NOVICE,
Difficulty::Experienced => EXPERIENCED,
Difficulty::Advanced => ADVANCED,
Difficulty::Secret => SECRET,
}
}
}
const SECRET: DifficultySettings = DifficultySettings {
pub const SECRET: Difficulty = Difficulty {
value: 9,
starting_gems: 250,
starting_whips: 100,
starting_teleports: 50,
starting_keys: 1,
starting_whip_power: BASE_WHIP_POWER + 1,
starting_whip_power: 3,
};
const NOVICE: DifficultySettings = DifficultySettings {
pub const NOVICE: Difficulty = Difficulty {
value: 8,
starting_gems: 20,
starting_whips: 10,
starting_teleports: 0,
starting_keys: 0,
starting_whip_power: BASE_WHIP_POWER,
starting_whip_power: 0,
};
const EXPERIENCED: DifficultySettings = DifficultySettings {
pub const EXPERIENCED: Difficulty = Difficulty {
value: 5,
starting_gems: 15,
starting_whips: 0,
starting_teleports: 0,
starting_keys: 0,
starting_whip_power: BASE_WHIP_POWER,
starting_whip_power: 0,
};
const ADVANCED: DifficultySettings = DifficultySettings {
pub const ADVANCED: Difficulty = Difficulty {
value: 2,
starting_gems: 10,
starting_whips: 0,
starting_teleports: 0,
starting_keys: 0,
starting_whip_power: BASE_WHIP_POWER,
starting_whip_power: 0,
};

View file

@ -9,7 +9,6 @@ pub enum FlashingMessageIntent {
Save,
Restore,
Restart,
NextLevel,
}
pub struct FlashingMessage {

View file

@ -1,24 +0,0 @@
#[derive(Debug, Default)]
pub struct MessageShown {
pub touched_boundary: bool,
pub slow_time: bool,
pub speed_time: bool,
pub whip: bool,
pub gem: bool,
pub teleport_scroll: bool,
pub stairs: bool,
}
impl MessageShown {
pub fn all_shown() -> Self {
MessageShown {
touched_boundary: true,
slow_time: true,
speed_time: true,
whip: true,
gem: true,
teleport_scroll: true,
stairs: true,
}
}
}

View file

@ -2,17 +2,15 @@ pub mod clock;
pub mod difficulty;
pub mod flashing_message;
pub mod map;
pub mod message_shown;
pub mod sound_effects;
pub mod sound_output;
pub mod stats;
use bracket_lib::prelude::*;
pub use clock::{Clock, StopClock};
pub use difficulty::DifficultySettings;
pub use difficulty::Difficulty;
pub use flashing_message::FlashingMessage;
pub use map::Map;
pub use message_shown::MessageShown;
pub use sound_effects::SoundEffects;
pub use sound_output::SoundOutput;
pub use stats::Stats;
@ -25,12 +23,9 @@ pub struct Resources {
pub clock: Clock,
pub stop_clock: bool,
pub map: Map,
pub difficulty: Option<DifficultySettings>,
pub selected_difficulty: Option<Difficulty>,
pub sound_effects: Option<SoundEffects>,
pub sound_output: Option<SoundOutput>,
pub flashing_message: Option<FlashingMessage>,
pub message_shown: MessageShown,
pub should_advance_level: bool,
pub speed_time_ticks: u32,
pub slow_time_ticks: u32,
}

View file

@ -1,16 +1,19 @@
use std::{cmp, iter, time::Duration};
use std::{array, iter, time::Duration};
use bracket_lib::random::RandomNumberGenerator;
use crate::resources::sound_output::{SoundOutput, SoundSamples};
type Frequency = u32;
type StartFrequency = u32;
type EndFrequency = u32;
type MinFrequency = u32;
type MaxFrequency = u32;
pub enum SoundType {
Silence,
Tone(Frequency),
Sweep(StartFrequency, EndFrequency),
Noise(MinFrequency, MaxFrequency),
}
@ -31,34 +34,28 @@ pub struct SoundEffects {
pub blocked: SoundSamples,
pub whipping: SoundSamples,
pub whipping_hit: SoundSamples,
pub whipping_hit_enemy: SoundSamples,
pub whipping_hit_block: SoundSamples,
pub whipping_hit_end: SoundSamples,
pub slow_hit: SoundSamples,
pub medium_hit: SoundSamples,
pub fast_hit: SoundSamples,
pub pause: SoundSamples,
pub speed_time: SoundSamples,
pub slow_time: SoundSamples,
rng: RandomNumberGenerator,
}
impl SoundEffects {
pub fn new(sound_output: &SoundOutput) -> Self {
let mut rng = RandomNumberGenerator::new();
Self {
startup: sound_output.render_sound_effect(&SoundEffect {
sounds: (1..800)
.map(|x| Sound {
sound_type: SoundType::Tone(x / 2),
duration: Duration::from_millis(1),
})
.collect(),
sounds: vec![Sound {
sound_type: SoundType::Sweep(1, 350),
duration: Duration::from_secs(1),
}],
}),
step: sound_output.render_sound_effect(&SoundEffect {
sounds: vec![
Sound {
sound_type: SoundType::Noise(350, 900),
duration: Duration::from_millis(5),
duration: Duration::from_millis(6),
},
Sound {
sound_type: SoundType::Silence,
@ -92,7 +89,7 @@ impl SoundEffects {
duration: Duration::from_millis(40),
})
.chain((0..4).flat_map(|_| {
[
array::IntoIter::new([
Sound {
sound_type: SoundType::Tone(100),
duration: Duration::from_millis(15),
@ -101,7 +98,7 @@ impl SoundEffects {
sound_type: SoundType::Silence,
duration: Duration::from_millis(15),
},
]
])
}))
.collect(),
}),
@ -122,27 +119,23 @@ impl SoundEffects {
}],
}),
whipping_hit: sound_output.render_sound_effect(&SoundEffect {
sounds: vec![Sound {
sounds: vec![
Sound {
sound_type: SoundType::Tone(400),
duration: Duration::from_millis(20),
},
Sound {
sound_type: SoundType::Tone(90),
duration: Duration::from_secs(3),
}],
},
],
}),
whipping_hit_enemy: sound_output.render_sound_effect(&SoundEffect {
whipping_hit_end: sound_output.render_sound_effect(&SoundEffect {
sounds: vec![Sound {
sound_type: SoundType::Tone(400),
duration: Duration::from_millis(20),
}],
}),
whipping_hit_block: sound_output.render_sound_effect(&SoundEffect {
sounds: (20_i32..=5700_i32)
.rev()
.step_by(5)
.map(|x| Sound {
sound_type: SoundType::Tone(cmp::max(0, rng.range(0, x * 2) - x) as u32),
duration: Duration::from_micros(665),
})
.collect(),
}),
slow_hit: sound_output.render_sound_effect(&SoundEffect {
sounds: vec![Sound {
sound_type: SoundType::Tone(400),
@ -174,24 +167,7 @@ impl SoundEffects {
sounds
},
}),
speed_time: sound_output.render_sound_effect(&SoundEffect {
sounds: (1..=7)
.map(|x| Sound {
sound_type: SoundType::Tone(x * 50 + 300),
duration: Duration::from_millis(x as u64 * 10 + 40),
})
.collect(),
}),
slow_time: sound_output.render_sound_effect(&SoundEffect {
sounds: (1..=7)
.rev()
.map(|x| Sound {
sound_type: SoundType::Tone(x * 50 + 300),
duration: Duration::from_millis(x as u64 * 10 + 40),
})
.collect(),
}),
rng,
rng: RandomNumberGenerator::new(),
}
}

View file

@ -4,8 +4,8 @@ use cpal::{
traits::{DeviceTrait, HostTrait, StreamTrait},
SampleRate, Stream,
};
use fundsp::prelude::*;
use oddio::{Frames, FramesSignal, Gain, Handle, Mixer, MonoToStereo, Stop};
use rand::Rng;
use super::sound_effects::{SoundEffect, SoundType};
@ -61,65 +61,39 @@ impl SoundOutput {
}
pub fn render_sound_effect(&self, effect: &SoundEffect) -> SoundSamples {
// Keep these outside the loop to remember phase
let mut half_cycle_counter: u32 = 0;
let mut speaker_out: bool = false;
let effect_buffer: Vec<f32> = effect
.sounds
.iter()
.flat_map(|sound| match sound.sound_type {
SoundType::Silence => {
// Reset phase on silence
half_cycle_counter = 0;
speaker_out = false;
(0..(self.sample_rate.0 as f32 * sound.duration.as_secs_f32()) as usize)
SoundType::Silence => (0
..(self.sample_rate.0 as f32 * sound.duration.as_secs_f32()) as usize)
.map(|_| 0f32)
.collect::<Vec<f32>>(),
SoundType::Tone(freq) => {
let mut c = square_hz(freq as f32);
c.reset(Some(self.sample_rate.0 as f64));
(0..(self.sample_rate.0 as f32 * sound.duration.as_secs_f32()) as usize)
.map(|_| c.get_mono())
.collect::<Vec<f32>>()
}
SoundType::Tone(freq) => {
// A frequency of 0 is silence
if freq == 0 {
half_cycle_counter = 0;
speaker_out = false;
return (0..(self.sample_rate.0 as f32 * sound.duration.as_secs_f32())
as usize)
.map(|_| 0f32)
.collect::<Vec<f32>>();
}
let mut buffer: Vec<f32> = vec![
0.;
(self.sample_rate.0 as f32 * sound.duration.as_secs_f32())
as usize
];
let half_cycle_counter_upper_bound: u32 = self.sample_rate.0 / freq;
for sample in &mut buffer {
if speaker_out {
*sample = 0.75;
}
half_cycle_counter += 2;
if half_cycle_counter >= half_cycle_counter_upper_bound {
half_cycle_counter %= half_cycle_counter_upper_bound;
speaker_out = !speaker_out;
}
}
buffer
SoundType::Sweep(start_freq, end_freq) => {
let mut c = lfo(|t| {
lerp(
start_freq as f32,
end_freq as f32,
t * sound.duration.as_secs_f32(),
)
}) >> square();
c.reset(Some(self.sample_rate.0 as f64));
(0..(self.sample_rate.0 as f32 * sound.duration.as_secs_f32()) as usize)
.map(|_| c.get_mono())
.collect::<Vec<f32>>()
}
SoundType::Noise(min, max) => {
let mut c =
(((white() + dc(1.0)) * dc(max as f32 / 2.0)) + dc(min as f32)) >> square();
(0..(self.sample_rate.0 as f32 * sound.duration.as_secs_f32()) as usize)
.map(|i| {
let t = i as f32 / self.sample_rate.0 as f32;
(t * (rand::thread_rng().gen_range(min as f32..max as f32))
* 2.0
* std::f32::consts::PI)
.sin()
.signum()
})
.map(|_| c.get_mono())
.collect::<Vec<f32>>()
}
})
@ -129,10 +103,11 @@ impl SoundOutput {
}
pub fn play_sound(&mut self, samples: SoundSamples) -> SoundEffectHandle {
let mut gain = oddio::Gain::new(oddio::FramesSignal::from(samples));
gain.set_gain(-10.0);
self.mixer_handle
.control::<oddio::Mixer<_>, _>()
.play(oddio::MonoToStereo::new(gain))
.play(oddio::MonoToStereo::new(oddio::Gain::new(
oddio::FramesSignal::from(samples),
0.50,
)))
}
}

View file

@ -1,10 +1,10 @@
use instant::Instant;
use crate::resources::clock::Clock;
use crate::resources::difficulty::*;
use crate::resources::flashing_message::{FlashingMessage, FlashingMessageIntent};
use crate::resources::sound_effects::SoundEffects;
use crate::resources::stats::Stats;
use crate::resources::{difficulty::*, MessageShown};
use crate::resources::{Map, Resources, SoundOutput};
use crate::{graphics, input, levels, systems};
use bracket_lib::prelude::*;
@ -43,8 +43,7 @@ impl State {
}
let starting_level = 0;
let selected_difficulty = Difficulty::Secret;
let difficulty_settings = DifficultySettings::from(&selected_difficulty);
let selected_difficulty = SECRET;
let mut world = World::new();
@ -57,11 +56,11 @@ impl State {
player_input: None,
stats: Stats {
score: 0,
gems: difficulty_settings.starting_gems,
whips: difficulty_settings.starting_whips,
whip_power: difficulty_settings.starting_whip_power,
teleports: difficulty_settings.starting_teleports,
keys: difficulty_settings.starting_keys,
gems: selected_difficulty.starting_gems,
whips: selected_difficulty.starting_whips,
whip_power: selected_difficulty.starting_whip_power,
teleports: selected_difficulty.starting_teleports,
keys: selected_difficulty.starting_keys,
},
clock: Clock {
last_ticked: Instant::now(),
@ -72,18 +71,12 @@ impl State {
map,
sound_effects,
sound_output,
difficulty: Some(difficulty_settings),
selected_difficulty: Some(selected_difficulty),
flashing_message: Some(FlashingMessage::new(
"Press any key to begin this level.",
Some(FlashingMessageIntent::Start),
)),
message_shown: match selected_difficulty {
Difficulty::Novice | Difficulty::Experienced => Default::default(),
_ => MessageShown::all_shown(),
},
should_advance_level: false,
speed_time_ticks: 0,
slow_time_ticks: 0,
};
State { world, resources }
@ -96,6 +89,9 @@ impl State {
self.resources.map = Map::from(levels::get_level(self.resources.level_number));
self.resources.map.spawn_entities(&mut self.world);
self.resources.flashing_message =
Some(FlashingMessage::from("Press any key to begin this level."));
self.resources.should_advance_level = false;
}
}

View file

@ -1,5 +1,4 @@
pub mod monster_ai;
pub mod powerups;
pub mod time;
pub mod whip;
@ -8,7 +7,6 @@ use hecs::World;
use crate::resources::Resources;
pub fn run(world: &mut World, resources: &mut Resources) {
powerups::run(resources);
whip::run(world, resources);
monster_ai::run(world, resources);
time::run(resources);

View file

@ -52,7 +52,7 @@ pub fn run(world: &mut World, resources: &mut Resources) {
};
if let Some(e) = resources.map.get_tile_content_at(destination) {
if let Ok(_player) = world.get::<&Player>(e) {
if let Ok(_player) = world.get::<Player>(e) {
// TODO: Sound
resources.map.clear_tile_content_at(Point::from(*position));
resources.stats.take_gems(damage_for_kind(monster.kind));
@ -91,16 +91,10 @@ pub fn run(world: &mut World, resources: &mut Resources) {
}
}
if resources.speed_time_ticks > 0 {
monster.ticks_until_move = 3;
} else if resources.slow_time_ticks > 0 {
monster.ticks_until_move = ticks_for_kind(monster.kind) * 5;
} else {
monster.ticks_until_move = ticks_for_kind(monster.kind);
}
}
}
}
for e in to_kill {
let _ = world.despawn(e);

View file

@ -1,12 +0,0 @@
use crate::resources::Resources;
pub fn run(resources: &mut Resources) {
if resources.clock.has_ticked {
if let Some(t) = resources.speed_time_ticks.checked_sub(1) {
resources.speed_time_ticks = t;
}
if let Some(t) = resources.slow_time_ticks.checked_sub(1) {
resources.slow_time_ticks = t;
}
}
}

View file

@ -7,7 +7,6 @@ use hecs::{Entity, World};
use crate::{
components::{monster::damage_for_kind, Monster, Position, WantsToWhip},
resources::Resources,
tile_data::TileType,
};
pub fn run(world: &mut World, resources: &mut Resources) {
@ -70,19 +69,27 @@ pub fn run(world: &mut World, resources: &mut Resources) {
if let Some(dest) = destination {
if let Some(e) = resources.map.get_tile_content_at(dest) {
if let Ok(monster) = world.get::<&Monster>(e) {
if let Ok(monster) = world.get::<Monster>(e) {
resources.stats.add_score(damage_for_kind(monster.kind));
to_kill.push(e);
resources.map.clear_tile_content_at(dest);
if let Some(sound) = &mut wants_to_whip.sound {
sound.control::<oddio::Stop<_>, _>().stop();
}
if wants_to_whip.frame == 7 {
wants_to_whip.sound = None;
if let (Some(sound_effects), Some(sound_output)) =
(&mut resources.sound_effects, &mut resources.sound_output)
{
sound_output.play_sound(sound_effects.whipping_hit_enemy.clone());
sound_output.play_sound(sound_effects.whipping_hit_end.clone());
}
} else if let (Some(sound_effects), Some(sound_output)) =
(&mut resources.sound_effects, &mut resources.sound_output)
{
wants_to_whip.sound =
Some(sound_output.play_sound(sound_effects.whipping_hit.clone()));
}
switch_to_hit_sound(resources, wants_to_whip);
}
} else {
hit_tile(resources, wants_to_whip, dest);
}
}
@ -108,36 +115,3 @@ pub fn run(world: &mut World, resources: &mut Resources) {
let _ = world.remove_one::<WantsToWhip>(e);
}
}
fn hit_tile(resources: &mut Resources, wants_to_whip: &mut WantsToWhip, location: Point) {
let tile = resources.map.get_tile_at(location);
match tile {
TileType::Block | TileType::Tree => {
let mut rng = RandomNumberGenerator::new();
if (rng.range(0, 7) as u32) < resources.stats.whip_power {
resources.map.set_tile_at(location, TileType::Floor);
if let (Some(sound_effects), Some(sound_output)) =
(&mut resources.sound_effects, &mut resources.sound_output)
{
sound_output.play_sound(sound_effects.whipping_hit_block.clone());
}
switch_to_hit_sound(resources, wants_to_whip);
}
}
TileType::Forest => todo!(),
_ => (),
}
}
fn switch_to_hit_sound(resources: &mut Resources, wants_to_whip: &mut WantsToWhip) {
if let Some(sound) = &mut wants_to_whip.sound {
sound.control::<oddio::Stop<_>, _>().stop();
}
if let (Some(sound_effects), Some(sound_output)) =
(&mut resources.sound_effects, &mut resources.sound_output)
{
wants_to_whip.sound = Some(sound_output.play_sound(sound_effects.whipping_hit.clone()));
}
}

View file

@ -2,7 +2,7 @@ use bracket_lib::prelude::*;
use crate::graphics::vga_color as vga;
#[derive(Eq, PartialEq, Copy, Clone)]
#[derive(PartialEq, Copy, Clone)]
pub struct TileData {
pub glyph: FontCharType,
pub color_fg: (u8, u8, u8),

View file

@ -13,21 +13,13 @@ module.exports = {
path: dist,
filename: "[name].js"
},
experiments: {
asyncWebAssembly: true,
syncWebAssembly: true
},
devServer: {
static: {
directory: dist,
}
contentBase: dist,
},
plugins: [
new CopyPlugin({
patterns: [
"static"
]
}),
new CopyPlugin([
path.resolve(__dirname, "static")
]),
new WasmPackPlugin({
crateDirectory: __dirname,