mirror of
https://github.com/Melon-Bread/Pet.GB
synced 2025-02-17 22:03:02 -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;
|
package;
|
||||||
|
|
||||||
|
|
||||||
import flixel.FlxG;
|
import flixel.FlxG;
|
||||||
import flixel.FlxSprite;
|
import flixel.FlxSprite;
|
||||||
import flixel.group.FlxGroup;
|
import flixel.group.FlxGroup;
|
||||||
import flixel.system.FlxSound;
|
import flixel.system.FlxSound;
|
||||||
import flixel.text.FlxText;
|
import flixel.text.FlxText;
|
||||||
import flixel.util.FlxColor;
|
import flixel.util.FlxColor;
|
||||||
import flixel.input.gamepad.FlxGamepad;
|
|
||||||
using flixel.util.FlxSpriteUtil;
|
using flixel.util.FlxSpriteUtil;
|
||||||
|
|
||||||
|
|
||||||
// TODO: Make sure the HUD is just displaying & triggering Gel stuff
|
// TODO: Make sure the HUD is just displaying & triggering Gel stuff
|
||||||
// TODO: Display in-game time
|
// TODO: Display in-game time
|
||||||
|
// TODO: Save system that saves every menu choice
|
||||||
class HUD extends FlxTypedGroup<FlxSprite>
|
class HUD extends FlxTypedGroup<FlxSprite>
|
||||||
{
|
{
|
||||||
// Top
|
// Top
|
||||||
@ -44,6 +45,9 @@ class HUD extends FlxTypedGroup<FlxSprite>
|
|||||||
private var _sndSelect:FlxSound;
|
private var _sndSelect:FlxSound;
|
||||||
private var _sndNext:FlxSound;
|
private var _sndNext:FlxSound;
|
||||||
|
|
||||||
|
// Menus
|
||||||
|
private var _infoMenu:InfoMenu;
|
||||||
|
|
||||||
// Misc
|
// Misc
|
||||||
private var _menuOption:Int;
|
private var _menuOption:Int;
|
||||||
private var _sprSelect:FlxSprite;
|
private var _sprSelect:FlxSprite;
|
||||||
@ -51,13 +55,14 @@ class HUD extends FlxTypedGroup<FlxSprite>
|
|||||||
|
|
||||||
private var _gel:Gel;
|
private var _gel:Gel;
|
||||||
|
|
||||||
public function new(g:Gel)
|
public function new(gel:Gel, infoMenu:InfoMenu)
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
|
|
||||||
// Misc
|
// Misc
|
||||||
_menuOption = 0;
|
_menuOption = 0;
|
||||||
_gel = g;
|
_gel = gel;
|
||||||
|
_infoMenu = infoMenu;
|
||||||
|
|
||||||
// Top
|
// Top
|
||||||
_sprTop = new FlxSprite(0, 0, AssetPaths.HUD_Background__png);
|
_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("hungry", [0, 1, 2, 3, 4], 3, true);
|
||||||
_sprThoughts.animation.add("poopy", [5, 6, 7, 8, 9], 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.animation.add("sleepy", [10, 11, 12, 13, 14], 4, true);
|
||||||
//_sprThoughts.visible = false;
|
|
||||||
add(_sprThoughts);
|
add(_sprThoughts);
|
||||||
|
|
||||||
|
|
||||||
|
// KILL ME PLEASE
|
||||||
_tmpText = new FlxText(_sprInteraction.x, _sprInteraction.y, 0, "", 8);
|
_tmpText = new FlxText(_sprInteraction.x, _sprInteraction.y, 0, "", 8);
|
||||||
add(_tmpText);
|
add(_tmpText);
|
||||||
|
|
||||||
// DEBUG
|
// DEBUG
|
||||||
|
FlxG.watch.add(_infoMenu, "exists", "Info Menu Open");
|
||||||
FlxG.watch.add(this, "_menuOption", "Menu Index");
|
FlxG.watch.add(this, "_menuOption", "Menu Index");
|
||||||
FlxG.watch.add(_sprInteraction, "alpha", "Interact Alpha");
|
FlxG.watch.add(_sprInteraction, "alpha", "Interact Alpha");
|
||||||
FlxG.watch.add(_sprInteraction, "visible", "Interact Visible");
|
FlxG.watch.add(_sprInteraction, "visible", "Interact Visible");
|
||||||
@ -161,6 +167,9 @@ class HUD extends FlxTypedGroup<FlxSprite>
|
|||||||
{
|
{
|
||||||
super.update(elapsed);
|
super.update(elapsed);
|
||||||
|
|
||||||
|
// If a menu is open do not let the rest of the game update
|
||||||
|
|
||||||
|
|
||||||
// TODO: Add WASD support?
|
// TODO: Add WASD support?
|
||||||
// TODO: Add vertical menu movent
|
// TODO: Add vertical menu movent
|
||||||
// TODO: Start + Select gives prompt to delete save file
|
// 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))
|
else if (FlxG.keys.justPressed.X || FlxG.gamepads.anyJustPressed(B))
|
||||||
makeOption(_menuOption);
|
makeOption(_menuOption);
|
||||||
|
|
||||||
_gel.update(elapsed);
|
|
||||||
|
|
||||||
// Gel Animation
|
// Gel Animation
|
||||||
if (_gel.CurrentMood == Gel.Mood.NEUTRAL)
|
if (_gel.CurrentMood == Gel.Mood.NEUTRAL)
|
||||||
_gel.animation.play("neutral", false);
|
_gel.animation.play("neutral", false);
|
||||||
@ -247,7 +254,7 @@ class HUD extends FlxTypedGroup<FlxSprite>
|
|||||||
{
|
{
|
||||||
// INFO
|
// INFO
|
||||||
case 0:
|
case 0:
|
||||||
//
|
showInfo();
|
||||||
|
|
||||||
// FEED
|
// FEED
|
||||||
case 1:
|
case 1:
|
||||||
@ -281,13 +288,18 @@ class HUD extends FlxTypedGroup<FlxSprite>
|
|||||||
|
|
||||||
// CONFIG
|
// CONFIG
|
||||||
case 7:
|
case 7:
|
||||||
//
|
showConfig();
|
||||||
}
|
}
|
||||||
_sndSelect.play(true);
|
_sndSelect.play(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function showInfo():Void
|
||||||
|
{
|
||||||
|
_infoMenu.OpenMenu();
|
||||||
|
}
|
||||||
|
|
||||||
private function feedGel():Void
|
private function feedGel():Void
|
||||||
{
|
{
|
||||||
itemJoin("F");
|
itemJoin("F");
|
||||||
@ -330,6 +342,11 @@ class HUD extends FlxTypedGroup<FlxSprite>
|
|||||||
_sprInteraction.fadeOut(2, itemLeave);
|
_sprInteraction.fadeOut(2, itemLeave);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function showConfig():Void
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private function itemJoin(letter:String = ""):Void
|
private function itemJoin(letter:String = ""):Void
|
||||||
{
|
{
|
||||||
_sprInteraction.visible = true;
|
_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 _hud:HUD;
|
||||||
|
|
||||||
|
private var _infoMenu:InfoMenu;
|
||||||
|
|
||||||
|
|
||||||
override public function create():Void
|
override public function create():Void
|
||||||
{
|
{
|
||||||
@ -24,8 +26,11 @@ class PlayState extends FlxState
|
|||||||
_gelPet.y = ((FlxG.height/2) - (_gelPet.height/2));
|
_gelPet.y = ((FlxG.height/2) - (_gelPet.height/2));
|
||||||
add(_gelPet);
|
add(_gelPet);
|
||||||
|
|
||||||
_hud = new HUD(_gelPet);
|
// Interface
|
||||||
|
_infoMenu = new InfoMenu(_gelPet);
|
||||||
|
_hud = new HUD(_gelPet, _infoMenu);
|
||||||
add(_hud);
|
add(_hud);
|
||||||
|
add(_infoMenu);
|
||||||
|
|
||||||
super.create();
|
super.create();
|
||||||
|
|
||||||
@ -36,5 +41,17 @@ class PlayState extends FlxState
|
|||||||
override public function update(elapsed:Float):Void
|
override public function update(elapsed:Float):Void
|
||||||
{
|
{
|
||||||
super.update(elapsed);
|
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…
x
Reference in New Issue
Block a user