9 Commits

Author SHA1 Message Date
23e4ef3093 Release v0.7.0
Some checks failed
Basic checks / Basic build-and-test supertask (push) Has been cancelled
check / nightly / doc (push) Has been cancelled
check / ubuntu / stable / features (push) Has been cancelled
check / ubuntu / 1.88.0 (push) Has been cancelled
check / stable / fmt (push) Has been cancelled
2025-12-26 10:35:45 -06:00
235d89ebb3 Automatically fill version info in index.html 2025-12-26 10:34:45 -06:00
12c303d0ab Pull in the check workflow from my Boids repo
Some checks failed
Basic checks / Basic build-and-test supertask (push) Has been cancelled
check / nightly / doc (push) Has been cancelled
check / ubuntu / stable / features (push) Has been cancelled
check / ubuntu / 1.88.0 (push) Has been cancelled
check / stable / fmt (push) Has been cancelled
Which is, in turn, something Jonhoo put together. See the comments in
the file for more.

I mainly want the feature combination checking that this should do.
2025-12-25 23:39:25 -06:00
03b985ee57 Record MSRV in Cargo.toml (currently 1.88) 2025-12-25 23:39:11 -06:00
16b118f37d Update basic.yml workflow for Bevy 0.17
This thing has been broken since a48dfc1d65 (v0.5.0 + 1) when the game
was upgraded to Bevy 0.17. Install the libwayland-dev package to get the
CI runner building correctly again.

I also increased the artifact retention period to 7 days... I'm not sure
I actually want to keep any artifacts, but if I'm going to then I should
keep them long enough for me to go back and look at them.
2025-12-25 23:35:20 -06:00
172b528138 Mark v0.6.2 release: Removed debug noise
Some checks failed
Basic checks / Basic build-and-test supertask (push) Failing after 1m10s
I've removed a bit of the debug stuff from the program -- mainly the
egui-inspector UI, but also some debug prints that were still happening
in the physics module.
2025-12-22 10:41:52 -06:00
70de4bb67d Remove debug prints in physics.rs 2025-12-22 10:39:40 -06:00
ebee953955 Hide egui-inspector window behind feature flag
The World Inspector widget shouldn't be enabled by default. This hides
it behind the "debug_ui" feature flag, along with the bevy_rapier2d
debug drawings.

The bevy_rapier2d debug plugin is now added when in debug mode, which
was not previously the case.
2025-12-21 16:45:52 -06:00
d2cb75c3a1 Apply clippy fixes 2025-12-20 09:38:46 -06:00
11 changed files with 170 additions and 64 deletions

View File

@@ -18,7 +18,12 @@ jobs:
with:
components: rustfmt clippy
- name: Install system dependencies
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends libasound2-dev libudev-dev
run: >
sudo apt-get update &&
sudo apt-get install -y --no-install-recommends
libasound2-dev
libudev-dev
libwayland-dev
- name : cargo generate-lockfile
if: hashFiles('Cargo.lock') == ''
run: cargo generate-lockfile
@@ -41,6 +46,6 @@ jobs:
name: roberts-bad-asteroids-game
path: target/release/asteroids
if-no-files-found: 'error'
retention-days: 1
retention-days: 7
compression-level: 9
overwrite: true

View File

