diff --git a/GreatSpringGameJam/Content/Maps/Level1.tmx b/GreatSpringGameJam/Content/Maps/Level1.tmx index b017e9b..d4aa722 100644 --- a/GreatSpringGameJam/Content/Maps/Level1.tmx +++ b/GreatSpringGameJam/Content/Maps/Level1.tmx @@ -30,11 +30,11 @@ 0,0,0,0,0,84,85,86,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,38,0,0,0,17,18,18,18,18,18,18,18,4,2,2,2,2,3,0,0,0,17,18,18,18,18,18,18,18,18,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,65,66,67,0,55,54,0, 0,0,0,0,0,100,101,102,103,104,0,0,0,0,0,0,0,0,39,0,0,0,0,0,0,0,0,1,2,2,2,3,0,0,0,17,18,18,18,18,18,18,18,18,18,18,18,18,19,0,0,1,5,4,2,2,2,5,18,18,18,19,39,39,0,0,0,0,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 0,0,0,0,0,0,0,0,0,0,0,0,1,2,2,2,2,2,2,3,0,0,0,0,0,0,0,17,18,18,18,19,0,0,0,17,4,2,2,2,2,5,18,18,18,18,18,18,19,0,0,9,10,10,21,18,18,18,18,18,18,4,2,2,3,0,0,0,17,18,18,18,18,18,18,18,18,18,18,18,18,18,18, -0,0,0,0,0,0,0,0,0,0,0,0,17,18,18,18,18,18,18,19,0,0,0,0,38,39,0,17,4,2,5,19,0,0,0,17,18,18,18,18,18,18,18,18,4,2,2,5,19,0,0,0,0,0,17,18,18,18,18,18,18,18,18,18,19,0,0,0,17,4,2,2,2,2,2,5,18,18,18,18,18,18,18, -2,2,2,2,2,2,2,2,2,2,2,2,5,18,4,2,2,2,5,19,0,0,0,1,2,2,2,5,18,18,18,19,0,0,0,17,18,18,18,18,18,18,18,18,18,18,18,18,19,0,0,0,82,0,17,18,4,2,2,2,2,2,2,5,19,0,0,0,17,18,18,18,18,18,18,18,18,4,2,2,2,5,18, -18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,19,0,0,0,17,18,18,18,18,18,18,18,19,0,0,0,17,18,18,4,2,2,2,2,2,2,5,18,18,19,0,37,0,0,0,17,18,18,18,18,18,18,18,18,18,19,0,0,0,17,18,18,18,18,18,18,18,18,18,18,18,18,18,18, -18,18,18,18,18,18,4,2,2,2,2,2,5,18,18,18,18,18,18,19,0,0,0,17,4,2,2,2,2,5,18,19,0,0,0,17,18,18,18,18,18,18,18,18,18,18,18,18,19,0,1,2,2,2,5,18,18,18,18,18,4,2,2,5,19,0,0,0,17,18,18,18,4,2,2,2,2,2,5,18,18,18,18, -18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,19,0,0,0,17,18,18,18,18,18,18,18,19,0,0,0,17,18,18,18,18,18,18,18,18,18,18,18,18,19,0,9,21,18,18,18,18,18,18,18,18,18,18,18,18,19,0,0,0,17,18,18,18,18,18,18,18,18,18,18,18,18,18,18, +0,0,0,0,0,0,0,0,0,0,0,0,17,18,18,18,18,18,18,19,0,0,0,0,38,39,0,17,4,2,5,19,0,0,0,17,18,18,18,18,18,18,18,18,4,2,2,5,19,38,0,0,0,0,17,18,18,18,18,18,18,18,18,18,19,0,0,0,17,4,2,2,2,2,2,5,18,18,18,18,18,18,18, +2,2,2,2,2,2,2,2,2,2,2,2,5,18,4,2,2,2,5,19,0,0,0,1,2,2,2,5,18,18,18,19,0,0,0,17,18,18,18,18,18,18,18,18,18,18,18,18,4,3,0,0,82,0,17,18,4,2,2,2,2,2,2,5,19,0,0,0,17,18,18,18,18,18,18,18,18,4,2,2,2,5,18, +18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,19,0,0,0,17,18,18,18,18,18,18,18,19,0,0,0,17,18,18,4,2,2,2,2,2,2,5,18,18,18,19,0,0,0,0,17,18,18,18,18,18,18,18,18,18,19,0,0,0,17,18,18,18,18,18,18,18,18,18,18,18,18,18,18, +18,18,18,18,18,18,4,2,2,2,2,2,5,18,18,18,18,18,18,19,0,0,0,17,4,2,2,2,2,5,18,19,0,0,0,17,18,18,18,18,18,18,18,18,18,18,18,18,20,11,0,1,2,2,5,18,18,18,18,18,4,2,2,5,19,0,0,0,17,18,18,18,4,2,2,2,2,2,5,18,18,18,18, +18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,19,0,0,0,17,18,18,18,18,18,18,18,19,0,0,0,17,18,18,18,18,18,18,18,18,18,18,18,18,19,0,0,17,18,18,18,18,18,18,18,18,18,18,18,18,19,0,0,0,17,18,18,18,18,18,18,18,18,18,18,18,18,18,18, 18,4,2,2,2,5,18,18,18,18,4,2,2,2,2,2,2,5,18,19,0,0,0,17,18,4,2,2,2,2,5,19,0,0,0,17,4,2,2,2,2,5,18,18,18,18,18,18,19,0,0,17,4,2,2,2,2,2,5,18,18,18,18,18,19,0,0,0,17,4,2,2,2,2,2,5,18,18,18,18,18,18,18, 18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,19,0,0,0,17,18,18,18,18,18,18,18,19,0,0,0,17,18,18,18,18,18,18,18,18,18,18,18,18,19,0,0,17,18,18,18,18,18,18,18,18,18,18,18,18,19,0,0,0,17,18,18,18,18,18,18,18,18,18,18,18,18,18,18 diff --git a/GreatSpringGameJam/Content/Textures/Stuff.aseprite b/GreatSpringGameJam/Content/Textures/Stuff.aseprite index 4705a0e..cd146a4 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 1310c0a..75762eb 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 337c305..9a470f5 100644 --- a/GreatSpringGameJam/GameImpl.cs +++ b/GreatSpringGameJam/GameImpl.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; @@ -13,6 +14,7 @@ using MLEM.Extensions; using MLEM.Font; using MLEM.Formatting.Codes; using MLEM.Startup; +using MLEM.Textures; using MLEM.Ui; using MLEM.Ui.Elements; using MonoGame.Extended; @@ -47,7 +49,11 @@ namespace GreatSpringGameJam { this.UiSystem.Style.Font = new GenericSpriteFont(LoadContent("Fonts/Regular")); this.UiSystem.Style.TextScale = 0.075F; this.UiSystem.Style.TextColor = ColorHelper.FromHexRgb(0xebd5bd); + this.UiSystem.Style.ButtonTexture = new NinePatch(this.SpriteBatch.GenerateSquareTexture(ColorHelper.FromHexRgb(0x594e6f) * 0.35F), 0); this.UiSystem.AutoScaleWithScreen = true; + this.UiSystem.Controls.HandleKeyboard = false; + this.UiSystem.Controls.HandleGamepad = false; + this.UiSystem.Controls.HandleTouch = false; this.UiSystem.TextFormatter.AddImage("Flower", Entity.StuffTexture[0, 1]); this.UiSystem.TextFormatter.AddImage("Gnome", Entity.StuffTexture[1, 1]); this.UiSystem.TextFormatter.AddImage("Snow", Entity.StuffTexture[2, 1]); @@ -56,28 +62,52 @@ namespace GreatSpringGameJam { this.mapLoader = new ContentManager(this.Services, this.Content.RootDirectory); var scores = GetScoreFile(); if (scores.Exists) { - using (var reader = new JsonTextReader(scores.OpenText())) - this.Scores = Serializer.Deserialize>(reader); + using var reader = new JsonTextReader(scores.OpenText()); + this.Scores = Serializer.Deserialize>(reader); } - this.Camera = new Camera(this.GraphicsDevice) { AutoScaleWithScreen = true, Scale = 4 }; - this.StartMap("Overworld"); + + // open the main menu + var group = new Group(Anchor.TopLeft, Vector2.One, false); + group.AddChild(new Image(Anchor.TopCenter, new Vector2(0.45F, -0.5F), Entity.StuffTexture[0, 2, 4, 2]) { + OnUpdated = (e, time) => e.PositionOffset = new Vector2(0, 50 + MathF.Sin((float) time.TotalGameTime.TotalSeconds * 2) * 5) + }); + group.AddChild(new Paragraph(Anchor.BottomCenter, 1, "Created by Ellpeck for the Great Spring Game Jam: 2021", true) { + TextScale = 0.06F + }); + 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 => { + if (!this.IsInCutscene) + this.StartLevel("Overworld", Color.White); + } + }); + buttons.AddChild(new VerticalSpace(10)); + buttons.AddChild(new Button(Anchor.AutoLeft, new Vector2(245, 50), "View on itch")); + buttons.AddChild(new Button(Anchor.AutoInlineIgnoreOverflow, new Vector2(245, 50), "View source") { + PositionOffset = new Vector2(10, 0), + OnPressed = e => Process.Start(new ProcessStartInfo("https://git.ellpeck.de/Ellpeck/GreatSpringGameJam") {UseShellExecute = true}) + }); + this.UiSystem.Add("MainMenu", group); } protected override void DoUpdate(GameTime gameTime) { base.DoUpdate(gameTime); - this.Map.Update(gameTime); - if (!this.IsInCutscene) - this.FocusCameraOnPlayer(); + if (this.Map != null) { + this.Map.Update(gameTime); + if (this.Player != null && !this.IsInCutscene) + this.FocusCameraOnPlayer(); + } } protected override void DoDraw(GameTime gameTime) { this.GraphicsDevice.Clear(ColorHelper.FromHexRgb(0x729cd4)); base.DoDraw(gameTime); - this.Map.Draw(gameTime, this.SpriteBatch, this.Camera); + if (this.Map != null) + this.Map.Draw(gameTime, this.SpriteBatch, this.Camera); } public void Finish() { @@ -143,7 +173,7 @@ namespace GreatSpringGameJam { CoroutineHandler.Start(this.FadeAndStartLevel(name, fadeColor)); } - private IEnumerable FadeAndStartLevel(string map, Color fadeColor) { + private IEnumerable FadeAndStartLevel(string mapName, Color fadeColor) { var fadeOverlay = new Group(Anchor.TopLeft, Vector2.One, false) { OnDrawn = (e, time, batch, a) => batch.FillRectangle(e.DisplayArea.ToExtended(), fadeColor * a), DrawAlpha = 0 @@ -156,8 +186,20 @@ namespace GreatSpringGameJam { yield return new Wait(0.25F); this.UiSystem.Remove("EndCard"); - this.StartMap(map); + this.UiSystem.Remove("MainMenu"); + // load next map + this.mapLoader.Unload(); + var map = new Map(this.mapLoader.Load($"Maps/{mapName}"), mapName); + var spawnPoint = map.SpawnPoint.ToVector2(); + if (mapName == "Overworld" && this.Map != null && this.Map.Name != mapName) + spawnPoint = (map.GetLevelEntrances().First(e => e.Name == this.Map.Name).Position / map.TileSize).FloorCopy(); + this.Player = new Player(map, spawnPoint); + this.Map = map; + this.Map.AddEntity(this.Player); + this.FocusCameraOnPlayer(1); + + // fade back in yield return new Wait(0.25F); while (fadeOverlay.DrawAlpha > 0) { fadeOverlay.DrawAlpha -= 0.04F; @@ -173,19 +215,6 @@ namespace GreatSpringGameJam { this.Camera.ConstrainWorldBounds(Vector2.Zero, this.Map.SizeInPixels.ToVector2()); } - private void StartMap(string name) { - // dispose loaded maps so that edits don't persist - this.mapLoader.Unload(); - var map = new Map(this.mapLoader.Load($"Maps/{name}"), name); - var spawnPoint = map.SpawnPoint.ToVector2(); - if (name == "Overworld" && this.Map != null && this.Map.Name != name) - spawnPoint = (map.GetLevelEntrances().First(e => e.Name == this.Map.Name).Position / map.TileSize).FloorCopy(); - this.Player = new Player(map, spawnPoint); - this.Map = map; - this.Map.AddEntity(this.Player); - this.FocusCameraOnPlayer(1); - } - private static FileInfo GetScoreFile() { var appData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); return new FileInfo(Path.Combine(appData, $"{Assembly.GetExecutingAssembly().GetName().Name}.dat")); diff --git a/GreatSpringGameJam/GreatSpringGameJam.csproj b/GreatSpringGameJam/GreatSpringGameJam.csproj index 0f8d3fe..a4ad4e4 100644 --- a/GreatSpringGameJam/GreatSpringGameJam.csproj +++ b/GreatSpringGameJam/GreatSpringGameJam.csproj @@ -5,13 +5,14 @@ net5.0 false false + A Breath of Spring Air - - - + + + @@ -29,8 +30,13 @@ + + Icon.ico + - - + + + Icon.bmp + \ No newline at end of file diff --git a/GreatSpringGameJam/Icon.bmp b/GreatSpringGameJam/Icon.bmp new file mode 100644 index 0000000..d46330f Binary files /dev/null and b/GreatSpringGameJam/Icon.bmp differ diff --git a/GreatSpringGameJam/Icon.ico b/GreatSpringGameJam/Icon.ico new file mode 100644 index 0000000..dd09242 Binary files /dev/null and b/GreatSpringGameJam/Icon.ico differ diff --git a/NuGet.config b/NuGet.config index c6e98bd..558b476 100644 --- a/NuGet.config +++ b/NuGet.config @@ -1,4 +1,7 @@ + + +