Compare commits
8 Commits
v0.6.0
...
12c303d0ab
| Author | SHA1 | Date | |
|---|---|---|---|
| 12c303d0ab | |||
| 03b985ee57 | |||
| 16b118f37d | |||
| 172b528138 | |||
| 70de4bb67d | |||
| ebee953955 | |||
| d2cb75c3a1 | |||
| 099926d368 |
@@ -18,7 +18,12 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
components: rustfmt clippy
|
components: rustfmt clippy
|
||||||
- name: Install system dependencies
|
- 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
|
- name : cargo generate-lockfile
|
||||||
if: hashFiles('Cargo.lock') == ''
|
if: hashFiles('Cargo.lock') == ''
|
||||||
run: cargo generate-lockfile
|
run: cargo generate-lockfile
|
||||||
@@ -41,6 +46,6 @@ jobs:
|
|||||||
name: roberts-bad-asteroids-game
|
name: roberts-bad-asteroids-game
|
||||||
path: target/release/asteroids
|
path: target/release/asteroids
|
||||||
if-no-files-found: 'error'
|
if-no-files-found: 'error'
|
||||||
retention-days: 1
|
retention-days: 7
|
||||||
compression-level: 9
|
compression-level: 9
|
||||||
overwrite: true
|
overwrite: true
|
||||||
|
|||||||
94
.gitea/workflows/check.yml
Normal file
94
.gitea/workflows/check.yml
Normal 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
|
||||||
6
Cargo.lock
generated
6
Cargo.lock
generated
@@ -242,7 +242,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "asteroids"
|
name = "asteroids"
|
||||||
version = "0.6.0"
|
version = "0.6.2"
|
||||||
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"
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "asteroids"
|
name = "asteroids"
|
||||||
version = "0.6.0"
|
version = "0.6.2"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
license = "AGPL-3.0-only"
|
license = "AGPL-3.0-only"
|
||||||
|
rust-version = "1.88.0"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bevy = "0.17"
|
bevy = "0.17"
|
||||||
|
|||||||
2
Makefile
2
Makefile
@@ -76,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/
|
||||||
|
|||||||
@@ -217,7 +217,7 @@ fn input_ship_shoot(
|
|||||||
physics::Velocity(bullet_vel),
|
physics::Velocity(bullet_vel),
|
||||||
Mesh2d(game_assets.bullet().0),
|
Mesh2d(game_assets.bullet().0),
|
||||||
MeshMaterial2d(game_assets.bullet().1),
|
MeshMaterial2d(game_assets.bullet().1),
|
||||||
ship_pos.clone(), // clone ship transform
|
*ship_pos, // clone ship transform
|
||||||
Lifetime(Timer::from_seconds(BULLET_LIFETIME, TimerMode::Once)),
|
Lifetime(Timer::from_seconds(BULLET_LIFETIME, TimerMode::Once)),
|
||||||
AudioPlayer::new(game_assets.laser_sound()),
|
AudioPlayer::new(game_assets.laser_sound()),
|
||||||
PlaybackSettings::ONCE, // `Lifetime` already despawns the entity, so this doesn't need to
|
PlaybackSettings::ONCE, // `Lifetime` already despawns the entity, so this doesn't need to
|
||||||
|
|||||||
18
src/main.rs
18
src/main.rs
@@ -1,11 +1,15 @@
|
|||||||
use bevy::{prelude::*, window::WindowResolution};
|
use bevy::{prelude::*, window::WindowResolution};
|
||||||
|
|
||||||
use asteroids::{AsteroidPlugin, config::WINDOW_SIZE};
|
use asteroids::{AsteroidPlugin, config::WINDOW_SIZE};
|
||||||
|
|
||||||
|
#[cfg(feature = "debug_ui")]
|
||||||
use bevy_inspector_egui::{bevy_egui::EguiPlugin, quick::WorldInspectorPlugin};
|
use bevy_inspector_egui::{bevy_egui::EguiPlugin, quick::WorldInspectorPlugin};
|
||||||
|
#[cfg(feature = "debug_ui")]
|
||||||
|
use bevy_rapier2d::render::RapierDebugRenderPlugin;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
App::new()
|
let mut app = App::new();
|
||||||
.add_plugins(DefaultPlugins.set(WindowPlugin {
|
app.add_plugins(DefaultPlugins.set(WindowPlugin {
|
||||||
primary_window: Some(Window {
|
primary_window: Some(Window {
|
||||||
canvas: Some("#game-canvas".to_owned()),
|
canvas: Some("#game-canvas".to_owned()),
|
||||||
resolution: WindowResolution::new(WINDOW_SIZE.0, WINDOW_SIZE.1),
|
resolution: WindowResolution::new(WINDOW_SIZE.0, WINDOW_SIZE.1),
|
||||||
@@ -13,8 +17,12 @@ fn main() {
|
|||||||
}),
|
}),
|
||||||
..default()
|
..default()
|
||||||
}))
|
}))
|
||||||
.add_plugins(AsteroidPlugin)
|
.add_plugins(AsteroidPlugin);
|
||||||
.add_plugins(EguiPlugin::default())
|
|
||||||
|
#[cfg(feature = "debug_ui")]
|
||||||
|
app.add_plugins(EguiPlugin::default())
|
||||||
.add_plugins(WorldInspectorPlugin::new())
|
.add_plugins(WorldInspectorPlugin::new())
|
||||||
.run();
|
.add_plugins(RapierDebugRenderPlugin::default());
|
||||||
|
|
||||||
|
app.run();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -238,7 +238,7 @@ pub fn ship_impact_listener(
|
|||||||
Sparkler::at_interval(0.15),
|
Sparkler::at_interval(0.15),
|
||||||
Mesh2d(game_assets.thruster_mesh()), // borrow the thruster mesh for now
|
Mesh2d(game_assets.thruster_mesh()), // borrow the thruster mesh for now
|
||||||
MeshMaterial2d(game_assets.thruster_mat_active()), // ... and the active thruster material
|
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),
|
Velocity(vel),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -111,30 +111,22 @@ pub fn collision_listener(
|
|||||||
if *one == *player {
|
if *one == *player {
|
||||||
if rocks.contains(*two) {
|
if rocks.contains(*two) {
|
||||||
// player-asteroid collision
|
// player-asteroid collision
|
||||||
dbg!("Writing ShipDestroy event");
|
|
||||||
ship_writer.write(messages::ShipDestroy);
|
ship_writer.write(messages::ShipDestroy);
|
||||||
} // else, we don't care
|
} // else, we don't care
|
||||||
} else if *two == *player {
|
} else if *two == *player && rocks.contains(*one) {
|
||||||
if rocks.contains(*one) {
|
|
||||||
dbg!("Writing ShipDestroy event");
|
|
||||||
ship_writer.write(messages::ShipDestroy);
|
ship_writer.write(messages::ShipDestroy);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Option 2: Bullet & Asteroid
|
// Option 2: Bullet & Asteroid
|
||||||
if bullets.contains(*one) {
|
if bullets.contains(*one) {
|
||||||
if rocks.contains(*two) {
|
if rocks.contains(*two) {
|
||||||
dbg!("Writing AsteroidDestroy & BulletDestroy events");
|
|
||||||
asteroid_writer.write(messages::AsteroidDestroy(*two));
|
asteroid_writer.write(messages::AsteroidDestroy(*two));
|
||||||
bullet_writer.write(messages::BulletDestroy(*one));
|
bullet_writer.write(messages::BulletDestroy(*one));
|
||||||
}
|
}
|
||||||
} else if rocks.contains(*one) {
|
} else if rocks.contains(*one) && bullets.contains(*two) {
|
||||||
if bullets.contains(*two) {
|
|
||||||
dbg!("Writing AsteroidDestroy & BulletDestroy events");
|
|
||||||
asteroid_writer.write(messages::AsteroidDestroy(*one));
|
asteroid_writer.write(messages::AsteroidDestroy(*one));
|
||||||
bullet_writer.write(messages::BulletDestroy(*two));
|
bullet_writer.write(messages::BulletDestroy(*two));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ use crate::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use bevy::{
|
use bevy::{
|
||||||
color::palettes::css::{BLACK, DARK_GRAY, GREEN, LIGHT_BLUE, RED, WHITE},
|
color::palettes::css::{BLACK, DARK_GRAY, GREEN, RED, WHITE},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -263,6 +263,7 @@ fn animate_get_ready_widget(
|
|||||||
/// on the HUD, this system would quit the game. The same will happen for
|
/// 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
|
/// returning to the title screen. This should be useful for making a pause
|
||||||
/// menu, too.
|
/// menu, too.
|
||||||
|
#[allow(clippy::type_complexity)]
|
||||||
fn operate_buttons(
|
fn operate_buttons(
|
||||||
mut interactions: Query<
|
mut interactions: Query<
|
||||||
(
|
(
|
||||||
|
|||||||
@@ -119,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.6.0</code></td>
|
<td><code>v0.6.1</code></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</article>
|
</article>
|
||||||
|
|||||||
Reference in New Issue
Block a user