From 94e90430d4f86a8bf8167f6385f433652d82d1e7 Mon Sep 17 00:00:00 2001 From: Rain Clark Date: Fri, 7 Oct 2016 06:01:39 -0400 Subject: [PATCH] Info menu not works :information_source: Pauses rest of game when open --- assets/images/Menu.png | Bin 0 -> 582 bytes source/HUD.hx | 33 ++++++++++++---- source/InfoMenu.hx | 83 +++++++++++++++++++++++++++++++++++++++++ source/PlayState.hx | 19 +++++++++- 4 files changed, 126 insertions(+), 9 deletions(-) create mode 100644 assets/images/Menu.png create mode 100644 source/InfoMenu.hx diff --git a/assets/images/Menu.png b/assets/images/Menu.png new file mode 100644 index 0000000000000000000000000000000000000000..3fcb4dc7c61ca9c34ba22a3ea56bfc49f66a95d2 GIT binary patch literal 582 zcmeAS@N?(olHy`uVBq!ia0vp^6M(pZgAGVNneafFfq{wF)5S5QV$R!J`gykt7}^q- zOMMXJ;bkrsIV_jB!JXrcAscgX%b|mZ4%|J$9JXjw>FVt-Le|~D0hl+oK-1ML5MIh z={3{dYV}`VUjLYS{g{28wf?=%WgmH59!Yk%G&6&*eRF`-OSsZ|dzn-T8H$!?n6C*IA{2aWFrAURd_~yTCX* gYjO59!~8GO{6=kZsVBal0j3WIPgg&ebxsLQ02Bu1CjbBd literal 0 HcmV?d00001 diff --git a/source/HUD.hx b/source/HUD.hx index 063399f..462b10a 100644 --- a/source/HUD.hx +++ b/source/HUD.hx @@ -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 { // Top @@ -44,6 +45,9 @@ class HUD extends FlxTypedGroup 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 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 _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 { 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 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 { // INFO case 0: - // + showInfo(); // FEED case 1: @@ -281,13 +288,18 @@ class HUD extends FlxTypedGroup // 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 _sprInteraction.fadeOut(2, itemLeave); } + private function showConfig():Void + { + + } + private function itemJoin(letter:String = ""):Void { _sprInteraction.visible = true; diff --git a/source/InfoMenu.hx b/source/InfoMenu.hx new file mode 100644 index 0000000..a1bae9f --- /dev/null +++ b/source/InfoMenu.hx @@ -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 +{ + 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; + } +} \ No newline at end of file diff --git a/source/PlayState.hx b/source/PlayState.hx index b1f87bd..9cadf14 100644 --- a/source/PlayState.hx +++ b/source/PlayState.hx @@ -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; + } } }