Skip to content

Commit

Permalink
Menu clean up, wow, much impressed
Browse files Browse the repository at this point in the history
  • Loading branch information
Nhawdge committed Nov 15, 2023
1 parent 82439ed commit a6fb17e
Show file tree
Hide file tree
Showing 32 changed files with 275 additions and 25 deletions.
33 changes: 33 additions & 0 deletions Assets/Art/Button.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{ "frames": [
{
"filename": "Normal-0",
"frame": { "x": 1, "y": 1, "w": 378, "h": 143 },
"rotated": false,
"trimmed": false,
"spriteSourceSize": { "x": 0, "y": 0, "w": 378, "h": 143 },
"sourceSize": { "w": 378, "h": 143 },
"duration": 100
},
{
"filename": "Hover-1",
"frame": { "x": 381, "y": 1, "w": 378, "h": 143 },
"rotated": false,
"trimmed": false,
"spriteSourceSize": { "x": 0, "y": 0, "w": 378, "h": 143 },
"sourceSize": { "w": 378, "h": 143 },
"duration": 100
}
],
"meta": {
"app": "https://www.aseprite.org/",
"version": "1.3-rc6-x64",
"image": "Button.png",
"format": "RGBA8888",
"size": { "w": 760, "h": 145 },
"scale": "1",
"frameTags": [
{ "name": "Normal", "from": 0, "to": 0, "direction": "forward", "color": "#000000ff" },
{ "name": "Hover", "from": 1, "to": 1, "direction": "forward", "color": "#000000ff" }
]
}
}
Binary file added Assets/Art/Button.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Assets/Art/Main_Menu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
73 changes: 73 additions & 0 deletions Assets/Art/words.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{ "frames": [
{
"filename": "Start-0",
"frame": { "x": 1, "y": 1, "w": 378, "h": 143 },
"rotated": false,
"trimmed": false,
"spriteSourceSize": { "x": 0, "y": 0, "w": 378, "h": 143 },
"sourceSize": { "w": 378, "h": 143 },
"duration": 100
},
{
"filename": "StartHover-1",
"frame": { "x": 381, "y": 1, "w": 378, "h": 143 },
"rotated": false,
"trimmed": false,
"spriteSourceSize": { "x": 0, "y": 0, "w": 378, "h": 143 },
"sourceSize": { "w": 378, "h": 143 },
"duration": 100
},
{
"filename": "HowToPlay-2",
"frame": { "x": 761, "y": 1, "w": 378, "h": 143 },
"rotated": false,
"trimmed": false,
"spriteSourceSize": { "x": 0, "y": 0, "w": 378, "h": 143 },
"sourceSize": { "w": 378, "h": 143 },
"duration": 100
},
{
"filename": "HowToPlayHover-3",
"frame": { "x": 1, "y": 146, "w": 378, "h": 143 },
"rotated": false,
"trimmed": false,
"spriteSourceSize": { "x": 0, "y": 0, "w": 378, "h": 143 },
"sourceSize": { "w": 378, "h": 143 },
"duration": 100
},
{
"filename": "Credits-4",
"frame": { "x": 381, "y": 146, "w": 378, "h": 143 },
"rotated": false,
"trimmed": false,
"spriteSourceSize": { "x": 0, "y": 0, "w": 378, "h": 143 },
"sourceSize": { "w": 378, "h": 143 },
"duration": 100
},
{
"filename": "CreditsHover-5",
"frame": { "x": 761, "y": 146, "w": 378, "h": 143 },
"rotated": false,
"trimmed": false,
"spriteSourceSize": { "x": 0, "y": 0, "w": 378, "h": 143 },
"sourceSize": { "w": 378, "h": 143 },
"duration": 100
}
],
"meta": {
"app": "https://www.aseprite.org/",
"version": "1.3-rc6-x64",
"image": "words.png",
"format": "RGBA8888",
"size": { "w": 1140, "h": 290 },
"scale": "1",
"frameTags": [
{ "name": "Start", "from": 0, "to": 0, "direction": "forward", "color": "#000000ff" },
{ "name": "StartHover", "from": 1, "to": 1, "direction": "forward", "color": "#000000ff" },
{ "name": "HowToPlay", "from": 2, "to": 2, "direction": "forward", "color": "#000000ff" },
{ "name": "HowToPlayHover", "from": 3, "to": 3, "direction": "forward", "color": "#000000ff" },
{ "name": "Credits", "from": 4, "to": 4, "direction": "forward", "color": "#000000ff" },
{ "name": "CreditsHover", "from": 5, "to": 5, "direction": "forward", "color": "#000000ff" }
]
}
}
Binary file added Assets/Art/words.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Assets/Aseprite/Button.ase
Binary file not shown.
Binary file added Assets/Aseprite/words.ase
Binary file not shown.
Binary file added Assets/Button1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Assets/Button2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Assets/How_to_play_hover.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Assets/How_to_play_no_hover.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Assets/Start_hover.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Assets/Start_not_hover.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Assets/credits_hover.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Assets/credits_not_hover.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed Assets/lavanda.rgs
Binary file not shown.
Binary file added Assets/words1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Assets/words2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Assets/words3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Assets/words4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Assets/words5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Assets/words6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions NovemberPiratesEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public void StartGame()
Raylib.InitWindow(1280, 720, "November Pirates");
Raylib.SetTargetFPS(60);
Raylib.InitAudioDevice();
Raylib.SetExitKey(0);
Camera = new Camera2D
{
zoom = 1.0f,
Expand Down
2 changes: 1 addition & 1 deletion Scenes/Levels/OceanScene.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ internal OceanScene()
Systems.Add(new ShipControlSystem());
Systems.Add(new CameraSystem());
Systems.Add(new WindSystem());
Systems.Add(new UiSystem());
Systems.Add(new DebugSystem());
Systems.Add(new CannonBallSystem());
Systems.Add(new EnemyControlSystem());
Expand All @@ -29,6 +28,7 @@ internal OceanScene()
Systems.Add(new AudioSystem());
Systems.Add(new NavigationSystem());
Systems.Add(new PlayerControlSystem());
Systems.Add(new UiSystem());

var mapDetails = MapManager.Instance.LoadMap("Level_0", World);
MapEdge = mapDetails.MapEdge;
Expand Down
7 changes: 7 additions & 0 deletions Scenes/Levels/Systems/UiSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Arch.Core.Extensions;
using NovemberPirates.Components;
using NovemberPirates.Extensions;
using NovemberPirates.Scenes.Menus.MainMenu;
using NovemberPirates.Systems;
using Raylib_CsLo;

Expand Down Expand Up @@ -29,6 +30,12 @@ internal override void UpdateNoCamera(World world)
Raylib.DrawText(Raylib.GetFrameTime().ToString(), 10, 70, 20, Raylib.RED);
Raylib.DrawFPS(10, 90);
}