@@ -0,0 +1,94 @@
# This workflow runs whenever a PR is opened or updated, or a commit is pushed to main. It runs
# several checks:
# - fmt: checks that the code is formatted according to rustfmt
# - clippy: checks that the code does not contain any clippy warnings
# - doc: checks that the code can be documented without errors
# - hack: check combinations of feature flags
# - msrv: check that the msrv specified in the crate is correct
permissions:
contents: read
# This configuration allows maintainers of this repo to create a branch and pull request based on
# the new branch. Restricting the push trigger to the main branch ensures that the PR only gets
# built once.
on:
push:
branches: [trunk]
pull_request:
# If new code is pushed to a PR branch, then cancel in progress workflows for that PR. Ensures that
# we don't waste CI time, and returns results quicker https://github.com/jonhoo/rust-ci-conf/pull/5
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
name: check
jobs:
fmt:
runs-on: ubuntu-latest
name: stable / fmt
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Install stable
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- name: cargo fmt --check
run: cargo fmt --check
doc:
# run docs generation on nightly rather than stable. This enables features like
# https://doc.rust-lang.org/beta/unstable-book/language-features/doc-cfg.html which allows an
# API be documented as only available in some specific platforms.
runs-on: ubuntu-latest
name: nightly / doc
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Install Dependencies
run: sudo apt-get update; sudo apt-get install -y --no-install-recommends libasound2-dev libudev-dev libwayland-dev
- name: Install nightly
uses: dtolnay/rust-toolchain@nightly
- name: cargo doc
run: cargo doc --no-deps --all-features
env:
RUSTDOCFLAGS: --cfg docsrs
hack:
# cargo-hack checks combinations of feature flags to ensure that features are all additive
# which is required for feature unification
runs-on: ubuntu-latest
name: ubuntu / stable / features
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Install Dependencies
run: sudo apt-get update; sudo apt-get install -y --no-install-recommends libasound2-dev libudev-dev libwayland-dev cmake
- name: Install stable
uses: dtolnay/rust-toolchain@stable
- name: cargo install cargo-hack
uses: taiki-e/install-action@cargo-hack
# intentionally no target specifier; see https://github.com/jonhoo/rust-ci-conf/pull/4
# --feature-powerset runs for every combination of features
- name: cargo hack
run: cargo hack --feature-powerset check
msrv:
# check that we can build using the minimal rust version that is specified by this crate
runs-on: ubuntu-latest
# we use a matrix here just because env can't be used in job names
# https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability
strategy:
matrix:
msrv: ["1.88.0"]
name: ubuntu / ${{ matrix.msrv }}
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Install Dependencies
run: sudo apt-get update; sudo apt-get install -y --no-install-recommends libasound2-dev libudev-dev libwayland-dev
- name: Install ${{ matrix.msrv }}
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.msrv }}
- name: cargo +${{ matrix.msrv }} check
run: cargo check

64
Cargo.lock generated
View File

