Compare commits
6 Commits
5af59863a1
...
8fc9e682cc
| Author | SHA1 | Date | |
|---|---|---|---|
| 8fc9e682cc | |||
| be83be1a7b | |||
| 3639122e54 | |||
| 97e0313c23 | |||
| de79ca0258 | |||
| 1edbd3e78c |
34
Cargo.lock
generated
34
Cargo.lock
generated
@@ -244,7 +244,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "asteroids"
|
name = "asteroids"
|
||||||
version = "0.4.0"
|
version = "0.5.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bevy",
|
"bevy",
|
||||||
"bevy-inspector-egui",
|
"bevy-inspector-egui",
|
||||||
@@ -1640,9 +1640,9 @@ checksum = "8f1fe948ff07f4bd06c30984e69f5b4899c516a3ef74f34df92a2df2ab535495"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bytes"
|
name = "bytes"
|
||||||
version = "1.10.1"
|
version = "1.11.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a"
|
checksum = "b35204fbdc0b3f4446b89fc1ac2cf84a8a68971995d0bf2e925ec7cd960f9cb3"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "calloop"
|
name = "calloop"
|
||||||
@@ -1672,9 +1672,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cc"
|
name = "cc"
|
||||||
version = "1.2.45"
|
version = "1.2.46"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "35900b6c8d709fb1d854671ae27aeaa9eec2f8b01b364e1619a40da3e6fe2afe"
|
checksum = "b97463e1064cb1b1c1384ad0a0b9c8abd0988e2a91f52606c80ef14aadb63e36"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"find-msvc-tools",
|
"find-msvc-tools",
|
||||||
"jobserver",
|
"jobserver",
|
||||||
@@ -2279,9 +2279,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "find-msvc-tools"
|
name = "find-msvc-tools"
|
||||||
version = "0.1.4"
|
version = "0.1.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "52051878f80a721bb68ebfbc930e07b65ba72f2da88968ea5c06fd6ca3d3a127"
|
checksum = "3a3076410a55c90011c298b04d0cfa770b00fa04e1e3c97d3f6c9de105a03844"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "fixedbitset"
|
name = "fixedbitset"
|
||||||
@@ -2313,9 +2313,9 @@ checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "font-types"
|
name = "font-types"
|
||||||
version = "0.10.0"
|
version = "0.10.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "511e2c18a516c666d27867d2f9821f76e7d591f762e9fc41dd6cc5c90fe54b0b"
|
checksum = "39a654f404bbcbd48ea58c617c2993ee91d1cb63727a37bf2323a4edeed1b8c5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytemuck",
|
"bytemuck",
|
||||||
]
|
]
|
||||||
@@ -2717,9 +2717,9 @@ checksum = "dfa686283ad6dd069f105e5ab091b04c62850d3e4cf5d67debad1933f55023df"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "image"
|
name = "image"
|
||||||
version = "0.25.8"
|
version = "0.25.9"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "529feb3e6769d234375c4cf1ee2ce713682b8e76538cb13f9fc23e1400a591e7"
|
checksum = "e6506c6c10786659413faa717ceebcb8f70731c0a60cbae39795fdf114519c1a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytemuck",
|
"bytemuck",
|
||||||
"byteorder-lite",
|
"byteorder-lite",
|
||||||
@@ -4041,9 +4041,9 @@ checksum = "c3d6831663a5098ea164f89cff59c6284e95f4e3c76ce9848d4529f5ccca9bde"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rangemap"
|
name = "rangemap"
|
||||||
version = "1.6.0"
|
version = "1.7.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f93e7e49bb0bf967717f7bd674458b3d6b0c5f48ec7e3038166026a69fc22223"
|
checksum = "acbbbbea733ec66275512d0b9694f34102e7d5406fdbe2ad8d21b28dce92887c"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rapier2d"
|
name = "rapier2d"
|
||||||
@@ -4551,9 +4551,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "syn"
|
name = "syn"
|
||||||
version = "2.0.109"
|
version = "2.0.110"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2f17c7e013e88258aa9543dcbe81aca68a667a9ac37cd69c9fbc07858bfe0e2f"
|
checksum = "a99801b5bd34ede4cf3fc688c5919368fea4e4814a4664359503e6015b280aea"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@@ -5197,9 +5197,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "weezl"
|
name = "weezl"
|
||||||
version = "0.1.11"
|
version = "0.1.12"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "009936b22a61d342859b5f0ea64681cbb35a358ab548e2a44a8cf0dac2d980b8"
|
checksum = "a28ac98ddc8b9274cb41bb4d9d4d5c425b6020c50c46f25559911905610b4a88"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wgpu"
|
name = "wgpu"
|
||||||
|
|||||||
10
Cargo.toml
10
Cargo.toml
@@ -1,14 +1,14 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "asteroids"
|
name = "asteroids"
|
||||||
version = "0.4.0"
|
version = "0.5.0"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
license = "AGPL-3.0-only"
|
license = "AGPL-3.0-only"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bevy = "0.16"
|
bevy = "0.16"
|
||||||
bevy-inspector-egui = "0.32.0"
|
bevy-inspector-egui = "0.32"
|
||||||
bevy_rapier2d = "0.31.0"
|
bevy_rapier2d = "0.31"
|
||||||
rand = "0.9.2"
|
rand = "0.9"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["dynamic_linking"]
|
default = ["dynamic_linking"]
|
||||||
@@ -16,7 +16,7 @@ dynamic_linking = ["bevy/dynamic_linking"]
|
|||||||
debug_ui = ["bevy_rapier2d/debug-render-2d"]
|
debug_ui = ["bevy_rapier2d/debug-render-2d"]
|
||||||
|
|
||||||
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
||||||
getrandom = { version = "0.3.3", features = ["wasm_js"] }
|
getrandom = { version = "0.3", features = ["wasm_js"] }
|
||||||
|
|
||||||
[profile.speedy]
|
[profile.speedy]
|
||||||
inherits = "release"
|
inherits = "release"
|
||||||
|
|||||||
15
Makefile
15
Makefile
@@ -15,20 +15,20 @@ SRCS := $(wildcard $(SRC_DIR)/**)
|
|||||||
.PHONY: clean full-clean tarball tarball-standalone web web-standalone
|
.PHONY: clean full-clean tarball tarball-standalone web web-standalone
|
||||||
|
|
||||||
# "Standalone" version. It includes an index.html to serve as-is
|
# "Standalone" version. It includes an index.html to serve as-is
|
||||||
web-standalone: out/asteroids.js out/asteroids_bg.wasm out/index.html
|
web-standalone: out/asteroids.js out/asteroids_bg.wasm.gz out/index.html
|
||||||
|
|
||||||
# "Bundle-able" version. It has a page, but no index.html. Consumers are
|
# "Bundle-able" version. It has a page, but no index.html. Consumers are
|
||||||
# expected to provide their own index.html and link to this page.
|
# expected to provide their own index.html and link to this page.
|
||||||
web: out/asteroids.js out/asteroids_bg.wasm out/asteroids.html
|
web: out/asteroids.js out/asteroids_bg.wasm.gz out/asteroids.html
|
||||||
|
|
||||||
tarball: asteroids_web_root.tar
|
tarball: asteroids_web_root.tar
|
||||||
|
|
||||||
tarball_standalone: asteroids_web_root_standalone.tar
|
tarball_standalone: asteroids_web_root_standalone.tar
|
||||||
|
|
||||||
asteroids_web_root.tar: out/asteroids.js out/asteroids_bg.wasm out/asteroids.html
|
asteroids_web_root.tar: out/asteroids.js out/asteroids_bg.wasm.gz out/asteroids.html
|
||||||
tar -caf $@ $^
|
tar -caf $@ $^
|
||||||
|
|
||||||
asteroids_web_root_standalone.tar: out/asteroids.js out/asteroids_bg.wasm out/index.html
|
asteroids_web_root_standalone.tar: out/asteroids.js out/asteroids_bg.wasm.gz out/index.html
|
||||||
tar -caf $@ $^
|
tar -caf $@ $^
|
||||||
|
|
||||||
target/$(CARGO_TARGET)/$(CARGO_PROFILE)/asteroids.wasm: $(SRCS) Cargo.lock Cargo.toml
|
target/$(CARGO_TARGET)/$(CARGO_PROFILE)/asteroids.wasm: $(SRCS) Cargo.lock Cargo.toml
|
||||||
@@ -39,13 +39,14 @@ out:
|
|||||||
|
|
||||||
# Both the JS and WASM files are generated by the wasm-bindgen call, so both
|
# Both the JS and WASM files are generated by the wasm-bindgen call, so both
|
||||||
# get to be on the target half of this recipe.
|
# get to be on the target half of this recipe.
|
||||||
out/asteroids.js out/asteroids_bg.wasm &: target/$(CARGO_TARGET)/$(CARGO_PROFILE)/asteroids.wasm | out
|
out/asteroids.js out/asteroids_bg.wasm.gz &: target/$(CARGO_TARGET)/$(CARGO_PROFILE)/asteroids.wasm | out
|
||||||
wasm-bindgen --no-typescript --target web --out-dir ./out/ --out-name asteroids target/$(CARGO_TARGET)/$(CARGO_PROFILE)/asteroids.wasm
|
wasm-bindgen --no-typescript --target web --out-dir ./out/ --out-name asteroids target/$(CARGO_TARGET)/$(CARGO_PROFILE)/asteroids.wasm
|
||||||
|
gzip -9 -f out/asteroids_bg.wasm
|
||||||
|
|
||||||
# Copies the index page to the output dir.
|
# Copies the index page to the output dir.
|
||||||
out/index.html: www/index.html
|
out/index.html: www/index.html
|
||||||
cp -a $< $@
|
cp -a $< $@
|
||||||
rm -f out/boids.html
|
rm -f out/asteroids.html
|
||||||
|
|
||||||
# Like `out/index.html`, but renames the page for use in a larger site.
|
# Like `out/index.html`, but renames the page for use in a larger site.
|
||||||
out/asteroids.html: www/index.html
|
out/asteroids.html: www/index.html
|
||||||
@@ -67,5 +68,5 @@ full-clean: clean
|
|||||||
install: web
|
install: web
|
||||||
install -dm0755 $(DESTDIR)
|
install -dm0755 $(DESTDIR)
|
||||||
install -m0644 out/asteroids.js $(DESTDIR)/
|
install -m0644 out/asteroids.js $(DESTDIR)/
|
||||||
install -m0644 out/asteroids_bg.wasm $(DESTDIR)/
|
install -m0644 out/asteroids_bg.wasm.gz $(DESTDIR)/
|
||||||
install -m0644 out/asteroids.html $(DESTDIR)/
|
install -m0644 out/asteroids.html $(DESTDIR)/
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ impl Plugin for AsteroidPlugin {
|
|||||||
objects::ship_impact_listener,
|
objects::ship_impact_listener,
|
||||||
physics::collision_listener,
|
physics::collision_listener,
|
||||||
machinery::tick_lifetimes,
|
machinery::tick_lifetimes,
|
||||||
|
machinery::update_scoreboard,
|
||||||
)
|
)
|
||||||
.run_if(in_state(GameState::Playing)),
|
.run_if(in_state(GameState::Playing)),
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ use std::time::Duration;
|
|||||||
|
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
|
|
||||||
use crate::{WorldSize, events::SpawnAsteroid, objects::AsteroidSize};
|
use crate::{WorldSize, events::{AsteroidDestroy, SpawnAsteroid}, objects::AsteroidSize, resources::Score};
|
||||||
|
|
||||||
/// Asteroid spawning parameters and state.
|
/// Asteroid spawning parameters and state.
|
||||||
///
|
///
|
||||||
@@ -135,3 +135,15 @@ pub fn operate_sparklers(sparklers: Query<(&mut Visibility, &mut Sparkler)>, tim
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Event listener for adding score after an asteroid was destroyed
|
||||||
|
///
|
||||||
|
/// Refreshing the HUD element is done by [crate::widgets::operate_ui] (a private function)
|
||||||
|
pub fn update_scoreboard(
|
||||||
|
mut destroy_events: EventReader<AsteroidDestroy>,
|
||||||
|
mut scoreboard: ResMut<Score>,
|
||||||
|
) {
|
||||||
|
for _event in destroy_events.read() {
|
||||||
|
scoreboard.0 += 100;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
use bevy::{
|
use bevy::{
|
||||||
ecs::{
|
ecs::{
|
||||||
bundle::Bundle,
|
|
||||||
component::Component,
|
component::Component,
|
||||||
entity::Entity,
|
entity::Entity,
|
||||||
event::{EventReader, EventWriter},
|
event::{EventReader, EventWriter},
|
||||||
|
|||||||
@@ -90,7 +90,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td>Program Version</td>
|
<td>Program Version</td>
|
||||||
<!-- This version text is completely unchecked. I'll need to do something about that. -->
|
<!-- This version text is completely unchecked. I'll need to do something about that. -->
|
||||||
<td><code>v0.4.0</code></td>
|
<td><code>v0.5.0</code></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</article>
|
</article>
|
||||||
@@ -98,7 +98,11 @@
|
|||||||
<script type="module">
|
<script type="module">
|
||||||
import init from './asteroids.js'
|
import init from './asteroids.js'
|
||||||
|
|
||||||
init().catch((error) => {
|
let compressed = await fetch("./asteroids_bg.wasm.gz")
|
||||||
|
let wasm_stream = compressed.body.pipeThrough(new DecompressionStream("gzip"))
|
||||||
|
let blob = await new Response(wasm_stream).blob();
|
||||||
|
|
||||||
|
init(await blob.arrayBuffer()).catch((error) => {
|
||||||
if (!error.message.startsWith("Using exceptions for control flow, don't mind me. This isn't actually an error!")) {
|
if (!error.message.startsWith("Using exceptions for control flow, don't mind me. This isn't actually an error!")) {
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user