mirror of
https://github.com/Melon-Bread/Pet.GB
synced 2024-11-28 13:58:20 -05:00
Info menu not works ℹ️
Pauses rest of game when open
This commit is contained in:
parent
2a3a15742b
commit
94e90430d4
BIN
assets/images/Menu.png
Normal file
BIN
assets/images/Menu.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 582 B |
@ -1,17 +1,18 @@
|
||||
package;
|
||||
|
||||
|
||||
import flixel.FlxG;
|
||||
import flixel.FlxSprite;
|
||||
import flixel.group.FlxGroup;
|
||||
import flixel.system.FlxSound;
|
||||
import flixel.text.FlxText;
|
||||
import flixel.util.FlxColor;
|
||||
import flixel.input.gamepad.FlxGamepad;
|
||||
using flixel.util.FlxSpriteUtil;
|
||||
|
||||
|
||||
// TODO: Make sure the HUD is just displaying & triggering Gel stuff
|
||||
// TODO: Display in-game time
|
||||
// TODO: Save system that saves every menu choice
|
||||
class HUD extends FlxTypedGroup<FlxSprite>
|
||||
{
|
||||
// Top
|
||||
@ -44,6 +45,9 @@ class HUD extends FlxTypedGroup<FlxSprite>
|
||||
private var _sndSelect:FlxSound;
|
||||
private var _sndNext:FlxSound;
|
||||
|
||||
// Menus
|
||||
private var _infoMenu:InfoMenu;
|
||||
|
||||
// Misc
|
||||
private var _menuOption:Int;
|
||||
private var _sprSelect:FlxSprite;
|
||||
@ -51,13 +55,14 @@ class HUD extends FlxTypedGroup<FlxSprite>
|
||||
|
||||
private var _gel:Gel;
|
||||
|
||||
public function new(g:Gel)
|
||||
public function new(gel:Gel, infoMenu:InfoMenu)
|
||||
{
|
||||
super();
|
||||
|
||||
// Misc
|
||||
_menuOption = 0;
|
||||
_gel = g;
|
||||
_gel = gel;
|
||||
_infoMenu = infoMenu;
|
||||
|
||||
// Top
|
||||
_sprTop = new FlxSprite(0, 0, AssetPaths.HUD_Background__png);
|
||||
@ -143,14 +148,15 @@ class HUD extends FlxTypedGroup<FlxSprite>
|
||||
_sprThoughts.animation.add("hungry", [0, 1, 2, 3, 4], 3, true);
|
||||
_sprThoughts.animation.add("poopy", [5, 6, 7, 8, 9], 3, true);
|
||||
_sprThoughts.animation.add("sleepy", [10, 11, 12, 13, 14], 4, true);
|
||||
//_sprThoughts.visible = false;
|
||||
add(_sprThoughts);
|
||||
|
||||
|
||||
// KILL ME PLEASE
|
||||
_tmpText = new FlxText(_sprInteraction.x, _sprInteraction.y, 0, "", 8);
|
||||
add(_tmpText);
|
||||
|
||||
// DEBUG
|
||||
FlxG.watch.add(_infoMenu, "exists", "Info Menu Open");
|
||||
FlxG.watch.add(this, "_menuOption", "Menu Index");
|
||||
FlxG.watch.add(_sprInteraction, "alpha", "Interact Alpha");
|
||||
FlxG.watch.add(_sprInteraction, "visible", "Interact Visible");
|
||||
@ -161,6 +167,9 @@ class HUD extends FlxTypedGroup<FlxSprite>
|
||||
{
|
||||
super.update(elapsed);
|
||||
|
||||
// If a menu is open do not let the rest of the game update
|
||||
|
||||
|
||||
// TODO: Add WASD support?
|
||||
// TODO: Add vertical menu movent
|
||||
// TODO: Start + Select gives prompt to delete save file
|
||||
@ -171,8 +180,6 @@ class HUD extends FlxTypedGroup<FlxSprite>
|
||||
else if (FlxG.keys.justPressed.X || FlxG.gamepads.anyJustPressed(B))
|
||||
makeOption(_menuOption);
|
||||
|
||||
_gel.update(elapsed);
|
||||
|
||||
// Gel Animation
|
||||
if (_gel.CurrentMood == Gel.Mood.NEUTRAL)
|
||||
_gel.animation.play("neutral", false);
|
||||
@ -247,7 +254,7 @@ class HUD extends FlxTypedGroup<FlxSprite>
|
||||
{
|
||||
// INFO
|
||||
case 0:
|
||||
//
|
||||
showInfo();
|
||||
|
||||
// FEED
|
||||
case 1:
|
||||
@ -281,13 +288,18 @@ class HUD extends FlxTypedGroup<FlxSprite>
|
||||
|
||||
// CONFIG
|
||||
case 7:
|
||||
//
|
||||
showConfig();
|
||||
}
|
||||
_sndSelect.play(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private function showInfo():Void
|
||||
{
|
||||
_infoMenu.OpenMenu();
|
||||
}
|
||||
|
||||
private function feedGel():Void
|
||||
{
|
||||
itemJoin("F");
|
||||
@ -330,6 +342,11 @@ class HUD extends FlxTypedGroup<FlxSprite>
|
||||
_sprInteraction.fadeOut(2, itemLeave);
|
||||
}
|
||||
|
||||
private function showConfig():Void
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private function itemJoin(letter:String = ""):Void
|
||||
{
|
||||
_sprInteraction.visible = true;
|
||||
|
83
source/InfoMenu.hx
Normal file
83
source/InfoMenu.hx
Normal file
@ -0,0 +1,83 @@
|
||||
package;
|
||||
|
||||
import flixel.FlxG;
|
||||
import flixel.FlxSprite;
|
||||
import flixel.group.FlxGroup;
|
||||
import flixel.text.FlxText;
|
||||
import flixel.util.FlxColor;
|
||||
|
||||
class InfoMenu extends FlxTypedGroup<FlxSprite>
|
||||
{
|
||||
private var _sprBackground:FlxSprite;
|
||||
|
||||
private var _txtTitle:FlxText;
|
||||
private var _txtAGE:FlxText;
|
||||
private var _txtINT:FlxText;
|
||||
private var _txtHAP:FlxText;
|
||||
private var _txtDIS:FlxText;
|
||||
private var _txtFooter:FlxText;
|
||||
|
||||
private var _gel:Gel;
|
||||
|
||||
public function new(gel:Gel)
|
||||
{
|
||||
super();
|
||||
_gel = gel;
|
||||
|
||||
_sprBackground = new FlxSprite(9, 9, AssetPaths.Menu__png);
|
||||
add(_sprBackground);
|
||||
|
||||
_txtTitle = new FlxText((_sprBackground.x + 11), (_sprBackground.y + 2), 0, "Gel Info", 16);
|
||||
_txtTitle.setFormat(AssetPaths.EarlyGameBoy__ttf, 16, FlxColor.fromRGB(8, 24, 32, 0), CENTER);
|
||||
add(_txtTitle);
|
||||
|
||||
// Content
|
||||
_txtAGE = new FlxText((_txtTitle.x + 7), (_sprBackground.y + 33), 0 , "Age: " + _gel.Age + " Days");
|
||||
_txtAGE.setFormat(AssetPaths.EarlyGameBoy__ttf, 8, FlxColor.fromRGB(8, 24, 32, 0), CENTER);
|
||||
add(_txtAGE);
|
||||
|
||||
_txtINT = new FlxText(_txtAGE.x, (_txtAGE.y + _txtAGE.height + 1), 0, "Int: " + _gel.Intellect + " Pts");
|
||||
_txtINT.setFormat(AssetPaths.EarlyGameBoy__ttf, 8, FlxColor.fromRGB(8, 24, 32, 0), CENTER);
|
||||
add (_txtINT);
|
||||
|
||||
_txtHAP = new FlxText(_txtINT.x, (_txtINT.y + _txtINT.height + 1), 0, "HAP: " + _gel.Happiness + " Pct");
|
||||
_txtHAP.setFormat(AssetPaths.EarlyGameBoy__ttf, 8, FlxColor.fromRGB(8, 24, 32, 0), CENTER);
|
||||
add (_txtHAP);
|
||||
|
||||
_txtDIS = new FlxText(_txtHAP.x, (_txtHAP.y + _txtHAP.height + 1), 0, "DIS: " + _gel.Discipline + " Pct");
|
||||
_txtDIS.setFormat(AssetPaths.EarlyGameBoy__ttf, 8, FlxColor.fromRGB(8, 24, 32, 0), CENTER);
|
||||
add (_txtDIS);
|
||||
|
||||
|
||||
// Footer
|
||||
_txtFooter = new FlxText((_sprBackground.x + 12), (_sprBackground.height - 12), 0, "Press B To Close", 8);
|
||||
_txtFooter.setFormat(AssetPaths.EarlyGameBoy__ttf, 8, FlxColor.fromRGB(8, 24, 32, 0), CENTER);
|
||||
add(_txtFooter);
|
||||
|
||||
active = false;
|
||||
visible = false;
|
||||
}
|
||||
|
||||
public function OpenMenu():Void
|
||||
{
|
||||
//_sprBackground.drawFrame();
|
||||
|
||||
visible = true;
|
||||
active = true;
|
||||
}
|
||||
|
||||
override public function update(elapsed:Float):Void
|
||||
{
|
||||
super.update(elapsed);
|
||||
|
||||
// TODO: When B is pressed fade this menu out
|
||||
if (FlxG.keys.pressed.Z || FlxG.gamepads.anyJustPressed(B))
|
||||
closeMenu();
|
||||
}
|
||||
|
||||
private function closeMenu():Void
|
||||
{
|
||||
active = false;
|
||||
visible = false;
|
||||
}
|
||||
}
|
@ -13,6 +13,8 @@ class PlayState extends FlxState
|
||||
|
||||
private var _hud:HUD;
|
||||
|
||||
private var _infoMenu:InfoMenu;
|
||||
|
||||
|
||||
override public function create():Void
|
||||
{
|
||||
@ -24,8 +26,11 @@ class PlayState extends FlxState
|
||||
_gelPet.y = ((FlxG.height/2) - (_gelPet.height/2));
|
||||
add(_gelPet);
|
||||
|
||||
_hud = new HUD(_gelPet);
|
||||
// Interface
|
||||
_infoMenu = new InfoMenu(_gelPet);
|
||||
_hud = new HUD(_gelPet, _infoMenu);
|
||||
add(_hud);
|
||||
add(_infoMenu);
|
||||
|
||||
super.create();
|
||||
|
||||
@ -36,5 +41,17 @@ class PlayState extends FlxState
|
||||
override public function update(elapsed:Float):Void
|
||||
{
|
||||
super.update(elapsed);
|
||||
if (_infoMenu.visible)
|
||||
{
|
||||
_gelPet.active = false;
|
||||
_gelPet._clock.pause(true);
|
||||
_hud.active = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
_gelPet.active = true;
|
||||
_gelPet._clock.pause(false);
|
||||
_hud.active = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user