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

Final push before submit

Sorry for not breaking down commits
This commit is contained in:
Rain Clark 2016-10-11 00:26:52 -04:00
parent de774be54c
commit 8668adb43a
13 changed files with 1075 additions and 449 deletions

File diff suppressed because it is too large Load Diff

BIN
_tmp/BoxArt.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 119 KiB

BIN
_tmp/FKGFGKHF.kra Normal file

Binary file not shown.

BIN
_tmp/Pallet.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 424 B

BIN
assets/images/Cursor.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 150 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.6 KiB

After

Width:  |  Height:  |  Size: 8.4 KiB

195
source/ConfigMenu.hx Normal file
View File

@ -0,0 +1,195 @@
package;
import flixel.FlxG;
import flixel.FlxSprite;
import flixel.group.FlxGroup;
import flixel.text.FlxText;
import flixel.util.FlxColor;
import flixel.util.FlxSave;
import haxe.xml.Parser;
class ConfigMenu extends FlxTypedGroup<FlxSprite>
{
private var _sprBackground:FlxSprite;
private var _sprCursor:FlxSprite;
private var _menuChoice:Int = 0;
private var _txtTitle:FlxText;
private var _txtVolume:FlxText;
private var _txtControls:FlxText;
private var _txtFooter:FlxText;
private var _gameMuted:Bool = false;
private var _strMuted:String = "On";
private var _usingArrows:Bool = true;
private var _strControls:String = "Arrows";
public function new()
{
super();
loadSettings();
_sprBackground = new FlxSprite(9, 9, AssetPaths.Menu__png);
add(_sprBackground);
// Title
_txtTitle = new FlxText((_sprBackground.x + 11), (_sprBackground.y + 2), 0, "Config", 16);
_txtTitle.setFormat(AssetPaths.EarlyGameBoy__ttf, 16, FlxColor.fromRGB(8, 24, 32, 0), CENTER);
_txtTitle.x = (FlxG.width/2) - (_txtTitle.width/2);
add(_txtTitle);
_sprCursor = new FlxSprite(0, 0, AssetPaths.Cursor__png);
_sprCursor.x = (_txtTitle.x - 15);
_sprCursor.y = (_sprBackground.y + 37);
add(_sprCursor);
// Content
_txtVolume = new FlxText((_sprCursor.x + _sprCursor.width), (_sprBackground.y + 33), 0 , "Sound: " + _strMuted);
_txtVolume.setFormat(AssetPaths.EarlyGameBoy__ttf, 8, FlxColor.fromRGB(8, 24, 32, 0), CENTER);
add(_txtVolume);
_txtControls = new FlxText(_txtVolume.x, (_txtVolume.y + _txtVolume.height + 1), 0, "Controls: " + _strControls);
_txtControls.setFormat(AssetPaths.EarlyGameBoy__ttf, 8, FlxColor.fromRGB(8, 24, 32, 0), CENTER);
add (_txtControls);
// Footer
_txtFooter = new FlxText((_sprBackground.x), (_sprBackground.height - 12), 0, "Press Start To Save", 8);
_txtFooter.setFormat(AssetPaths.EarlyGameBoy__ttf, 8, FlxColor.fromRGB(8, 24, 32, 0), CENTER);
add(_txtFooter);
active = false;
visible = false;
}
override public function update(elapsed:Float):Void
{
super.update(elapsed);
if (FlxG.keys.pressed.ENTER || FlxG.gamepads.anyJustPressed(START))
saveConfig();
if (_usingArrows)
{
if (FlxG.keys.justPressed.UP || FlxG.gamepads.anyJustPressed(DPAD_UP))
nextChoice(-1);
else if (FlxG.keys.justPressed.DOWN || FlxG.gamepads.anyJustPressed(DPAD_DOWN))
nextChoice(1);
else if (FlxG.keys.justPressed.LEFT || FlxG.gamepads.anyJustPressed(DPAD_LEFT))
makeChoice();
else if (FlxG.keys.justPressed.RIGHT || FlxG.gamepads.anyJustPressed(DPAD_RIGHT))
makeChoice();
}
else
{
if (FlxG.keys.justPressed.W || FlxG.gamepads.anyJustPressed(DPAD_UP))
nextChoice(-1);
else if (FlxG.keys.justPressed.S || FlxG.gamepads.anyJustPressed(DPAD_DOWN))
nextChoice(1);
else if (FlxG.keys.justPressed.A || FlxG.gamepads.anyJustPressed(DPAD_LEFT))
makeChoice();
else if (FlxG.keys.justPressed.D || FlxG.gamepads.anyJustPressed(DPAD_RIGHT))
makeChoice();
}
}
private function nextChoice(amount:Int)
{
_menuChoice += amount;
if (_menuChoice < 0)
_menuChoice = 2;
else if (_menuChoice > 1)
_menuChoice = 0;
switch (_menuChoice)
{
case 0:
_sprCursor.y = (_sprBackground.y + 37);
case 1:
_sprCursor.y = (_txtControls.y + 4);
}
}
private function makeChoice()
{
switch (_menuChoice)
{
case 0:
_gameMuted = !_gameMuted;
case 1:
_usingArrows = !_usingArrows;
}
updateInfo();
}
private function saveConfig():Void
{
var _save = new FlxSave();
_save.bind("Pet.GB");
if (_gameMuted)
_save.data.muted = true;
else if (!_gameMuted)
_save.data.muted = false;
if (_usingArrows)
_save.data.arrowInput = true;
else if (!_usingArrows)
_save.data.arrowInput = false;
_save.close();
closeMenu();
}
public function OpenMenu():Void
{
loadSettings();
visible = true;
active = true;
updateInfo();
}
private function closeMenu():Void
{
active = false;
visible = false;
}
private function updateInfo():Void
{
if (!_gameMuted)
_strMuted = "On";
else
_strMuted = "Off";
if (_usingArrows)
_strControls = "Arrows";
else
_strControls = "WASD";
_txtVolume.text = "Volume: " + _strMuted;
_txtControls.text = "Controls: " + _strControls;
}
private function loadSettings():Void
{
var _save = new FlxSave();
_save.bind("Pet.GB");
_usingArrows = _save.data.arrowInput;
FlxG.sound.muted = _save.data.muted;
_save.close();
}
}

