Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
helio-frota committed Oct 19, 2024
1 parent cc8991f commit 3394d1c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Binary file added resources/sounds/music.wav
Binary file not shown.
10 changes: 9 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use color_eyre::Result;
use macroquad::{audio, prelude::*};
use macroquad::{audio::{self, PlaySoundParams}, prelude::*};
use player::Player;

extern crate rand;
Expand All @@ -25,6 +25,7 @@ async fn main() -> Result<()> {
set_pc_assets_folder("resources");
let font = load_ttf_font("fonts/OpenSans-Regular.ttf").await?;
let gold_sound = audio::load_sound("sounds/gold.wav").await?;
let music = audio::load_sound("sounds/music.wav").await?;
let font_size = 20.0;

// The colors
Expand All @@ -46,6 +47,12 @@ async fn main() -> Result<()> {

let mut game_over = false;

let music_params = PlaySoundParams {
looped: true,
volume: 1.0,
};
audio::play_sound(&music, music_params);

loop {
if !game_over {
clear_background(dark_green);
Expand Down Expand Up @@ -181,6 +188,7 @@ async fn main() -> Result<()> {
}
}
} else {
audio::stop_sound(&music);
let text_size =
measure_text("GAME OVER", None, font_size as _, 1.0);
draw_text(
Expand Down

0 comments on commit 3394d1c

Please sign in to comment.