diff --git a/GreatSpringGameJam/Content/Content.mgcb b/GreatSpringGameJam/Content/Content.mgcb index 426665b..0728e54 100644 --- a/GreatSpringGameJam/Content/Content.mgcb +++ b/GreatSpringGameJam/Content/Content.mgcb @@ -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 + diff --git a/GreatSpringGameJam/Content/Contentless.json b/GreatSpringGameJam/Content/Contentless.json index 2851e9c..a9c0d4a 100644 --- a/GreatSpringGameJam/Content/Contentless.json +++ b/GreatSpringGameJam/Content/Contentless.json @@ -8,6 +8,9 @@ "overrides": { "Sounds/": { "Processor": "SoundEffectProcessor" + }, + "Songs/": { + "Processor": "SongProcessor" } } } \ No newline at end of file diff --git a/GreatSpringGameJam/Content/Songs/SpringPlains.wav b/GreatSpringGameJam/Content/Songs/SpringPlains.wav new file mode 100644 index 0000000..af3b251 Binary files /dev/null and b/GreatSpringGameJam/Content/Songs/SpringPlains.wav differ diff --git a/GreatSpringGameJam/Content/Songs/SummerForest.wav b/GreatSpringGameJam/Content/Songs/SummerForest.wav new file mode 100644 index 0000000..98b7626 Binary files /dev/null and b/GreatSpringGameJam/Content/Songs/SummerForest.wav differ diff --git a/GreatSpringGameJam/Content/Textures/Stuff.aseprite b/GreatSpringGameJam/Content/Textures/Stuff.aseprite index cd146a4..e3eb247 100644 Binary files a/GreatSpringGameJam/Content/Textures/Stuff.aseprite and b/GreatSpringGameJam/Content/Textures/Stuff.aseprite differ diff --git a/GreatSpringGameJam/Content/Textures/Stuff.png b/GreatSpringGameJam/Content/Textures/Stuff.png index 75762eb..bdf7c6c 100644 Binary files a/GreatSpringGameJam/Content/Textures/Stuff.png and b/GreatSpringGameJam/Content/Textures/Stuff.png differ diff --git a/GreatSpringGameJam/GameImpl.cs b/GreatSpringGameJam/GameImpl.cs index df473e0..a2d423c 100644 --- a/GreatSpringGameJam/GameImpl.cs +++ b/GreatSpringGameJam/GameImpl.cs @@ -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 Ellpeck for the Great Spring Game Jam: 2021", 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), " Play ") { 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("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("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 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"));