39
source/EndState.hx Normal file
View File

@ -0,0 +1,39 @@
package;
import flixel.FlxG;
import flixel.FlxState;
import flixel.text.FlxText;
import flixel.util.FlxColor;
class EndState extends FlxState
{
private var _txtMessage:FlxText;
override public function create():Void
{
super.create();
_txtMessage = new FlxText(9, 9, 0, "Your Pet Gel Buddy\nHas Moved On.\n\nIt Feels You Should\nDo The Same.");
_txtMessage.setFormat(AssetPaths.EarlyGameBoy__ttf, 8, FlxColor.fromRGB(136, 192, 112, 0), CENTER);
add(_txtMessage);
}
override public function update(elapsed:Float):Void
{
super.update(elapsed);
set_bgColor(FlxColor.fromRGB(8, 24, 32, 0));
if (FlxG.keys.pressed.ENTER || FlxG.gamepads.anyJustPressed(START))
goMainMenu();
}
private function goMainMenu():Void
{
FlxG.camera.fade(FlxColor.BLACK, .33, false, function()
{
FlxG.switchState(new MenuState());
});
}
}

View File

@ -3,6 +3,7 @@ package;
import flixel.FlxG; import flixel.FlxG;
import flixel.FlxSprite; import flixel.FlxSprite;
import flixel.system.FlxSound; import flixel.system.FlxSound;
import flixel.util.FlxSave;
class Gel extends FlxSprite class Gel extends FlxSprite
{ {
@ -10,6 +11,11 @@ class Gel extends FlxSprite
private var MIN_LEVEL(default, never):Int = 0; private var MIN_LEVEL(default, never):Int = 0;
private var MAX_LEVEL(default, never):Int = 100; private var MAX_LEVEL(default, never):Int = 100;
// END_GAME
public var ENDGAME:Bool = false;
private var _endFlags:Int = 0;
private var _hoursSuffering:Int = 0;
// Usless Stats that have no pupose yet // Usless Stats that have no pupose yet
public var Intellect:Int = 1; // Had to be somewhat smart to get out of the egg public var Intellect:Int = 1; // Had to be somewhat smart to get out of the egg
public var Age:Int = 1; public var Age:Int = 1;
@ -65,6 +71,9 @@ class Gel extends FlxSprite
_sndAshamed = FlxG.sound.load(AssetPaths.Ashamed__ogg); _sndAshamed = FlxG.sound.load(AssetPaths.Ashamed__ogg);
// DEBUG // DEBUG
FlxG.watch.add(this, "ENDGAME");
FlxG.watch.add(this, "_endFlags");
FlxG.watch.add(this, "_hoursSuffering");
FlxG.watch.add(this, "Age"); FlxG.watch.add(this, "Age");
FlxG.watch.add(this, "CurrentMood"); FlxG.watch.add(this, "CurrentMood");
FlxG.watch.add(animation, "finished"); FlxG.watch.add(animation, "finished");
@ -90,6 +99,11 @@ class Gel extends FlxSprite
{ {
super.update(elapsed); super.update(elapsed);
loadSettings();
if (_endFlags > 2)
ENDGAME = true;
_clock.update(); _clock.update();
if (_clock.HourPassed) if (_clock.HourPassed)
newHour(); newHour();
@ -358,12 +372,22 @@ class Gel extends FlxSprite
_hasStudied = false; _hasStudied = false;
_clock.HourPassed = false; _clock.HourPassed = false;
// END_GAME Checks
if (CurrentMood == ANGRY || _madeWaste || _isHungry)
_hoursSuffering ++;
else
_hoursSuffering = 0;
if (_hoursSuffering > 1)
_endFlags++;
else if (_hoursSuffering > 3)
ENDGAME = true;
} }
private function newDay():Void private function newDay():Void
{ {
Age++; Age++;
// TODO: Add END_GAME checks here
_clock.DayPassed = false; _clock.DayPassed = false;
} }
@ -395,6 +419,15 @@ class Gel extends FlxSprite
else if (Waste < MIN_LEVEL) else if (Waste < MIN_LEVEL)
Waste = MIN_LEVEL; Waste = MIN_LEVEL;
} }
private function loadSettings():Void
{
var _save = new FlxSave();
_save.bind("Pet.GB");
FlxG.sound.muted = _save.data.muted;
_save.close();
}
} }
enum Mood enum Mood

