Commit Graph
100 Commits
Author SHA1 Message Date
robert 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
robert 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
robert 72f062ea10 Teach the Makefile how to "build" the audio assets
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
robert eecfbf5d7c Dev version bump to 0.6.0-dev3
Basic checks / Basic build-and-test supertask (push) Failing after 1m2s
I'm moving on from asset stuff, so I'm considering this a "new version."

Next up: Fixing the Makefile to understand the sound files.
2025-12-19 10:41:08 -06:00
robert 1e09e3ce3a Fix: Include the sound asset for the thruster!
I forgot to check-in the file the other day. Big brain here in this
head.
2025-12-19 10:40:28 -06:00
robert 19ac032792 Add proper meshes & materials for game objects
The asteroid circles have been replaced with polylines. I was going to
do a regular triangle mesh, but I don't want to figure out GLTF
loading or manually chunking the points into convex hulls.

Asteroid materials are now all populated and their GameAsset getters are
indexed correctly. I'm not sold on the size based color selection.
Later, I think I'll either remove the extra colors or let each of them
randomly apply to any asteroid.

The bullet is now a short line segment. Apparently I already wired in
the rotation logic, so pointing it correctly out of the ship already
works.
2025-12-19 10:29:48 -06:00
robert de75e25ca6 Add ship thruster sound
The player's Ship now has an AudioPlayer component constantly looping a
thruster sound effect. It starts paused and is only resumed when the
player fires the thruster.

As noted in the TODO comment at the top of the input_ship_thruster(...)
system, I need to figure out if I want to start using the `Single<>`
query parameter instead of a `Query<>` and then doing my own
null-ability checks (like what it does now).
2025-12-17 17:18:18 -06:00
robert d7802bdbed Add asteroid destruction sound 2025-12-17 16:18:31 -06:00
robert ae093d2c9c Add bullet/laser sound
Firing the weapon now makes a sound. I've implemented this by spawning
the playback component on the bullet rather than the gun. This seemed
easier than figuring out how to reset a playback component that lives on
the ship entity -- although thats probably better for memory access
patterns.
2025-12-17 14:29:57 -06:00
robert 3963b548b9 Fix: Make shipwreck sound entity despawn itself
I started to work on weapon fire sounds and realized I don't know if the
entity and/or component get removed after playback ends. It turns out
that they DO NOT!... unless told to do so, like this.
2025-12-17 14:23:57 -06:00
robert b1fd2e5f73 Add a readme
Basic checks / Basic build-and-test supertask (push) Failing after 1m54s
There hasn't been a README this whole time... I guess there hasn't been
anything I need to immediately communicate to someone looking at the
source repository.

There is now a README so I have somewhere to record the extra licensing
information (for the Kenney asset).
2025-12-17 11:01:23 -06:00
robert 09ff4dc6ca First sound! Added ship explosion sound effect
It's a simple one-shot sound clip that gets dispatched as one more part
of the ship impact routine.

The GameAssets struct has been updated to have an array of handles for
audio assets (just the one, for now).