@@ -242,7 +242,7 @@ dependencies = [
[[package]]
name = "asteroids"
version = "0.6.1"
version = "0.7.0"
dependencies = [
"bevy",
"bevy-inspector-egui",
@@ -302,9 +302,9 @@ dependencies = [
[[package]]
name = "async-lock"
version = "3.4.1"
version = "3.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5fd03604047cee9b6ce9de9f70c6cd540a0520c813cbd49bae61f33ab80ed1dc"
checksum = "290f7f2596bd5b78a9fec8088ccd89180d7f9f55b94b0576823bbbdc72ee8311"
dependencies = [
"event-listener",
"event-listener-strategy",
@@ -1848,9 +1848,9 @@ dependencies = [
[[package]]
name = "cc"
version = "1.2.50"
version = "1.2.51"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9f50d563227a1c37cc0a263f64eca3334388c01c5e4c4861a9def205c614383c"
checksum = "7a0aeaff4ff1a90589618835a598e545176939b97874f7abc7851caa0618f203"
dependencies = [
"find-msvc-tools",
"jobserver",
@@ -2194,18 +2194,18 @@ checksum = "2a2330da5de22e8a3cb63252ce2abb30116bf5265e89c0e01bc17015ce30a476"
[[package]]
name = "derive_more"
version = "2.1.0"
version = "2.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "10b768e943bed7bf2cab53df09f4bc34bfd217cdb57d971e769874c9a6710618"
checksum = "d751e9e49156b02b44f9c1815bcb94b984cdcc4396ecc32521c739452808b134"
dependencies = [
"derive_more-impl",
]
[[package]]
name = "derive_more-impl"
version = "2.1.0"
version = "2.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6d286bfdaf75e988b4a78e013ecd79c581e06399ab53fbacd2d916c2f904f30b"
checksum = "799a97264921d8623a957f6c3b9011f3b5492f557bbb7a5a19b7fa6d06ba8dcb"
dependencies = [
"convert_case",
"proc-macro2",
@@ -2491,9 +2491,9 @@ dependencies = [
[[package]]
name = "find-msvc-tools"
version = "0.1.5"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3a3076410a55c90011c298b04d0cfa770b00fa04e1e3c97d3f6c9de105a03844"
checksum = "645cbb3a84e60b7531617d5ae4e57f7e27308f6445f5abf653209ea76dec8dff"
[[package]]
name = "fixedbitset"
@@ -2646,7 +2646,7 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1bd49230192a3797a9a4d6abe9b3eed6f7fa4c8a8a4947977c6f80025f92cbd8"
dependencies = [
"rustix 1.1.2",
"rustix 1.1.3",
"windows-link 0.2.1",
]
@@ -3212,9 +3212,9 @@ dependencies = [
[[package]]
name = "itoa"
version = "1.0.15"
version = "1.0.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c"
checksum = "7ee5b5339afb4c41626dde77b7a611bd4f2c202b897852b4bcf5d03eddc61010"
[[package]]
name = "jni"
@@ -3661,9 +3661,9 @@ dependencies = [
[[package]]
name = "ntapi"
version = "0.4.1"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8a3895c6391c39d7fe7ebc444a87eb2991b2a0bc718fdabd071eec617fc68e4"
checksum = "c70f219e21142367c70c0b30c6a9e3a14d55b4d12a204d897fbec83a0363f081"
dependencies = [
"winapi",
]
@@ -4289,7 +4289,7 @@ dependencies = [
"concurrent-queue",
"hermit-abi",
"pin-project-lite",
"rustix 1.1.2",
"rustix 1.1.3",
"windows-sys 0.61.2",
]
@@ -4660,9 +4660,9 @@ dependencies = [
[[package]]
name = "rustix"
version = "1.1.2"
version = "1.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cd15f8a2c5551a84d56efdc1cd049089e409ac19a3072d5037a17fd70719ff3e"
checksum = "146c9e247ccc180c1f61615433868c99f3de3ae256a30a43b49f67c2d9171f34"
dependencies = [
"bitflags 2.10.0",
"errno",
@@ -4703,12 +4703,6 @@ dependencies = [
"twox-hash",
]
[[package]]
name = "ryu"
version = "1.0.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f"
[[package]]
name = "safe_arch"
version = "0.7.4"
@@ -4802,15 +4796,15 @@ dependencies = [
[[package]]
name = "serde_json"
version = "1.0.145"
version = "1.0.147"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "402a6f66d8c709116cf22f558eab210f5a50187f702eb4d7e5ef38d9a7f1c79c"
checksum = "6af14725505314343e673e9ecb7cd7e8a36aa9791eb936235a3567cc31447ae4"
dependencies = [
"itoa",
"memchr",
"ryu",
"serde",
"serde_core",
"zmij",
]
[[package]]
@@ -5525,7 +5519,7 @@ checksum = "673a33c33048a5ade91a6b139580fa174e19fb0d23f396dca9fa15f2e1e49b35"
dependencies = [
"cc",
"downcast-rs 1.2.1",
"rustix 1.1.2",
"rustix 1.1.3",
"scoped-tls",
"smallvec",
"wayland-sys",
@@ -5538,7 +5532,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c66a47e840dc20793f2264eb4b3e4ecb4b75d91c0dd4af04b456128e0bdd449d"
dependencies = [
"bitflags 2.10.0",
"rustix 1.1.2",
"rustix 1.1.3",
"wayland-backend",
"wayland-scanner",
]
@@ -5560,7 +5554,7 @@ version = "0.31.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "447ccc440a881271b19e9989f75726d60faa09b95b0200a9b7eb5cc47c3eeb29"
dependencies = [
"rustix 1.1.2",
"rustix 1.1.3",
"wayland-client",
"xcursor",
]
@@ -6474,7 +6468,7 @@ dependencies = [
"libc",
"libloading",
"once_cell",
"rustix 1.1.2",
"rustix 1.1.3",
"x11rb-protocol",
]
@@ -6624,6 +6618,12 @@ dependencies = [
"syn",
]
[[package]]
name = "zmij"
version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d0095ecd462946aa3927d9297b63ef82fb9a5316d7a37d134eeb36e58228615a"
[[package]]
name = "zune-core"
version = "0.4.12"

View File

@@ -1,8 +1,9 @@
[package]
name = "asteroids"
version = "0.6.1"
version = "0.7.0"
edition = "2024"
license = "AGPL-3.0-only"
rust-version = "1.88.0"
[dependencies]
bevy = "0.17"

View File

@@ -3,18 +3,23 @@
## Do not use it if that isn't your goal!
##
# # # Configuration Variables # # #
#
# Patch these to select a different build profile or target
# The target shouldn't change any time soon. WASM64, I guess. Other targets
# aren't aimed at the web, so you shouldn't be using this makefile.
CARGO_TARGET := wasm32-unknown-unknown
CARGO_PROFILE := tiny
# # # Automatic Variables # # #
SRC_DIR = ./src
SRCS := $(wildcard $(SRC_DIR)/**)
ASSET_SOURCE := $(wildcard assets/**)
ASSETS := $(patsubst assets/%.ogg, out/assets/%.ogg, $(ASSET_SOURCE))
CRATE_VERSION != sed -nre 's/^version = "(.*)"/\1/p' Cargo.toml
.PHONY: clean full-clean tarball tarball-standalone web web-standalone
# "Standalone" version. It includes an index.html to serve as-is
@@ -56,6 +61,7 @@ out/asteroids.js out/asteroids_bg.wasm.gz &: target/$(CARGO_TARGET)/$(CARGO_PROF
out/index.html: www/index.html
cp -a $< $@
rm -f out/asteroids.html
sed -i -e "s/#CRATE_VERSION_PLACEHOLDER#/$(CRATE_VERSION)/" $@
# Like `out/index.html`, but renames the page for use in a larger site.
out/asteroids.html: www/index.html

View File

@@ -217,7 +217,7 @@ fn input_ship_shoot(
physics::Velocity(bullet_vel),
Mesh2d(game_assets.bullet().0),
MeshMaterial2d(game_assets.bullet().1),
ship_pos.clone(), // clone ship transform
*ship_pos, // clone ship transform
Lifetime(Timer::from_seconds(BULLET_LIFETIME, TimerMode::Once)),
AudioPlayer::new(game_assets.laser_sound()),
PlaybackSettings::ONCE, // `Lifetime` already despawns the entity, so this doesn't need to

View File

@@ -1,11 +1,15 @@
use bevy::{prelude::*, window::WindowResolution};
use asteroids::{AsteroidPlugin, config::WINDOW_SIZE};
#[cfg(feature = "debug_ui")]
use bevy_inspector_egui::{bevy_egui::EguiPlugin, quick::WorldInspectorPlugin};
#[cfg(feature = "debug_ui")]
use bevy_rapier2d::render::RapierDebugRenderPlugin;
fn main() {
App::new()
.add_plugins(DefaultPlugins.set(WindowPlugin {
let mut app = App::new();
app.add_plugins(DefaultPlugins.set(WindowPlugin {
primary_window: Some(Window {
canvas: Some("#game-canvas".to_owned()),
resolution: WindowResolution::new(WINDOW_SIZE.0, WINDOW_SIZE.1),
@@ -13,8 +17,12 @@ fn main() {
}),
..default()
}))
.add_plugins(AsteroidPlugin)
.add_plugins(EguiPlugin::default())
.add_plugins(AsteroidPlugin);
#[cfg(feature = "debug_ui")]
app.add_plugins(EguiPlugin::default())
.add_plugins(WorldInspectorPlugin::new())
.run();
.add_plugins(RapierDebugRenderPlugin::default());
app.run();
}

View File

@@ -238,7 +238,7 @@ pub fn ship_impact_listener(
Sparkler::at_interval(0.15),
Mesh2d(game_assets.thruster_mesh()), // borrow the thruster mesh for now
MeshMaterial2d(game_assets.thruster_mat_active()), // ... and the active thruster material
player.0.clone(), // clone the player transform
*player.0, // clone the player transform
Velocity(vel),
));
}

View File

@@ -111,30 +111,22 @@ pub fn collision_listener(
if *one == *player {
if rocks.contains(*two) {
// player-asteroid collision
dbg!("Writing ShipDestroy event");
ship_writer.write(messages::ShipDestroy);
} // else, we don't care
} else if *two == *player {
if rocks.contains(*one) {
dbg!("Writing ShipDestroy event");
} else if *two == *player && rocks.contains(*one) {
ship_writer.write(messages::ShipDestroy);
}
}
// Option 2: Bullet & Asteroid
if bullets.contains(*one) {
if rocks.contains(*two) {
dbg!("Writing AsteroidDestroy & BulletDestroy events");
asteroid_writer.write(messages::AsteroidDestroy(*two));
bullet_writer.write(messages::BulletDestroy(*one));
}
} else if rocks.contains(*one) {
if bullets.contains(*two) {
dbg!("Writing AsteroidDestroy & BulletDestroy events");
} else if rocks.contains(*one) && bullets.contains(*two) {
asteroid_writer.write(messages::AsteroidDestroy(*one));
bullet_writer.write(messages::BulletDestroy(*two));
}
}
}
}
}

View File

@@ -8,7 +8,7 @@ use crate::{
};
use bevy::{
color::palettes::css::{BLACK, DARK_GRAY, GREEN, LIGHT_BLUE, RED, WHITE},
color::palettes::css::{BLACK, DARK_GRAY, GREEN, RED, WHITE},
prelude::*,
};
@@ -263,6 +263,7 @@ fn animate_get_ready_widget(
/// on the HUD, this system would quit the game. The same will happen for
/// returning to the title screen. This should be useful for making a pause
/// menu, too.
#[allow(clippy::type_complexity)]
fn operate_buttons(
mut interactions: Query<
(

View File

@@ -118,8 +118,7 @@
</tr>
<tr>
<td>Program Version</td>
<!-- This version text is completely unchecked. I'll need to do something about that. -->
<td><code>v0.6.1</code></td>
<td><code>#CRATE_VERSION_PLACEHOLDER#</code></td>
</tr>
</table>
</article>