1
0
mirror of https://github.com/Melon-Bread/Pet.GB synced 2024-11-24 20:58:19 -05:00

Toying with Gel animation speeds again 👾

This commit is contained in:
Rain Clark 2016-10-07 07:19:05 -04:00
parent f314eb7878
commit 8715a781dc
5 changed files with 112 additions and 51 deletions

View File

@ -202,4 +202,5 @@
* SE Volume * SE Volume
* Switch controls between Arrows (defualt) or WASD * Switch controls between Arrows (defualt) or WASD
* Brightness? * Brightness?
* Cancel (Exits menu without saving)
* Pauses timer when viewing * Pauses timer when viewing

View File

@ -47,12 +47,12 @@ class Gel extends FlxSprite
super(X, Y); super(X, Y);
loadGraphic(AssetPaths.Player__png, true, 64, 64); loadGraphic(AssetPaths.Player__png, true, 64, 64);
animation.add("neutral", [0, 1, 2, 3, 4, 5, 4, 3, 2, 1], 2, true); 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], 2, true); animation.add("happy", [6, 7, 8, 9, 10, 11, 10, 9, 8, 7], 5 true);
animation.add("angry", [12, 13, 14, 13], 2, true); animation.add("angry", [12, 13, 14, 13], 5, true);
animation.add("sleeping", [15, 16, 17, 16], 1, true); animation.add("sleeping", [15, 16, 17, 16], 3, true);
animation.add("excited", [18, 19, 20, 19], 3, false); animation.add("excited", [18, 19, 20, 19], 6, false);
animation.add("ashamed", [21, 22, 23, 22], 3, false); animation.add("ashamed", [21, 22, 23, 22], 4, false);
_clock = new Clock(); _clock = new Clock();

View File

@ -167,16 +167,16 @@ 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: Start + Select gives prompt to delete save file // TODO: Start + Select gives prompt to delete save file
if (FlxG.keys.justPressed.RIGHT || FlxG.gamepads.anyJustPressed(DPAD_RIGHT)) if (FlxG.keys.justPressed.UP || FlxG.gamepads.anyJustPressed(DPAD_UP))
nextOption(true); 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)) 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)) else if (FlxG.keys.justPressed.X || FlxG.gamepads.anyJustPressed(B))
makeOption(_menuOption); makeOption(_menuOption);
@ -202,30 +202,26 @@ class HUD extends FlxTypedGroup<FlxSprite>
} }
private function nextOption(increment:Bool):Void private function nextOption(direction:MenuDirection):Void
{ {
// TODO: Add vertical menu movent // TODO: Fix double tap in same vert direction
if (increment) switch (direction)
{ {
if (_menuOption >= 7) case UP:
_menuOption -= 4;
if (_menuOption < 0)
_menuOption = 0; _menuOption = 0;
else
_menuOption++;
if (_menuOption >= 4)
{
_sprSelect.x = (_menuOption - 4) * 40;
_sprSelect.y = _sprBottom.y;
}
else
{
_sprSelect.x = _menuOption * 40; _sprSelect.x = _menuOption * 40;
_sprSelect.y = 0; _sprSelect.y = 0;
}
} case DOWN:
else _menuOption += 4;
{ if (_menuOption > 7)
_menuOption = 7;
_sprSelect.x = (_menuOption - 4) * 40;
_sprSelect.y = _sprBottom.y;
case LEFT:
if (_menuOption <= 0) if (_menuOption <= 0)
_menuOption = 7; _menuOption = 7;
else else
@ -242,9 +238,26 @@ class HUD extends FlxTypedGroup<FlxSprite>
_sprSelect.y = 0; _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); _sndNext.play(true);
} }
}
private function makeOption(option:Int):Void private function makeOption(option:Int):Void
{ {
@ -291,6 +304,7 @@ class HUD extends FlxTypedGroup<FlxSprite>
showConfig(); showConfig();
} }
_sndSelect.play(true); _sndSelect.play(true);
// TODO: Save Game
} }
} }
@ -361,6 +375,10 @@ class HUD extends FlxTypedGroup<FlxSprite>
_gel.Wait = false; _gel.Wait = false;
} }
public function SaveGame()
{
}
} }
// TODO: Actually use this instead of _menuChoice // TODO: Actually use this instead of _menuChoice
@ -375,3 +393,11 @@ enum MenuOption
WIPE; WIPE;
CONFIG; CONFIG;
} }
private enum MenuDirection
{
UP;
DOWN;
LEFT;
RIGHT;
}

View File

@ -1,7 +1,8 @@
package; package;
import flixel.FlxG;
import flixel.FlxGame; import flixel.FlxGame;
import openfl.Lib; import flixel.util.FlxSave;
import openfl.display.Sprite; import openfl.display.Sprite;
class Main extends Sprite class Main extends Sprite
@ -9,7 +10,21 @@ class Main extends Sprite
public function new() public function new()
{ {
// SAVE BEGIN
var _save = new FlxSave();
_save.bind("Pet.GB");
super(); super();
addChild(new FlxGame(0, 0, MenuState)); 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();
} }
} }

View File

@ -15,20 +15,36 @@ class PlayState extends FlxState
private var _infoMenu:InfoMenu; private var _infoMenu:InfoMenu;
public static var GameVolume = 1;
override public function create():Void override public function create():Void
{ {
// SAVE BEGIN
var _save:FlxSave = new FlxSave();
_save.bind("Pet.GB")
_sprBackground = new FlxSprite(0, 0, AssetPaths.background__png); _sprBackground = new FlxSprite(0, 0, AssetPaths.background__png);
add(_sprBackground); add(_sprBackground);
if (_save.data.GelPet == null)
{
_gelPet = new Gel(); _gelPet = new Gel();
_gelPet.x = ((FlxG.width/2) - (_gelPet.width/2)); _gelPet.x = ((FlxG.width/2) - (_gelPet.width/2));
_gelPet.y = ((FlxG.height/2) - (_gelPet.height/2)); _gelPet.y = ((FlxG.height/2) - (_gelPet.height/2));
}
else
{
_gelPet = _save.data.GelPet;
_gelPet._clock = _save.data.GelPet.Clock;
}
add(_gelPet); add(_gelPet);
// Interface // Interface
_infoMenu = new InfoMenu(_gelPet); _infoMenu = new InfoMenu(_gelPet);
if (_save.data.HUD == null)
_hud = new HUD(_gelPet, _infoMenu); _hud = new HUD(_gelPet, _infoMenu);
else
_hud = _save.data.HUD;
add(_hud); add(_hud);
add(_infoMenu); add(_infoMenu);
@ -36,6 +52,9 @@ class PlayState extends FlxState
// DEBUG // DEBUG
FlxG.debugger.setLayout(FlxDebuggerLayout.RIGHT); FlxG.debugger.setLayout(FlxDebuggerLayout.RIGHT);
// SAVE END
_save.close();
} }
override public function update(elapsed:Float):Void override public function update(elapsed:Float):Void