diff --git a/GelNotes.md b/GelNotes.md index 4ae120b..9a6f23a 100644 --- a/GelNotes.md +++ b/GelNotes.md @@ -202,4 +202,5 @@ * SE Volume * Switch controls between Arrows (defualt) or WASD * Brightness? + * Cancel (Exits menu without saving) * Pauses timer when viewing diff --git a/source/Gel.hx b/source/Gel.hx index c7f51a2..34628ac 100644 --- a/source/Gel.hx +++ b/source/Gel.hx @@ -47,12 +47,12 @@ class Gel extends FlxSprite super(X, Y); loadGraphic(AssetPaths.Player__png, true, 64, 64); - animation.add("neutral", [0, 1, 2, 3, 4, 5, 4, 3, 2, 1], 2, true); - animation.add("happy", [6, 7, 8, 9, 10, 11, 10, 9, 8, 7], 2, true); - animation.add("angry", [12, 13, 14, 13], 2, true); - animation.add("sleeping", [15, 16, 17, 16], 1, true); - animation.add("excited", [18, 19, 20, 19], 3, false); - animation.add("ashamed", [21, 22, 23, 22], 3, false); + animation.add("neutral", [0, 1, 2, 3, 4, 5, 4, 3, 2, 1], 5, true); + animation.add("happy", [6, 7, 8, 9, 10, 11, 10, 9, 8, 7], 5 true); + animation.add("angry", [12, 13, 14, 13], 5, true); + animation.add("sleeping", [15, 16, 17, 16], 3, true); + animation.add("excited", [18, 19, 20, 19], 6, false); + animation.add("ashamed", [21, 22, 23, 22], 4, false); _clock = new Clock(); diff --git a/source/HUD.hx b/source/HUD.hx index 462b10a..9432996 100644 --- a/source/HUD.hx +++ b/source/HUD.hx @@ -167,16 +167,16 @@ 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 - if (FlxG.keys.justPressed.RIGHT || FlxG.gamepads.anyJustPressed(DPAD_RIGHT)) - nextOption(true); + if (FlxG.keys.justPressed.UP || FlxG.gamepads.anyJustPressed(DPAD_UP)) + nextOption(UP); + else if (FlxG.keys.justPressed.DOWN || FlxG.gamepads.anyJustPressed(DPAD_DOWN)) + nextOption(DOWN); else if (FlxG.keys.justPressed.LEFT || FlxG.gamepads.anyJustPressed(DPAD_LEFT)) - nextOption(false); + nextOption(LEFT); + else if (FlxG.keys.justPressed.RIGHT || FlxG.gamepads.anyJustPressed(DPAD_RIGHT)) + nextOption(RIGHT); else if (FlxG.keys.justPressed.X || FlxG.gamepads.anyJustPressed(B)) makeOption(_menuOption); @@ -202,49 +202,62 @@ class HUD extends FlxTypedGroup } - private function nextOption(increment:Bool):Void + private function nextOption(direction:MenuDirection):Void { - // TODO: Add vertical menu movent - if (increment) + // TODO: Fix double tap in same vert direction + switch (direction) { - if (_menuOption >= 7) - _menuOption = 0; - else - _menuOption++; - - if (_menuOption >= 4) - { - _sprSelect.x = (_menuOption - 4) * 40; - _sprSelect.y = _sprBottom.y; - } - else - { + case UP: + _menuOption -= 4; + if (_menuOption < 0) + _menuOption = 0; _sprSelect.x = _menuOption * 40; _sprSelect.y = 0; - } - } - else - { - if (_menuOption <= 0) - _menuOption = 7; - else - _menuOption--; - - if (_menuOption >= 4) - { + case DOWN: + _menuOption += 4; + if (_menuOption > 7) + _menuOption = 7; _sprSelect.x = (_menuOption - 4) * 40; _sprSelect.y = _sprBottom.y; - } - else - { - _sprSelect.x = _menuOption * 40; - _sprSelect.y = 0; - } - } + case LEFT: + if (_menuOption <= 0) + _menuOption = 7; + else + _menuOption--; + + if (_menuOption >= 4) + { + _sprSelect.x = (_menuOption - 4) * 40; + _sprSelect.y = _sprBottom.y; + } + else + { + _sprSelect.x = _menuOption * 40; + _sprSelect.y = 0; + } + + case RIGHT: + if (_menuOption >= 7) + _menuOption = 0; + else + _menuOption++; + + if (_menuOption >= 4) + { + _sprSelect.x = (_menuOption - 4) * 40; + _sprSelect.y = _sprBottom.y; + } + else + { + _sprSelect.x = _menuOption * 40; + _sprSelect.y = 0; + } + _sndNext.play(true); } +} private function makeOption(option:Int):Void { @@ -291,6 +304,7 @@ class HUD extends FlxTypedGroup showConfig(); } _sndSelect.play(true); + // TODO: Save Game } } @@ -361,6 +375,10 @@ class HUD extends FlxTypedGroup _gel.Wait = false; } + public function SaveGame() + { + + } } // TODO: Actually use this instead of _menuChoice @@ -374,4 +392,12 @@ enum MenuOption SCOLD; WIPE; CONFIG; +} + +private enum MenuDirection +{ + UP; + DOWN; + LEFT; + RIGHT; } \ No newline at end of file diff --git a/source/Main.hx b/source/Main.hx index c7c3e8d..a3f1516 100644 --- a/source/Main.hx +++ b/source/Main.hx @@ -1,7 +1,8 @@ package; +import flixel.FlxG; import flixel.FlxGame; -import openfl.Lib; +import flixel.util.FlxSave; import openfl.display.Sprite; class Main extends Sprite @@ -9,7 +10,21 @@ class Main extends Sprite public function new() { + // SAVE BEGIN + var _save = new FlxSave(); + _save.bind("Pet.GB"); + super(); addChild(new FlxGame(0, 0, MenuState)); + + // Loads volume if exists + if (_save.data.volume != null) + FlxG.sound.volume = _save.data.volume; + // Set save data volume to default (100%) + else + _save.data.volume = FlxG.sound.volume; + + // SAVE END + _save.close(); } } diff --git a/source/PlayState.hx b/source/PlayState.hx index 9cadf14..1ac7ac0 100644 --- a/source/PlayState.hx +++ b/source/PlayState.hx @@ -15,20 +15,36 @@ class PlayState extends FlxState private var _infoMenu:InfoMenu; + public static var GameVolume = 1; override public function create():Void { + // SAVE BEGIN + var _save:FlxSave = new FlxSave(); + _save.bind("Pet.GB") + _sprBackground = new FlxSprite(0, 0, AssetPaths.background__png); add(_sprBackground); - _gelPet = new Gel(); - _gelPet.x = ((FlxG.width/2) - (_gelPet.width/2)); - _gelPet.y = ((FlxG.height/2) - (_gelPet.height/2)); + if (_save.data.GelPet == null) + { + _gelPet = new Gel(); + _gelPet.x = ((FlxG.width/2) - (_gelPet.width/2)); + _gelPet.y = ((FlxG.height/2) - (_gelPet.height/2)); + } + else + { + _gelPet = _save.data.GelPet; + _gelPet._clock = _save.data.GelPet.Clock; + } add(_gelPet); // Interface _infoMenu = new InfoMenu(_gelPet); - _hud = new HUD(_gelPet, _infoMenu); + if (_save.data.HUD == null) + _hud = new HUD(_gelPet, _infoMenu); + else + _hud = _save.data.HUD; add(_hud); add(_infoMenu); @@ -36,6 +52,9 @@ class PlayState extends FlxState // DEBUG FlxG.debugger.setLayout(FlxDebuggerLayout.RIGHT); + + // SAVE END + _save.close(); } override public function update(elapsed:Float):Void