Skip to content

Commit 7a8d408

Browse files
committed
feat: Add game won sound effect
1 parent f96c701 commit 7a8d408

File tree

9 files changed

+32
-10
lines changed

9 files changed

+32
-10
lines changed

CREDITS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Disclaimer: I do NOT own any of these assets. All of them are licensed under a license similar to CC0 (as of writing this at least). If you want to use any of these assets yourself, follow the link to the corresponding asset and download it from there.
44

5-
Any assets that are in the game and not listed here are made by me (@PraxTube, unless I have forgotten to add them, it wasn't an accident!) and follow the same license as the [the rest of the project](https://github.com/PraxTube/magus-parvus/blob/master/LICENSE).
5+
Any assets that are in the game and not listed here are made by me (@PraxTube, unless I have forgotten to list them here, it wasn't on purpose!) and follow the same license as the [the rest of the project](https://github.com/PraxTube/magus-parvus/blob/master/LICENSE).
66

77
## Pixel Art
88

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
A cozy little 2D top down mage game. You cast spells by typing their name.
44
You can play the game [over on itch](https://praxtube.itch.io/magus-parvus).
55

6+
<p align="center">
7+
<img src="docs/demo/screenshot.jpg" alt="screenshot" />
8+
</p>
9+
610
<p align="center">
711
<img src="docs/demo/showcase.gif" alt="animated" />
812
</p>

assets/sounds/game_won.ogg

65.9 KB
Binary file not shown.

docs/demo/screenshot.jpg

125 KB
Loading

src/assets.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,8 @@ pub struct GameAssets {
228228
#[asset(path = "sounds/earth_wall.ogg")]
229229
pub earth_wall_sound: Handle<AudioSource>,
230230

231+
#[asset(path = "sounds/game_won.ogg")]
232+
pub game_won_sound: Handle<AudioSource>,
231233
#[asset(path = "sounds/game_over.ogg")]
232234
pub game_over_sound: Handle<AudioSource>,
233235

src/ui/game_over_ui.rs

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use bevy::prelude::*;
22

33
use crate::{
44
audio::{GameAudio, PlaySound},
5+
player::speed_timer::SpeedTimer,
56
GameAssets, GameState,
67
};
78

@@ -47,15 +48,27 @@ fn spawn_title(commands: &mut Commands, font: Handle<Font>) -> Entity {
4748
commands.spawn((GameOverScreen, text_bundle)).id()
4849
}
4950

50-
fn spawn_text(commands: &mut Commands, font: Handle<Font>) {
51+
fn spawn_time(commands: &mut Commands, font: Handle<Font>, time: f32) -> Entity {
52+
let text = format!("TIME: {:.2} seconds", time);
53+
let text_style = TextStyle {
54+
font,
55+
font_size: 60.0,
56+
color: Color::WHITE,
57+
};
58+
let text_bundle = TextBundle::from_sections([TextSection::new(text, text_style.clone())]);
59+
commands.spawn((GameOverScreen, text_bundle)).id()
60+
}
61+
62+
fn spawn_text(commands: &mut Commands, font: Handle<Font>, time: f32) {
5163
let title_text = spawn_title(commands, font.clone());
64+
let time_text = spawn_time(commands, font.clone(), time);
5265

5366
commands
5467
.spawn((
5568
GameOverScreen,
5669
NodeBundle {
5770
style: Style {
58-
top: Val::Percent(35.0),
71+
top: Val::Percent(30.0),
5972
width: Val::Percent(100.0),
6073
flex_direction: FlexDirection::Column,
6174
row_gap: Val::Vh(10.0),
@@ -67,7 +80,7 @@ fn spawn_text(commands: &mut Commands, font: Handle<Font>) {
6780
..default()
6881
},
6982
))
70-
.push_children(&[title_text]);
83+
.push_children(&[title_text, time_text]);
7184
}
7285

7386
fn spawn_audio_silence_timer(commands: &mut Commands) {
@@ -77,9 +90,13 @@ fn spawn_audio_silence_timer(commands: &mut Commands) {
7790
)));
7891
}
7992

80-
fn spawn_game_over_screen(mut commands: Commands, assets: Res<GameAssets>) {
93+
fn spawn_game_over_screen(
94+
mut commands: Commands,
95+
assets: Res<GameAssets>,
96+
speed_timer: Res<SpeedTimer>,
97+
) {
8198
spawn_background(&mut commands, assets.white_pixel.clone());
82-
spawn_text(&mut commands, assets.font.clone());
99+
spawn_text(&mut commands, assets.font.clone(), speed_timer.elapsed);
83100
spawn_audio_silence_timer(&mut commands);
84101
}
85102

src/ui/spell_book/bundle.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,7 @@ pub struct SpellbookViewDescriptionBundle {
153153
impl SpellbookViewDescriptionBundle {
154154
pub fn new(assets: &Res<GameAssets>) -> Self {
155155
let value = "Walk up to a statue and defeat all slimes.".to_string()
156-
+ " You will get a new spell from each statue.\n"
157-
+ "Press 'i' to open your spell console and type your spell. Try 'fireball'.";
156+
+ " You will get a new spell from each statue.\n";
158157
Self {
159158
spellbook_view_description: SpellbookViewDescription,
160159
text_bundle: TextBundle {

src/ui/win_ui.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ fn reduce_audio_volume(
127127

128128
fn play_sound(assets: Res<GameAssets>, mut ev_play_sound: EventWriter<PlaySound>) {
129129
ev_play_sound.send(PlaySound {
130-
clip: assets.game_over_sound.clone(),
130+
clip: assets.game_won_sound.clone(),
131131
..default()
132132
});
133133
}

0 commit comments

Comments
 (0)