Compare commits
2 Commits
a48dfc1d65
...
b1fd2e5f73
| Author | SHA1 | Date | |
|---|---|---|---|
| b1fd2e5f73 | |||
| 09ff4dc6ca |
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -242,7 +242,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "asteroids"
|
||||
version = "0.6.0-dev1"
|
||||
version = "0.6.0-dev2"
|
||||
dependencies = [
|
||||
"bevy",
|
||||
"bevy-inspector-egui",
|
||||
|
||||
@@ -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
14
README.md
Normal 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].
|
||||
BIN
assets/explosionCrunch_004.ogg
Normal file
BIN
assets/explosionCrunch_004.ogg
Normal file
Binary file not shown.
@@ -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,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user