This sound file, and the next several, are all from Kenney
(www.kenney.nl).
2025-12-17 10:46:51 -06:00
robert a48dfc1d65 Finish the engine upgrade
Basic checks / Basic build-and-test supertask (push) Failing after 2m1s
Events have been replaced with Messages, import paths have been updated
for new engine module layout, and minor API changes have been matched.
2025-12-17 10:15:33 -06:00
robert 6e425e8eb9 WIP on engine upgrade 2025-12-17 09:44:48 -06:00
robert 7bd88c702f Replace event derives with message derives 2025-12-17 09:44:48 -06:00
robert cfe35c61ed Rename crate::events to crate::messages
Bevy 0.17 introduces this idea of "Messages" which mostly replace the
previous usage of "Events." The old events still exist, but are meant
more for targetted actions -- something happening and immediately
triggering a function call on an observer.
2025-12-17 09:44:48 -06:00
robert 13643f73fb Upgrade to Bevy 0.17... minus fixes for API change
Bevy 0.17 is out and I'm going to get started on an upgrade. Upgrading
dependencies will be it's own commit, as will many of the fixes. This
way I can cherry-pick anything, if need be.
2025-12-17 09:41:44 -06:00
robert 8fc9e682cc Release v0.5.0
Basic checks / Basic build-and-test supertask (push) Failing after 28s
2025-11-15 15:18:54 -06:00
robert be83be1a7b Compress the WASM file for even more space savings 2025-11-15 15:16:37 -06:00
robert 3639122e54 Fix: install "asteroids.html" not "boids.html"
Yay for copying code around!
2025-11-15 15:16:02 -06:00
robert 97e0313c23 Impl a basic scoring system
Games have scores, so I need a score counter... I guess.
2025-11-09 11:14:27 -06:00
robert de79ca0258 Apply clippy lint fix 2025-11-09 10:57:36 -06:00
robert 1edbd3e78c Name oldest viable dependency versions
Semver compatible resolution means I still get the newest, so I want to
name the oldest that still works to let Cargo do it's thing.
2025-11-08 22:17:05 -06:00
robert 5af59863a1 Release v0.4.0, now includes lockfile
Basic checks / Basic build-and-test supertask (push) Successful in 6m23s
The only real change was the addition of some CSS. I'm recording the
lockfile so that consumers can more reliably build the same binary each
time.
2025-11-08 12:31:29 -06:00
robert 84d93d496a Remove Linux-specific deps from web build
Basic checks / Basic build-and-test supertask (push) Successful in 6m24s
The Alsa and Udev system dependencies are only required on Linux. The
WASM/WASI build doesn't use them, so they don't need to exist in the
build container.
2025-11-08 12:10:42 -06:00
robert 4a9d252691 Update Dockerfile, copy everything, use makefile
I have figured out the `.dockerignore` file so I don't have to do manual
context size management like before.

The Dockerfile now uses the Makefile to ensure image builds contain the
same thing non-image builds would.
2025-11-08 12:08:45 -06:00
robert 3c9a9a7d9d Add some CSS 2025-11-08 12:07:30 -06:00
robert 010cbd6d4b Add an install target 2025-11-06 14:18:13 -06:00
robert 918992702f Add standalone & bundle-able build variants
Basic checks / Basic build-and-test supertask (push) Successful in 8m8s
Now there are build targets for producing a version that can be served
as-is, and another that can be included as a page in a larger site.
2025-11-06 10:48:06 -06:00
robert c8c64e4d22 Place Makefile 'configurables' up top
Variables that a package consumer might want to adjust should be placed
at the top of the file so they are immediately visible. Any constants
shall live below those (just the SRC folder, really).
2025-11-06 10:26:35 -06:00
robert 88a1b0e44b Release: v0.3.0, drop "+patches" note on webpate
Basic checks / Basic build-and-test supertask (push) Successful in 6m44s
2025-10-30 13:55:48 -05:00
robert aaab0757de Add a license to the project (AGPLv3)
Basic checks / Basic build-and-test supertask (push) Successful in 7m6s
2025-10-30 12:47:22 -05:00
robert 5aa47687a5 Add a Dockerfile for container-ized web hosting 2025-10-30 12:36:10 -05:00
robert 01cef2dd97 Add a Makefile to automate the web build proc
This is also copied from my Boids project, just like the HTML page was.
2025-10-30 12:07:12 -05:00
robert fb5209a5c2 Have Bevy find assigned canvas element
Bevy creates it's own canvas element by default, but the custom page
defines its own. This makes Bevy go find that one.

The window sizing still works -- it simply resizes the canvas upon
starting. I'm not sure if I'll change that or remove the size from the
HTML. That's a tomorrow problem.
2025-10-30 12:00:09 -05:00
robert fe4e946e83 Add a custom webpage for the WASM build
It's just a copy of the page I made for my Boids program, but with all
the relevant names swapped to "asteroids".
2025-10-30 11:56:24 -05:00
robert 7c385b1557 Make dynamic linking feature a default
Basic checks / Basic build-and-test supertask (push) Successful in 7m17s
Now I don't need to keep setting the option on the command line. I'll
take it out (or use `--no-default-features`) when making the release
build.
2025-08-29 13:35:50 -05:00
robert 746de2bd80 Add "Game Over" text to the game over screen
Basic checks / Basic build-and-test supertask (push) Successful in 7m18s
2025-08-15 15:26:11 -05:00
robert 73ee5e554b Reorder ship-collision steps, rm frozen debris
When the player gets a game-over, the debris is spawned and then frozen
in place as the physics system gets turned off. I can make sure it never
appears by writing the state change and returning early from the
function.

