2 Commits

Author SHA1 Message Date
b1fd2e5f73 Add a readme
Some checks failed
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
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
6 changed files with 37 additions and 4 deletions

2
Cargo.lock generated
View File

@@ -242,7 +242,7 @@ dependencies = [
[[package]]
name = "asteroids"
version = "0.6.0-dev1"
version = "0.6.0-dev2"
dependencies = [
"bevy",
"bevy-inspector-egui",

View File

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

14
README.md Normal file
View File

@@ -0,0 +1,14 @@
# Asteroids
*Another* Asteroids game I'm making. This time in Rust with the Bevy game engine.
## License
| File(s) | License |
|-|-|
| * | AGPLv3 |
| assets/* | CC0 |
(the most-specific match is the applicable license)
The sound files are from KenneyNL's "Sci-Fi Sounds (1.0)" pack. Find their work at [www.kenney.nl].

Binary file not shown.

View File

@@ -3,6 +3,7 @@
//! Asteroids, the player's ship, and such.
use bevy::{
audio::{AudioPlayer, PlaybackSettings},
camera::visibility::Visibility,
ecs::{
component::Component,
@@ -232,5 +233,11 @@ pub fn ship_impact_listener(
// STEP 4: Respawn player (teleport them to the origin)
player.0.translation = Vec3::ZERO;
player.1.0 = Vec2::ZERO;
// STEP 5: Play crash sound
commands.spawn((
AudioPlayer::new(game_assets.wreck_sound()),
PlaybackSettings::ONCE,
));
}
}

View File

@@ -1,7 +1,8 @@
//! All the resources for the game
use bevy::{
asset::{Assets, Handle},
asset::{AssetServer, Assets, Handle},
audio::AudioSource,
ecs::{
resource::Resource,
world::{FromWorld, World},
@@ -57,6 +58,7 @@ impl Default for WorldSize {
pub struct GameAssets {
meshes: [Handle<Mesh>; 5],
materials: [Handle<ColorMaterial>; 7],
sounds: [Handle<AudioSource>; 1],
}
impl GameAssets {
@@ -95,6 +97,10 @@ impl GameAssets {
pub fn bullet(&self) -> (Handle<Mesh>, Handle<ColorMaterial>) {
(self.meshes[4].clone(), self.materials[6].clone())
}
pub fn wreck_sound(&self) -> Handle<AudioSource> {
self.sounds[0].clone()
}
}
impl FromWorld for GameAssets {
@@ -122,6 +128,12 @@ impl FromWorld for GameAssets {
world_materials.add(ASTEROID_SMALL_COLOR),
world_materials.add(BULLET_COLOR),
];
GameAssets { meshes, materials }
let loader = world.resource_mut::<AssetServer>();
let sounds = [loader.load("explosionCrunch_004.ogg")];
GameAssets {
meshes,
materials,
sounds,
}
}
}