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

82 lines
1.6 KiB
Haxe
Raw Permalink Normal View History

2016-10-03 20:43:09 -04:00
package;
import flixel.FlxG;
import flixel.FlxSprite;
import flixel.FlxState;
2016-10-06 01:18:02 -04:00
import flixel.system.debug.FlxDebugger;
import flixel.util.FlxSave;
2016-10-03 20:43:09 -04:00
class PlayState extends FlxState
{
private var _sprBackground:FlxSprite;
private var _gelPet:Gel;
private var _clock:Clock;
2016-10-03 20:43:09 -04:00
private var _hud:HUD;
private var _infoMenu:InfoMenu;
private var _configMenu:ConfigMenu;
2016-10-06 01:18:02 -04:00
2016-10-03 20:43:09 -04:00
override public function create():Void
{
// SAVE BEGIN
var _save:FlxSave = new FlxSave();
_save.bind("Pet.GB");
2016-10-03 20:43:09 -04:00
_sprBackground = new FlxSprite(0, 0, AssetPaths.background__png);
add(_sprBackground);
_clock = new Clock();
_gelPet = new Gel(0, 0, _clock);
_gelPet.x = ((FlxG.width/2) - (_gelPet.width/2));
_gelPet.y = ((FlxG.height/2) - (_gelPet.height/2));
2016-10-03 20:43:09 -04:00
add(_gelPet);
// Interface
_infoMenu = new InfoMenu(_gelPet);
_configMenu = new ConfigMenu();
_hud = new HUD(_gelPet, _clock, _infoMenu, _configMenu);
2016-10-03 20:43:09 -04:00
add(_hud);
add(_infoMenu);
add(_configMenu);
2016-10-03 20:43:09 -04:00
super.create();
2016-10-07 00:16:45 -04:00
// DEBUG
FlxG.debugger.setLayout(FlxDebuggerLayout.RIGHT);
// Loads Settings
FlxG.sound.muted = _save.data.muted;
// SAVE END
_save.close();
2016-10-03 20:43:09 -04:00
}
override public function update(elapsed:Float):Void
{
super.update(elapsed);
if (_infoMenu.visible || _configMenu.visible)
{
_gelPet.active = false;
_clock.pause();
_hud.active = false;
}
else
{
_gelPet.active = true;
2016-10-09 05:30:25 -04:00
_clock.pause(false);
_hud.active = true;
}
2016-10-09 05:30:25 -04:00
if (_gelPet.CurrentMood == Gel.Mood.EXCITED || _gelPet.CurrentMood == Gel.Mood.ASHAMED)
_clock.pause();
else
_clock.pause(false);
2016-10-03 20:43:09 -04:00
}
}