This means the asteroid despawning needs to happen before that point,
otherwise the asteroids would be left on screen.
2025-08-15 15:02:28 -05:00
robert 0967795d51 Remove unnecessary mut on system parameter
Basic checks / Basic build-and-test supertask (push) Successful in 7m4s
2025-08-14 22:33:53 -05:00
robert 20c71658c3 Implement a basic ship debris effect
I'm stealing the thruster mesh, which itself is actually the ship's
mesh, to draw the debris particles. I'll come back and make the scatter
a bit better at some point, but for now it's passable.
2025-08-14 22:33:42 -05:00
robert 960861af79 Add a sparkler component to flash entities
I'll be using this to make a sparkling effect on the debris field left
behind from a destroyed ship.

It can also be used to do the temporary invincibility effect when
(re)spawning the player.
2025-08-14 21:57:47 -05:00
robert 4b70be7048 Fix and improve ButtonMenuAction doc comment 2025-08-14 20:54:29 -05:00
robert 8bf21e74f0 Remove Rapier debug plugin 2025-08-14 18:25:33 -05:00
robert c0cf6d7f30 Fix: reset "get-ready" timer upon showing widget
Basic checks / Basic build-and-test supertask (push) Successful in 7m21s
Closes #25: Reset "get ready" timer upon entering the get-ready state.
2025-08-14 18:20:50 -05:00
robert cc23e9e08e Despawn the player when exiting the Playing state
Closes #21: Despawn player ship when exiting `GameState::Playing`

I've also moved the `fn despawn<T>` utility to the lib.rs module.
2025-08-14 14:50:12 -05:00
robert cf9825fcc3 Fix: Starting game from GUI runs "get ready" timer
Basic checks / Basic build-and-test supertask (push) Successful in 7m14s
Closes #23: Main menu's start button doesn't run the get-ready timer

I made the start button go directly to `GameState::Playing`, which is
not actually the right state for beginning a new game. Swap the states
and everything works again.
2025-08-14 14:39:24 -05:00
robert 708f514582 Implement a proper gun fire-rate mechanism
There is now a `Weapon` component which is just a timer for the gun's
fire rate. It is ticked every frame, clamping at the "ready" state (0
time remaining).

The ship spawns with this thing, and the `input_ship_shoot` system has
been updated to use it.
2025-08-14 14:34:22 -05:00
robert 0a7ffcfa0a Add reflection & debug inspector stuff to Score 2025-08-14 13:14:32 -05:00
robert 40ee042b53 Implement the HUD for real
Now it works!... but it runs every single frame, probably causing a
bunch of unnecessary text rendering and UI layout operations. I'll have
to come back and make it event-based at some point.
2025-08-14 13:07:25 -05:00
robert 9d9b25d1df Name the profiles to not suggest they're WASM-only
Basic checks / Basic build-and-test supertask (push) Successful in 7m13s
2025-08-14 11:04:20 -05:00
robert 89ee328807 A couple extra build profiles 2025-08-14 11:04:20 -05:00
robert 90d8142855 Use wasm-server-runner as the WASM runner
This way I can `cargo run --target ...` and Cargo will spawn a dummy
webserver instead of attempting to execute the WASM file on my x86/arm
CPU.
2025-08-14 11:03:37 -05:00
robert 10366b642c Add wasm-specific feature for RNG child dependency
The `rand` crate eventually depends on `getrandom` which requires a
different feature set when running in the browser. WASM has no OS, and
so no RNG provider... but the browser, specifically, has one that the
JavaScript runtime can touch. Enabling the "wasm_js" feature on
`getrandom` allowes it to use this backend.

An extra config option must *also* be passed to `rustc`. THis can be set
through the environment, or the config.toml. I've chosen the latter so I
don't need to think about it very often.
2025-08-14 11:03:37 -05:00
robert 94e0cd0999 Add my own crate features to pass through to deps
Basic checks / Basic build-and-test supertask (push) Successful in 7m25s
Closes #20