if (Raylib.IsKeyPressed(KeyboardKey.KEY_ESCAPE))
{
NovemberPiratesEngine.Instance.ActiveScene = new PauseScene(NovemberPiratesEngine.Instance.ActiveScene);
}
}
}
}
11 changes: 11 additions & 0 deletions Scenes/Menus/Components/SpriteButton.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using NovemberPirates.Components;

namespace NovemberPirates.Scenes.Menus.Components
{
internal class SpriteButton : UiTitle
{
internal Sprite ButtonSprite;
internal Sprite TextSprite;
internal Action Action { get; set; } = () => { };
}
}
15 changes: 11 additions & 4 deletions Scenes/Menus/MainMenu/CreditsScene.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
using NovemberPirates.Scenes.Menus.Systems;
using NovemberPirates.Scenes.Menus.Components;
using NovemberPirates.Scenes.Menus.Systems;

namespace NovemberPirates.Scenes.Menus.MainMenu
{
internal class CreditsScene : BaseScene
{
public CreditsScene()
{

Systems.Add(new MenuSystem());


World.Create(new UiButton
{
Text = "Back",
Action = () =>
{
NovemberPiratesEngine.Instance.ActiveScene = new MainMenuScene();
},
Order = 5
});
}
}
}
6 changes: 3 additions & 3 deletions Scenes/Menus/MainMenu/HowToPlayScene.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ public HowToPlayScene()
var instructions3 = World.Create<UiTitle>();
instructions3.Set(new UiTitle { Text = @"F2 for the debugger I'm proud of", Order = 3 });

