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

Sound effect now plays when new thought pops up

This commit is contained in:
Rain Clark 2016-10-09 05:30:10 -04:00
parent 0354c16496
commit 02590653d3
2 changed files with 19 additions and 4 deletions

BIN
assets/sounds/Thought.ogg Normal file

Binary file not shown.

View File

@ -45,6 +45,7 @@ class HUD extends FlxTypedGroup<FlxSprite>
// Sounds // Sounds
private var _sndSelect:FlxSound; private var _sndSelect:FlxSound;
private var _sndNext:FlxSound; private var _sndNext:FlxSound;
private var _sndThought:FlxSound;
// Time Display // Time Display
private var _txtTime:FlxText; private var _txtTime:FlxText;
@ -135,6 +136,8 @@ class HUD extends FlxTypedGroup<FlxSprite>
// Sound // Sound
_sndSelect = FlxG.sound.load(AssetPaths.Select__ogg); _sndSelect = FlxG.sound.load(AssetPaths.Select__ogg);
_sndNext = FlxG.sound.load(AssetPaths.Next__ogg); _sndNext = FlxG.sound.load(AssetPaths.Next__ogg);
_sndThought = FlxG.sound.load(AssetPaths.Thought__ogg);
// Menu Selecter // Menu Selecter
_sprSelect = new FlxSprite(0, 0, AssetPaths.tmpSelect__png); _sprSelect = new FlxSprite(0, 0, AssetPaths.tmpSelect__png);
@ -209,17 +212,17 @@ class HUD extends FlxTypedGroup<FlxSprite>
// Need Bubble // Need Bubble
if (_gel.CurrentNeed == Gel.Need.NONE) if (_gel.CurrentNeed == Gel.Need.NONE)
_sprThoughts.animation.play("none", false); showThought("none");
else if (_gel.CurrentNeed == Gel.Need.HUNGRY) else if (_gel.CurrentNeed == Gel.Need.HUNGRY)
_sprThoughts.animation.play("hungry", false); showThought("hungry");
else if (_gel.CurrentNeed == Gel.Need.POOPY) else if (_gel.CurrentNeed == Gel.Need.POOPY)
{ {
// The odds of the Gel willing to communicate its about to make Waste // The odds of the Gel willing to communicate its about to make Waste
if (FlxG.random.bool((((_gel.Discipline * 3) + _gel.Intellect)) / 4)) if (FlxG.random.bool((((_gel.Discipline * 3) + _gel.Intellect)) / 4))
_sprThoughts.animation.play("poopy", false); showThought("poopy");
} }
else if (_gel.CurrentNeed == Gel.Need.SLEEPY) else if (_gel.CurrentNeed == Gel.Need.SLEEPY)
_sprThoughts.animation.play("sleepy", false); showThought("sleepy");
// Update time display // Update time display
_txtTime.text = Std.string(_clock.CurrentHour) + ":00"; _txtTime.text = Std.string(_clock.CurrentHour) + ":00";
@ -382,6 +385,18 @@ class HUD extends FlxTypedGroup<FlxSprite>
// TODO: Make Config menu and call it here // TODO: Make Config menu and call it here
} }
private function showThought(thought:String):Void
{
if (_sprThoughts.animation.name == thought)
return;
else
{
_sprThoughts.animation.play(thought, false);
if (thought != "none")
_sndThought.play(true);
}
}
private function itemJoin(animation:String):Void private function itemJoin(animation:String):Void
{ {
_sprInteraction.visible = true; _sprInteraction.visible = true;