Compare commits
7 Commits
84d93d496a
...
v0.5.0
| Author | SHA1 | Date | |
|---|---|---|---|
| 8fc9e682cc | |||
| be83be1a7b | |||
| 3639122e54 | |||
| 97e0313c23 | |||
| de79ca0258 | |||
| 1edbd3e78c | |||
| 5af59863a1 |
6008
Cargo.lock
generated
Normal file
6008
Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
10
Cargo.toml
10
Cargo.toml
@@ -1,14 +1,14 @@
|
||||
[package]
|
||||
name = "asteroids"
|
||||
version = "0.3.0"
|
||||
version = "0.5.0"
|
||||
edition = "2024"
|
||||
license = "AGPL-3.0-only"
|
||||
|
||||
[dependencies]
|
||||
bevy = "0.16"
|
||||
bevy-inspector-egui = "0.32.0"
|
||||
bevy_rapier2d = "0.31.0"
|
||||
rand = "0.9.2"
|
||||
bevy-inspector-egui = "0.32"
|
||||
bevy_rapier2d = "0.31"
|
||||
rand = "0.9"
|
||||
|
||||
[features]
|
||||
default = ["dynamic_linking"]
|
||||
@@ -16,7 +16,7 @@ dynamic_linking = ["bevy/dynamic_linking"]
|
||||
debug_ui = ["bevy_rapier2d/debug-render-2d"]
|
||||
|
||||
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
||||
getrandom = { version = "0.3.3", features = ["wasm_js"] }
|
||||
getrandom = { version = "0.3", features = ["wasm_js"] }
|
||||
|
||||
[profile.speedy]
|
||||
inherits = "release"
|
||||
|
||||
15
Makefile
15
Makefile
@@ -15,20 +15,20 @@ SRCS := $(wildcard $(SRC_DIR)/**)
|
||||
.PHONY: clean full-clean tarball tarball-standalone web web-standalone
|
||||
|
||||
# "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
|
||||
# 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_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 $@ $^
|
||||
|
||||
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 $@ $^
|
||||
|
||||
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
|
||||
# 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
|
||||
gzip -9 -f out/asteroids_bg.wasm
|
||||
|
||||
# Copies the index page to the output dir.
|
||||
out/index.html: www/index.html
|
||||
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.
|
||||
out/asteroids.html: www/index.html
|
||||
@@ -67,5 +68,5 @@ full-clean: clean
|
||||
install: web
|
||||
install -dm0755 $(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)/
|
||||
|
||||
@@ -65,6 +65,7 @@ impl Plugin for AsteroidPlugin {
|
||||
objects::ship_impact_listener,
|
||||
physics::collision_listener,
|
||||
machinery::tick_lifetimes,
|
||||
machinery::update_scoreboard,
|
||||
)
|
||||
.run_if(in_state(GameState::Playing)),
|
||||
)
|
||||
|
||||
@@ -8,7 +8,7 @@ use std::time::Duration;
|
||||
|
||||
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.
|
||||
///
|
||||
@@ -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::{
|
||||
ecs::{
|
||||
bundle::Bundle,
|
||||
component::Component,
|
||||
entity::Entity,
|
||||
event::{EventReader, EventWriter},
|
||||
|
||||
@@ -90,7 +90,7 @@
|
||||
<tr>
|
||||
<td>Program Version</td>
|
||||
<!-- This version text is completely unchecked. I'll need to do something about that. -->
|
||||
<td><code>v0.3.0</code></td>
|
||||
<td><code>v0.5.0</code></td>
|
||||
</tr>
|
||||
</table>
|
||||
</article>
|
||||
@@ -98,7 +98,11 @@
|
||||
<script type="module">
|
||||
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!")) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user