~comcloudway/little_town

c2210ecd1736e0bc3bad5e834c8200230eb95a52 — Jakob Meier 1 year, 6 months ago d6d1e99
Added background music
7 files changed, 37 insertions(+), 1 deletions(-)

M .build.yml
M .gitignore
M Cargo.lock
M Cargo.toml
M README.md
M fetch-assets.sh
M src/main.rs
M .build.yml => .build.yml +1 -0
@@ 4,6 4,7 @@ sources:
packages:
  - mingw-w64-gcc
  - wget
  - ffmpeg
  - clang
  - alsa-lib-dev
  - protoc

M .gitignore => .gitignore +2 -0
@@ 4,4 4,6 @@ assets/exp/
assets/desert
assets/fonts/
assets/ui/
assets/music.wav
assets/music.mp3
local.data

M Cargo.lock => Cargo.lock +1 -0
@@ 1628,6 1628,7 @@ dependencies = [
 "macroquad",
 "nanoserde",
 "quad-rand",
 "quad-snd",
 "quad-storage",
]


M Cargo.toml => Cargo.toml +1 -0
@@ 28,3 28,4 @@ libp2p = { version = "0.51.0", features = [
futures = { version = "0.3.26", optional = true }
async-std = { version = "1.12.0", optional = true }
quad-rand = { version = "0.2.1", optional = true }
quad-snd = "0.2.7"

M README.md => README.md +7 -1
@@ 26,7 26,7 @@ with this 2D game
  - [ ] place block with single click
  - [ ] destroy block with long click
- [ ] Settings menu (i.e for Keybindings)
- [ ] Background music (ambient)
- [x] Background music (ambient)
- [x] Add more assets
  - [x] SketchTown Expansion pack
  - [x] (MAYBE) [Sketch Desert](https://kenney.nl/assets/sketch-desert)


@@ 122,3 122,9 @@ See below or a detailed list:
- [Sektch Desert](https://kenney.nl/assets/sketch-desert) asset pack
- [UI Pack: RPG Expansion](https://kenney.nl/assets/ui-pack-rpg-expansion) asset pack
- [Kenney Fonts](https://kenney.nl/assets/kenney-fonts)

The Background music has been obtained from [pixabay](https://pixabay.com/music/solo-piano-raining-ambient-calm-piano-music-loop-111521/).
The song is called *Raining - Ambient Calm Piano Music*,
and has been comosed by *HarumachiMusic*.
According to the [pixabey license](https://pixabay.com/service/license/),
it may be used for personal and commercial use.

M fetch-assets.sh => fetch-assets.sh +12 -0
@@ 6,6 6,8 @@ rm -rf assets/exp
rm -rf assets/desert
rm -rf assets/fonts
rm -rf assets/ui
rm assets/music.mp3
rm assets/music.wav
# enable failsafe
set -e



@@ 58,3 60,13 @@ wget https://kenney.nl/content/3-assets/137-kenney-fonts/kenney_fontpackage.zip 
unzip assets/fonts.zip -d assets/fonts
rm assets/fonts.zip
echo "✅ Extracting fonts done"

# fetch music
echo "⏳ Downloading Music"
echo "from https://pixabay.com/music/solo-piano-raining-ambient-calm-piano-music-loop-111521/"
echo "Titled Raining - Ambient Calm Piano Music ( loop ) by HarumachiMusic"
wget https://cdn.pixabay.com/download/audio/2022/05/18/audio_281d895824.mp3?filename=raining-ambient-calm-piano-music-loop-111521.mp3 \
    -O assets/music.mp3
ffmpeg -i assets/music.mp3 assets/music.wav
rm assets/music.mp3
echo "✅ Downloaded music"

M src/main.rs => src/main.rs +13 -0
@@ 15,6 15,12 @@ mod game;
#[cfg(feature = "multiplayer")]
mod p2p;

use quad_snd::{
    Sound,
    AudioContext,
    PlaySoundParams
};

use game::{
    GameComponent,
    GameEvent


@@ 28,6 34,13 @@ async fn main() {

    let mut screen = Screen::default();

    let mut ctx = AudioContext::new();
    let mut sound = Sound::load(&mut ctx, include_bytes!("../assets/music.wav"));
    sound.play(&mut ctx, PlaySoundParams{
        looped: true,
        volume: 0.2
    });

    loop {
        clear_background(Color::from_rgba(215, 189, 165, 255));