added music

This commit is contained in:
Ell 2021-03-18 20:04:47 +01:00
parent 78aff1a518
commit 84869f8e17
7 changed files with 38 additions and 0 deletions

View file

@ -105,3 +105,13 @@
/processor:SoundEffectProcessor
/build:Sounds/WateringCan.ogg
#begin Songs/SummerForest.wav
/importer:WavImporter
/processor:SongProcessor
/build:Songs/SummerForest.wav
#begin Songs/SpringPlains.wav
/importer:WavImporter
/processor:SongProcessor
/build:Songs/SpringPlains.wav

View file

@ -8,6 +8,9 @@
"overrides": {
"Sounds/": {
"Processor": "SoundEffectProcessor"
},
"Songs/": {
"Processor": "SongProcessor"
}
}
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View file

@ -9,6 +9,7 @@ using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Media;
using MLEM.Cameras;
using MLEM.Extended.Extensions;
using MLEM.Extensions;
@ -81,6 +82,11 @@ namespace GreatSpringGameJam {
group.AddChild(new Paragraph(Anchor.BottomCenter, 1, "Created by <l https://ellpeck.de>Ellpeck</l> for the <l https://itch.io/jam/great-spring-game-jam-2021>Great Spring Game Jam: 2021</l>", true) {
TextScale = 0.06F
});
group.AddChild(new Image(Anchor.TopRight, new Vector2(60), i => Entity.StuffTexture[3 + (MediaPlayer.IsMuted ? 1 : 0), 1]) {
PositionOffset = new Vector2(4),
CanBeMoused = true,
OnPressed = e => MediaPlayer.IsMuted = !MediaPlayer.IsMuted
});
var buttons = group.AddChild(new Group(Anchor.BottomCenter, new Vector2(500)) {PositionOffset = new Vector2(0, 125)});
buttons.AddChild(new Button(Anchor.AutoCenter, new Vector2(1, 60), "<i Gnome> Play <i Flower>") {
OnPressed = e => {
@ -95,6 +101,9 @@ namespace GreatSpringGameJam {
OnPressed = e => Process.Start(new ProcessStartInfo("https://git.ellpeck.de/Ellpeck/GreatSpringGameJam") {UseShellExecute = true})
});
this.UiSystem.Add("MainMenu", group);
MediaPlayer.IsRepeating = true;
MediaPlayer.Play(LoadContent<Song>("Songs/SpringPlains"));
}
protected override void DoUpdate(GameTime gameTime) {
@ -167,11 +176,13 @@ namespace GreatSpringGameJam {
yield return wait;
}
FadeOutSong();
this.IsInCutscene = true;
CoroutineHandler.Start(Impl());
}
public void StartLevel(string name, Color fadeColor) {
FadeOutSong();
this.IsInCutscene = true;
CoroutineHandler.Start(this.FadeAndStartLevel(name, fadeColor));
}
@ -211,6 +222,7 @@ namespace GreatSpringGameJam {
this.UiSystem.Remove(fadeOverlay.Root.Name);
this.IsInCutscene = false;
MediaPlayer.Play(LoadContent<Song>("Songs/" + (mapName == "Overworld" ? "SummerForest" : "SpringPlains")));
}
private void FocusCameraOnPlayer(float speed = 0.25F) {
@ -218,6 +230,19 @@ namespace GreatSpringGameJam {
this.Camera.ConstrainWorldBounds(Vector2.Zero, this.Map.SizeInPixels.ToVector2());
}
private static void FadeOutSong() {
static IEnumerable<Wait> Impl() {
while (MediaPlayer.Volume > 0) {
MediaPlayer.Volume -= 0.05F;
yield return new Wait(CoroutineEvents.Update);
}
MediaPlayer.Stop();
MediaPlayer.Volume = 1;
}
CoroutineHandler.Start(Impl());
}
private static FileInfo GetScoreFile() {
var appData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
return new FileInfo(Path.Combine(appData, $"{Assembly.GetExecutingAssembly().GetName().Name}.dat"));