var backButton = new UiButton
World.Create(new UiButton
{
Text = "Back",
Action = () =>
{
NovemberPiratesEngine.Instance.ActiveScene = new MainMenuScene();
},
Order = 6
};
Order = 5
});
}

}
Expand Down
58 changes: 44 additions & 14 deletions Scenes/Menus/MainMenu/MainMenuScene.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
using Arch.Core.Extensions;
using NovemberPirates.Components;
using NovemberPirates.Scenes.Levels;
using NovemberPirates.Scenes.Menus.Components;
using NovemberPirates.Scenes.Menus.Systems;
using NovemberPirates.Utilities;
using System.Numerics;

namespace NovemberPirates.Scenes.Menus.MainMenu
{
Expand All @@ -11,41 +14,69 @@ public MainMenuScene()
{
Systems.Add(new MenuSystem());

var title = World.Create<UiTitle>();
//var title = World.Create<UiTitle>();
//var uiTitle = new UiTitle() { Text = "November Pirates" };
//title.Set(uiTitle);

var uiTitle = new UiTitle() { Text = "November Pirates" };
title.Set(uiTitle);

var button = World.Create<UiButton>();
button.Set(new UiButton
World.Create(new SpriteButton
{
Text = "Start Game",
Text = "Start",
Action = () =>
{
NovemberPiratesEngine.Instance.ActiveScene = new OceanScene();
},
Order = 1
Order = 1,
TextSprite = new Sprite(TextureKey.Words, "Assets/Art/words")
{
Position = new Vector2(750, 150),
OriginPos = Render.OriginAlignment.LeftTop
},
ButtonSprite = new Sprite(TextureKey.Button, "Assets/Art/Button")
{
Position = new Vector2(750, 150),
OriginPos = Render.OriginAlignment.LeftTop
}
});


World.Create(new UiButton
World.Create(new SpriteButton
{
Text = "How to Play",
Text = "HowToPlay",
Action = () =>
{
NovemberPiratesEngine.Instance.ActiveScene = new HowToPlayScene();
},
Order = 2
Order = 2,
TextSprite = new Sprite(TextureKey.Words, "Assets/Art/words")
{
Position = new Vector2(750, 300),
OriginPos = Render.OriginAlignment.LeftTop,
},
ButtonSprite = new Sprite(TextureKey.Button, "Assets/Art/Button")
{
Position = new Vector2(750, 300),
OriginPos = Render.OriginAlignment.LeftTop
}
});

World.Create(new UiButton
World.Create(new SpriteButton
{
Text = "Credits",
Action = () =>
{
NovemberPiratesEngine.Instance.ActiveScene = new CreditsScene();
},
Order = 3
Order = 3,
TextSprite = new Sprite(TextureKey.Words, "Assets/Art/words")
{
Position = new Vector2(750, 450),
OriginPos = Render.OriginAlignment.LeftTop
},
ButtonSprite = new Sprite(TextureKey.Button, "Assets/Art/Button")
{
Position = new Vector2(750, 450),
OriginPos = Render.OriginAlignment.LeftTop
}
});


Expand All @@ -55,7 +86,6 @@ public MainMenuScene()
Action = () =>
{
Environment.Exit(0);
//NovemberPiratesEngine.Instance.ActiveScene = new HowToPlayScene();
},
Order = 5
});
Expand Down
53 changes: 53 additions & 0 deletions Scenes/Menus/MainMenu/PauseScene.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
using NovemberPirates.Scenes.Menus.Components;
using NovemberPirates.Scenes.Menus.Systems;

namespace NovemberPirates.Scenes.Menus.MainMenu
{
internal class PauseScene : BaseScene
{
public PauseScene(BaseScene lastScene)
{
Systems.Add(new MenuSystem());

World.Create(new UiButton
{
Text = "Resume",
Action = () =>
{
NovemberPiratesEngine.Instance.ActiveScene = lastScene;
},
Order = 1
});

World.Create(new UiButton
{
Text = "Settings",
Action = () =>
{
//NovemberPiratesEngine.Instance.ActiveScene = new MainMenuScene();
},
Order = 2
});

World.Create(new UiButton
{
Text = "Main Menu",
Action = () =>
{
NovemberPiratesEngine.Instance.ActiveScene = new MainMenuScene();
},
Order = 3
});

World.Create(new UiButton
{
Text = "Exit Game",
Action = () =>
{
Environment.Exit(0);
},
Order = 5
});
}
}
}
Loading

0 comments on commit a6fb17e

Please sign in to comment.