8 Commits

Author SHA1 Message Date
099926d368 Hotfix for broken install target in Makefile
Some checks failed
Basic checks / Basic build-and-test supertask (push) Failing after 48s
I didn't check that it also *installs* all of it's components! That's
what I get for not having a list of package contents... although I'd
probably just end up missing something there instead.
2025-12-19 16:11:13 -06:00
76426094d3 Mark v0.6.0 release
Some checks failed
Basic checks / Basic build-and-test supertask (push) Failing after 59s
2025-12-19 13:47:49 -06:00
4b101633e7 Better colors for the "get ready" screen
The card itself is transparent, but it still has a size of 30% of the
viewport because the bar is based on the size of it's container.

The start bar and text can still be green and red, respectively, but the
light blue was completely out of place.
2025-12-19 13:45:22 -06:00
a5a6f32037 Add a sound warning and mute guide
Page visitors may be surprised by the sounds and not know how to turn
them off. The answer is "you don't", but practically the browser tab can
be muted instead.
2025-12-19 13:36:48 -06:00
4d899d3c97 Improved "load game" button, now with elem swap
Some checks failed
Basic checks / Basic build-and-test supertask (push) Failing after 1m3s
The canvas element no longer exists in the page source. Instead, there
is a div styled to look similar and contain a button. The button is
styled to match the ones in the Bevy app. When pressed, the button
creates the canvas element, replaces the fake canvas div, and loads the
WASM to do it's thing.
2025-12-19 13:27:42 -06:00
6d5afc2445 Add a basic "load game" button
This will ensure the user has interacted with the page before the game
starts, thus allowing the sound to play correctly.

It doesn't re-load the game if the user quits. I'd like to figure out
how to do that.

The need to push the button isn't immediately obvious. It should be over
top (or in place of) the canvas to best convey that the user must start
the game.
2025-12-19 11:46:18 -06:00
d34d0a31f2 Fix: Folder deps need to be order-only deps
I did the thing againnnnn. The Makefile thinks the sound assets are
constantly out-of-date because the folder that contains them technically
changes any time a file is added or removed from the folder.

1. "out/assets" is created, it is up-to-date
2. "out/assets/example.ogg" is created, it is up-to-date
3. Parent folder "out/assets" has it's mtime updated because it's
   contents have changed. It is newer than it was at step 1, and newer
   than the .ogg file in step 2.
4. run `make` again
5. "out/assets" is up-to-date, nothing changes
6. "out/assets/example.ogg" is OLDER than one of it's dependencies
   ("out/assets/"), and is rebuilt.
7. "out/assets" got new contents, so it's mtime was updated again.

The cycle isn't infinite, but it will always try to rebuild the sound
files. The fix is to consider the containing folder to only be an
ordering dependency rather than a substantive dependency. The former
only needs the dependency to be made first, where the latter considers
the dependency to be part of the target file. The containing folder is
not part of the sound files, so "rebuilding" the sound files when the
folder changes is complete nonsense.
2025-12-19 11:26:18 -06:00
72f062ea10 Teach the Makefile how to "build" the audio assets
Some checks failed
Basic checks / Basic build-and-test supertask (push) Failing after 55s
Makefiles are pretty strange things.

There is a new wildcard target which will copy any .ogg file from
"assets/" into "out/assets". On it's own, it does nothing -- it only
knows how to create the output file by copying the input one.

To drive this, a list of output assets must be created and depended upon
by the main build target(s). I don't want to manually maintain an asset
manifest in a Makefile, so I've achived this by wildcard matching
anything in the "assets/" folder, then rewriting the prefix to be
"out/assets/". This list is in a variable, which is now part of the
dependency list for the main build target(s). All files will be
installed, but only when they are out-of-date. Excellent.
2025-12-19 10:55:57 -06:00
5 changed files with 72 additions and 21 deletions

6
Cargo.lock generated
View File