Now this crate can be told to build with or without certain behavior,
rather than needing to patch the Cargo.toml file.
2025-08-14 10:34:03 -05:00
robert 18d026637b Bump the crate version
I marked 0.2 at some point, so I guess I should keep incrementing this
during development. The menus are finished, which is as good a
checkpoint as any.
2025-08-14 08:58:02 -05:00
robert 51e6989ef4 Swap button colors to be less upsetting
Making everything gray is still boring as dirt, but at least it doesn't
look like debug info.
2025-08-14 08:55:13 -05:00
robert 2ffc0e8861 Finish main-menu button handling
Basic checks / Basic build-and-test supertask (push) Successful in 7m8s
2025-08-13 17:25:26 -05:00
robert d15b96ef48 Add "start" and "quit" buttons to title screen
I'm stealing the game-over plugin's button handling for use in the main
menu. I guess it turns out that my widgets are more generic than
intended.
2025-08-13 17:00:29 -05:00
robert 0aefc96f7a Center the text, add a drop shadow 2025-08-13 16:03:40 -05:00
robert 4102446e90 Rename main menu marker to "MarkerMainMenu" 2025-08-13 15:38:53 -05:00
robert f4df2ae33a Rearrange the main menu components & systems
I'm trying to keep things somewhat in order. Plugins, then components,
then systems. Within those, they're roughly ordered by game state.
2025-08-13 15:36:14 -05:00
robert fc43be0777 Hook up the action selectors to the buttons
Basic checks / Basic build-and-test supertask (push) Successful in 7m8s
2025-08-13 14:22:00 -05:00
robert a74b99deb4 Visual button interaction is working, needs act
Basic checks / Basic build-and-test supertask (push) Successful in 7m22s
2025-08-13 12:59:38 -05:00
robert 2f9401e93f Begin GameOver scene, widget spawner works
I've taken a lot directly from the Bevy UI button example.
(https://bevy.org/examples/ui-user-interface/button/)

I'll make it look better later. For now, it just needs to exist. Onward
to the UI operation system!
2025-08-13 11:58:11 -05:00
robert 54ef257ab4 Make generic UI despawning function 2025-08-13 11:56:35 -05:00
robert 69bef24913 Collect GUI plugins at the top of the module
I want the different "scenes" to be their own plugins for ease of setup
and reading.

The main menu plugin has been renamed to have "Plugin" first. This is so
the lexical sort in the docs places all the plugins next to each other.

The "get-ready" plugin has been given an empty struct and an
`impl Plugin` to match the main menu plugin. I've started the game over
scene, but left it unimplemented.
2025-08-13 11:09:48 -05:00
robert df4479bf49 Remove collision debug print system 2025-08-13 10:33:59 -05:00
robert 33828d6a85 Rewrite WorldSize as a newtype around Vec2
Basic checks / Basic build-and-test supertask (push) Successful in 7m7s
Closes #16

Bevy provides Deref and DerefMut derives, so that's nice. I'm not sure
it makes any sense to keep the field private since those derefs expose
the Vec2 anyway. I added an `impl Default` anyway, though.
2025-08-12 23:39:19 -05:00
robert 5e2018d3e4 Docs for physics module 2025-08-12 23:26:37 -05:00
robert 7c877264a2 autoformat 2025-08-12 23:18:46 -05:00
robert 16842c13f7 Docs for objects.rs 2025-08-12 23:18:33 -05:00
robert e199db16eb Docs for machinery.rs 2025-08-12 23:01:32 -05:00
robert f17910daef Docs for lib.rs 2025-08-12 22:41:37 -05:00
robert 70f2313766 Improve documentation for the events
Basic checks / Basic build-and-test supertask (push) Has been cancelled
2025-08-12 11:33:00 -05:00
robert 58bbc1e614 Fix documentation links 2025-08-11 23:50:43 -05:00
robert 79679759c5 Move HUD spawning system into widgets
It actually needs to be completely replaced. When that finally happens,
the new bits will live here.
2025-08-11 23:42:06 -05:00
robert 0e517de419 Move the title screen stuff into widgets.rs 2025-08-11 23:40:52 -05:00
robert cb2b57449a Create a "widgets" module (by moving title scene)
The non-gameplay scenes are really just a bunch of widgets. I'm going to
put them all together and then bundle the functionality with some
exported plugin builders.
2025-08-11 23:39:42 -05:00
robert 9a262fcffc Move Lifetime component to machinery module 2025-08-11 23:34:12 -05:00
robert 34ee2fcc7d Create a "machinery" module for game systems
I'm not sold on the name, but anyway.

This module will hold the systems that power the main game mechanics, as
well as a few extra items to support that (in particular, the Lifetime
component).
2025-08-11 23:28:39 -05:00
robert 93da225636 Move resources to a resources.rs submodule 2025-08-11 23:19:06 -05:00
robert cd194e2dbf Move collision system to physics module 2025-08-11 23:07:18 -05:00
robert 1369a3092f Move the ship & bullet systems into the object mod 2025-08-11 23:01:14 -05:00
robert 619037dab0 Move asteroid spawning & splitting systems
They deal with events, but are directly related to how the Asteroid
object interacts with the events, so I'm putting them here.
2025-08-11 22:59:20 -05:00
robert c1b69c412a autoformat 2025-08-11 22:48:08 -05:00
robert d8a83b77c2 Move ship & bullet to the objects module 2025-08-11 22:47:48 -05:00
robert f5ff7c8779 Move Asteroid components to the objects.rs mod 2025-08-11 22:44:05 -05:00
robert f4484f759f Move SpawnAsteroid event into events.rs 2025-08-11 19:16:34 -05:00
robert 571b910945 Rename "event" module to be plural "events.rs" 2025-08-11 19:14:22 -05:00
robert 804186ea2f Handle player ship destruction... some of it...
Basic checks / Basic build-and-test supertask (push) Has been cancelled
The player will be respawned, their lives decreased, and the board
cleared. The UI doesn't update, and the sudden snap to a freshly reset
board is quite jarring. The state transition to GameOver stops the game,
but there isn't anything else running in that state so it just looks
frozen.

Basically, there's a ton left to do, but technically I have handled
player ship destruction!
2025-08-10 21:29:25 -05:00
robert 45b1fe751f Create the asteroid splitter to break down rocks.
Basic checks / Basic build-and-test supertask (push) Has been cancelled
2025-08-10 20:45:08 -05:00
robert 3d28d489b0 Fix: Pass size through to spawned asteroid
I actually have most of the asteroid's destruction handling system done
and found this bug.

Asteroid *assets* are selected based on the size set in the spawn event,
but the `Asteroid` Component itself was left hard-coded to the smallest
size.
2025-08-10 18:46:49 -05:00
robert cdd665cc93 Add bullet on-impact despawning system 2025-08-10 18:43:56 -05:00
robert 364fbd7530 Use the lifetime limiters on Bullets & Asteroids
Basic checks / Basic build-and-test supertask (push) Successful in 7m3s
Closes #14

Despawn bullets to limit range.

Despawn asteroids to limit random garbage floating around the scene.
2025-08-10 17:14:26 -05:00
robert 2f463303a0 Create Lifetime component and system
Closes #13

The lifetime component, and system to operate it, are ready! Now I can
delete things that have lived for too long.
2025-08-10 17:07:20 -05:00
robert 8d689d7842 Wire in the bullet & asteroid destruction events 2025-08-10 16:49:22 -05:00
robert 65f28e832f Implement basic gun controller
Basic checks / Basic build-and-test supertask (push) Successful in 7m3s
The spacebar fires the gun, bullets are spawned on top of the ship with
a velocity that sends them forward (relative to the ship).

I still need a despawn mechanism, and a fire rate control. To despawn
things, I'm already planning a `Lifetime` component. For rate of fire,
an additional component will be created and attached to the player ship.
2025-08-10 13:30:42 -05:00
robert dea8a0dc1a Fix: apply thrust input properly
Basic checks / Basic build-and-test supertask (push) Successful in 7m11s
Yay for funny coordinate spaces. I was, again, using the wrong
operations to get the 2D Cartesian angle and apply force to the ship.
2025-08-09 16:25:19 -05:00
robert 6191fde25a Fix: apply steering input properly
The ship in Asteroids isn't expected to spin up while holding a steering
direction, but that's exactly what I just made it do.

Fix that problem by assigning, not accumulating, the angular velocity
for the ship.
2025-08-09 16:09:54 -05:00