View File

@ -8,6 +8,8 @@ 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.util.FlxSave;
import haxe.xml.Parser;
using flixel.util.FlxSpriteUtil; using flixel.util.FlxSpriteUtil;
@ -52,22 +54,29 @@ class HUD extends FlxTypedGroup<FlxSprite>
// Menus // Menus
private var _infoMenu:InfoMenu; private var _infoMenu:InfoMenu;
private var _configMenu:ConfigMenu;
// Misc // Misc
private var _menuOption:Int; private var _menuOption:Int;
private var _sprSelect:FlxSprite; private var _sprSelect:FlxSprite;
private var _gel:Gel; private var _gel:Gel;
private var _clock:Clock; private var _clock:Clock;
private var _usingArrows:Bool = true;
public function new(gel:Gel, clock:Clock, infoMenu:InfoMenu) public function new(gel:Gel, clock:Clock, infoMenu:InfoMenu, configMenu:ConfigMenu)
{ {
super(); super();
loadSettings();
// Misc // Misc
_menuOption = 0; _menuOption = 0;
_gel = gel; _gel = gel;
_clock = clock; _clock = clock;
_infoMenu = infoMenu; _infoMenu = infoMenu;
_configMenu = configMenu;
// Top // Top
_sprTop = new FlxSprite(0, 0, AssetPaths.HUD_Background__png); _sprTop = new FlxSprite(0, 0, AssetPaths.HUD_Background__png);
@ -179,19 +188,43 @@ class HUD extends FlxTypedGroup<FlxSprite>
override public function update(elapsed:Float):Void override public function update(elapsed:Float):Void
{ {
super.update(elapsed); super.update(elapsed);
loadSettings();
// TODO: Add WASD support? if (_gel.ENDGAME)
// TODO: Start + Select gives prompt to delete save file {
if (FlxG.keys.justPressed.UP || FlxG.gamepads.anyJustPressed(DPAD_UP)) FlxG.camera.fade(FlxColor.fromRGB(8, 24, 32, 0), 0.5, true, function()
nextOption(UP); {
else if (FlxG.keys.justPressed.DOWN || FlxG.gamepads.anyJustPressed(DPAD_DOWN)) FlxG.switchState(new EndState());
nextOption(DOWN); });
else if (FlxG.keys.justPressed.LEFT || FlxG.gamepads.anyJustPressed(DPAD_LEFT)) }
nextOption(LEFT);
else if (FlxG.keys.justPressed.RIGHT || FlxG.gamepads.anyJustPressed(DPAD_RIGHT))
nextOption(RIGHT); if (_usingArrows)
else if (FlxG.keys.justPressed.X || FlxG.gamepads.anyJustPressed(B)) {
makeOption(_menuOption); 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(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);
}
else
{
if (FlxG.keys.justPressed.W || FlxG.gamepads.anyJustPressed(DPAD_UP))
nextOption(UP);
else if (FlxG.keys.justPressed.S || FlxG.gamepads.anyJustPressed(DPAD_DOWN))
nextOption(DOWN);
else if (FlxG.keys.justPressed.A || FlxG.gamepads.anyJustPressed(DPAD_LEFT))
nextOption(LEFT);
else if (FlxG.keys.justPressed.D || FlxG.gamepads.anyJustPressed(DPAD_RIGHT))
nextOption(RIGHT);
else if (FlxG.keys.justPressed.X || FlxG.gamepads.anyJustPressed(B))
makeOption(_menuOption);
}
// Wasting Check // Wasting Check
if (_gel._madeWaste == true) if (_gel._madeWaste == true)
@ -281,9 +314,9 @@ class HUD extends FlxTypedGroup<FlxSprite>
_sprSelect.x = _menuOption * 40; _sprSelect.x = _menuOption * 40;
_sprSelect.y = 0; _sprSelect.y = 0;
} }
}
_sndNext.play(true);
} }
_sndNext.play(true);
}
private function makeOption(option:Int):Void private function makeOption(option:Int):Void
{ {
@ -382,7 +415,7 @@ class HUD extends FlxTypedGroup<FlxSprite>
private function showConfig():Void private function showConfig():Void
{ {
// TODO: Make Config menu and call it here _configMenu.OpenMenu();
} }
private function showThought(thought:String):Void private function showThought(thought:String):Void
@ -410,6 +443,18 @@ class HUD extends FlxTypedGroup<FlxSprite>
_sprInteraction.animation.play("none"); _sprInteraction.animation.play("none");
_gel.Wait = false; _gel.Wait = false;
} }
private function loadSettings():Void
{
var _save = new FlxSave();
_save.bind("Pet.GB");
_usingArrows = _save.data.arrowInput;
FlxG.sound.muted = _save.data.muted;
_save.close();
}
} }
private enum MenuDirection private enum MenuDirection