@@ -242,7 +242,7 @@ dependencies = [
[[package]] [[package]]
name = "asteroids" name = "asteroids"
version = "0.6.0-dev3" version = "0.6.1"
dependencies = [ dependencies = [
"bevy", "bevy",
"bevy-inspector-egui", "bevy-inspector-egui",
@@ -4295,9 +4295,9 @@ dependencies = [
[[package]] [[package]]
name = "portable-atomic" name = "portable-atomic"
version = "1.11.1" version = "1.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f84267b20a16ea918e43c6a88433c2d54fa145c92a811b5b047ccbe153674483" checksum = "f59e70c4aef1e55797c2e8fd94a4f2a973fc972cfde0e0b05f683667b0cd39dd"
[[package]] [[package]]
name = "portable-atomic-util" name = "portable-atomic-util"

View File

@@ -1,6 +1,6 @@
[package] [package]
name = "asteroids" name = "asteroids"
version = "0.6.0-dev3" version = "0.6.1"
edition = "2024" edition = "2024"
license = "AGPL-3.0-only" license = "AGPL-3.0-only"

View File

@@ -12,23 +12,26 @@ CARGO_PROFILE := tiny
SRC_DIR = ./src SRC_DIR = ./src
SRCS := $(wildcard $(SRC_DIR)/**) SRCS := $(wildcard $(SRC_DIR)/**)
ASSET_SOURCE := $(wildcard assets/**)
ASSETS := $(patsubst assets/%.ogg, out/assets/%.ogg, $(ASSET_SOURCE))
.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.gz out/index.html web-standalone: out/asteroids.js out/asteroids_bg.wasm.gz out/index.html $(ASSETS)
# "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.gz out/asteroids.html web: out/asteroids.js out/asteroids_bg.wasm.gz out/asteroids.html $(ASSETS)
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.gz out/asteroids.html asteroids_web_root.tar: out/asteroids.js out/asteroids_bg.wasm.gz out/asteroids.html $(ASSETS)
tar -caf $@ $^ tar -caf $@ $^
asteroids_web_root_standalone.tar: out/asteroids.js out/asteroids_bg.wasm.gz out/index.html asteroids_web_root_standalone.tar: out/asteroids.js out/asteroids_bg.wasm.gz out/index.html $(ASSETS)
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
@@ -37,6 +40,12 @@ target/$(CARGO_TARGET)/$(CARGO_PROFILE)/asteroids.wasm: $(SRCS) Cargo.lock Cargo
out: out:
mkdir $@ mkdir $@
out/assets: | out
mkdir $@
out/assets/%.ogg: assets/%.ogg | out/assets
cp -ar assets/$*.ogg $@
# 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.gz &: target/$(CARGO_TARGET)/$(CARGO_PROFILE)/asteroids.wasm | out out/asteroids.js out/asteroids_bg.wasm.gz &: target/$(CARGO_TARGET)/$(CARGO_PROFILE)/asteroids.wasm | out
@@ -67,6 +76,8 @@ full-clean: clean
# output into the web root. Only supports the "bundle-able" mode. # output into the web root. Only supports the "bundle-able" mode.
install: web install: web
install -dm0755 $(DESTDIR) install -dm0755 $(DESTDIR)
install -dm0755 $(DESTDIR)/assets
install -m0644 out/asteroids.js $(DESTDIR)/ install -m0644 out/asteroids.js $(DESTDIR)/
install -m0644 out/asteroids_bg.wasm.gz $(DESTDIR)/ install -m0644 out/asteroids_bg.wasm.gz $(DESTDIR)/
install -m0644 out/asteroids.html $(DESTDIR)/ install -m0644 out/asteroids.html $(DESTDIR)/
install -m0644 $(ASSETS) $(DESTDIR)/assets/

View File

@@ -180,9 +180,9 @@ fn spawn_get_ready(mut commands: Commands, mut timer: ResMut<ReadySetGoTimer>) {
height: Val::Percent(30.), height: Val::Percent(30.),
..default() ..default()
}, },
BackgroundColor(LIGHT_BLUE.into()), BackgroundColor(Color::NONE),
children![ children![
(Text::new("Get Ready!"), TextColor(BLACK.into())), (Text::new("Get Ready!"), TextColor(WHITE.into())),
( (
CountdownBar, CountdownBar,
Node { Node {

View File

@@ -12,6 +12,7 @@
margin: auto; margin: auto;
padding: 0.5em; padding: 0.5em;
} }
#prestart-controls,
canvas { canvas {
margin-top: 1em; margin-top: 1em;
margin-left: auto; margin-left: auto;
@@ -22,6 +23,26 @@
border-radius: 8px; border-radius: 8px;
background-color: rgb(40%, 40%, 40%); background-color: rgb(40%, 40%, 40%);
} }
#prestart-controls {
width: 800px;
height: 600px;
text-align: center;
align-content: center;
}
button {
font-size: 20px;
text-shadow: 0.2em 0.2em 0px rgba(0, 0, 0, 75%);
padding: 1em;
border-radius: 2em;
border-style: solid;
border-color: black;
color: rgb(90%, 90%, 90%);
background-color: rgb(15%, 15%, 15%);
}
button:hover {
background-color: rgb(25%, 25%, 25%);
border-color: rgb(90%, 90%, 90%);
}
main { main {
margin-left: auto; margin-left: auto;
margin-right: auto; margin-right: auto;
@@ -41,13 +62,21 @@
<h1> <h1>
Robert's Bad Asteroids Game Robert's Bad Asteroids Game
</h1> </h1>
<canvas id="game-canvas" width="1280" height="720"></canvas> <!-- <canvas id="game-canvas" width="800" height="600"></canvas> -->
<div id="prestart-controls">
<button id="gameload-button">Load Game</button>
</div>
<main> <main>
<article> <article>
<h2>Description</h2> <h2>Description</h2>
<p> <p>
A (work in progress) version of the Asteroids arcade game. A (work in progress) version of the Asteroids arcade game.
</p> </p>
<p>
<em>Sound Warning!</em> The game now has sound effects, but there are no controls on the page for changing the
volume (including to mute them). You can mute the browser tab by pressing <code>ctrl</code> + <code>m</code>.
Proper volume controls are coming soon.
</p>
</article> </article>
<article> <article>
<h3>Controls</h3> <h3>Controls</h3>
@@ -90,7 +119,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.5.0</code></td> <td><code>v0.6.1</code></td>
</tr> </tr>
</table> </table>
</article> </article>
@@ -98,6 +127,16 @@
<script type="module"> <script type="module">
import init from './asteroids.js' import init from './asteroids.js'
let button = document.getElementById("gameload-button");
button.onclick = async function loadGame() {
console.log("Game Load button was pressed!");
let canvas = document.createElement("canvas");
// <canvas id="game-canvas" width="800" height="600"></canvas>
canvas.setAttribute("id", "game-canvas");
canvas.setAttribute("width", "800");
canvas.setAttribute("height", "600");
button.parentElement.replaceWith(canvas);
let compressed = await fetch("./asteroids_bg.wasm.gz") let compressed = await fetch("./asteroids_bg.wasm.gz")
let wasm_stream = compressed.body.pipeThrough(new DecompressionStream("gzip")) let wasm_stream = compressed.body.pipeThrough(new DecompressionStream("gzip"))
let blob = await new Response(wasm_stream).blob(); let blob = await new Response(wasm_stream).blob();
@@ -107,6 +146,7 @@
throw error; throw error;
} }
}); });
}
</script> </script>
</body> </body>