View File

@ -27,6 +27,7 @@ class InfoMenu extends FlxTypedGroup<FlxSprite>
_sprBackground = new FlxSprite(9, 9, AssetPaths.Menu__png); _sprBackground = new FlxSprite(9, 9, AssetPaths.Menu__png);
add(_sprBackground); add(_sprBackground);
// Title
_txtTitle = new FlxText((_sprBackground.x + 11), (_sprBackground.y + 2), 0, "Gel Info", 16); _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); _txtTitle.setFormat(AssetPaths.EarlyGameBoy__ttf, 16, FlxColor.fromRGB(8, 24, 32, 0), CENTER);
add(_txtTitle); add(_txtTitle);
@ -60,8 +61,6 @@ class InfoMenu extends FlxTypedGroup<FlxSprite>
public function OpenMenu():Void public function OpenMenu():Void
{ {
//_sprBackground.drawFrame();
visible = true; visible = true;
active = true; active = true;
updateInfo(); updateInfo();

View File

@ -7,7 +7,6 @@ import openfl.display.Sprite;
class Main extends Sprite class Main extends Sprite
{ {
// TODO: Fix Gel Colors
// TODO: Add END_GAME Flags // TODO: Add END_GAME Flags
// TODO: Makes saving work for at least the config screen // TODO: Makes saving work for at least the config screen
// TODO: Make Game Over screen // TODO: Make Game Over screen
@ -18,17 +17,13 @@ class Main extends Sprite
_save.bind("Pet.GB"); _save.bind("Pet.GB");
super(); super();
addChild(new FlxGame(0, 0, MenuState)); addChild(new FlxGame(0, 0, MenuState, 1, 60, 60, true, false));
// Loads volume if exists // Loads Settings
if (_save.data.volume != null) if (_save.data.gameMuted = true)
FlxG.sound.volume = _save.data.volume; FlxG.sound.muted = _save.data.muted;
// Set save data volume to default (100%) if (_save.data.arrowInput == null)
else _save.data.arrowInput = true;
_save.data.volume = 1;
// SAVE WRITE
_save.flush();
// SAVE END // SAVE END
_save.close(); _save.close();

View File

@ -17,6 +17,7 @@ class PlayState extends FlxState
private var _hud:HUD; private var _hud:HUD;
private var _infoMenu:InfoMenu; private var _infoMenu:InfoMenu;
private var _configMenu:ConfigMenu;
override public function create():Void override public function create():Void
@ -30,33 +31,28 @@ class PlayState extends FlxState
_clock = new Clock(); _clock = new Clock();
if (_save.data.GelPet == null) _gelPet = new Gel(0, 0, _clock);
{ _gelPet.x = ((FlxG.width/2) - (_gelPet.width/2));
_gelPet = new Gel(0, 0, _clock); _gelPet.y = ((FlxG.height/2) - (_gelPet.height/2));
_gelPet.x = ((FlxG.width/2) - (_gelPet.width/2));
_gelPet.y = ((FlxG.height/2) - (_gelPet.height/2));
}
else
{
_gelPet = _save.data.gel;
_gelPet._clock = _save.data.clock;
}
add(_gelPet); add(_gelPet);
// Interface // Interface
_infoMenu = new InfoMenu(_gelPet); _infoMenu = new InfoMenu(_gelPet);
if (_save.data.HUD == null) _configMenu = new ConfigMenu();
_hud = new HUD(_gelPet, _clock, _infoMenu); _hud = new HUD(_gelPet, _clock, _infoMenu, _configMenu);
else
_hud = _save.data.hud;
add(_hud); add(_hud);
add(_infoMenu); add(_infoMenu);
add(_configMenu);
super.create(); super.create();
// DEBUG // DEBUG
FlxG.debugger.setLayout(FlxDebuggerLayout.RIGHT); FlxG.debugger.setLayout(FlxDebuggerLayout.RIGHT);
// Loads Settings
FlxG.sound.muted = _save.data.muted;
// SAVE END // SAVE END
_save.close(); _save.close();
} }
@ -64,10 +60,10 @@ 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) if (_infoMenu.visible || _configMenu.visible)
{ {
_gelPet.active = false; _gelPet.active = false;
_clock.pause(true); _clock.pause();
_hud.active = false; _hud.active = false;
} }
else else
@ -75,7 +71,6 @@ class PlayState extends FlxState
_gelPet.active = true; _gelPet.active = true;
_clock.pause(false); _clock.pause(false);
_hud.active = true; _hud.active = true;
saveGame();
} }
if (_gelPet.CurrentMood == Gel.Mood.EXCITED || _gelPet.CurrentMood == Gel.Mood.ASHAMED) if (_gelPet.CurrentMood == Gel.Mood.EXCITED || _gelPet.CurrentMood == Gel.Mood.ASHAMED)
@ -83,36 +78,4 @@ class PlayState extends FlxState
else else
_clock.pause(false); _clock.pause(false);
} }
private function saveGame()
{
// SAVE BEGIN
var _save:FlxSave = new FlxSave();
_save.bind("Pet.GB");
// SAVED DATA
_save.data.gel = _gelPet;
_save.data.clock = _gelPet._clock;
_save.data.hud = _hud;
//_save.data.age = _gel.age;
// WRITE SAVE
//_save.flush();
// SAVE END
_save.close;
}
private function quitGame():Void
{
// SAVE BEGIN
var _save:FlxSave = new FlxSave();
_save.bind("Pet.GB");
// SAVED DATA
_save.data.HUD = _hud;
// SAVE END
_save.close;
}
} }