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

Added Excite/Ashamed animation & sound effect 🔈

This commit is contained in:
Rain Clark 2016-10-09 05:29:51 -04:00
parent ba7653e681
commit 0354c16496
4 changed files with 48 additions and 16 deletions

BIN
assets/sounds/Ashamed.ogg Normal file

Binary file not shown.

BIN
assets/sounds/Excited.ogg Normal file

Binary file not shown.

View File

@ -2,6 +2,7 @@ package;
import flixel.FlxG;
import flixel.FlxSprite;
import flixel.system.FlxSound;
class Gel extends FlxSprite
{
@ -38,6 +39,9 @@ class Gel extends FlxSprite
// Sleep Timer
private var _hoursAsleep:Int = 0;
// Sound Effects
private var _sndExcited:FlxSound;
private var _sndAshamed:FlxSound;
// Gels internal clock
public var _clock:Clock;
@ -51,14 +55,19 @@ class Gel extends FlxSprite
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("excited", [18, 19, 20, 20, 19, 18], 6, false);
animation.add("ashamed", [21, 22, 23, 22], 4, false);
_clock = clock;
// Sound Effects
_sndExcited = FlxG.sound.load(AssetPaths.Excited__ogg);
_sndAshamed = FlxG.sound.load(AssetPaths.Ashamed__ogg);
// DEBUG
FlxG.watch.add(this, "Age");
FlxG.watch.add(this, "CurrentMood");
FlxG.watch.add(animation, "finished");
FlxG.watch.add(this, "CurrentNeed");
FlxG.watch.add(this.animation, "name", "Gel.animation");
FlxG.watch.add(this, "Wait");
@ -87,6 +96,11 @@ class Gel extends FlxSprite
if (_clock.DayPassed)
newDay();
if (animation.name == "excited" && !_sndExcited.playing)
resumeMood();
else if (animation.name == "ashamed" && !_sndAshamed.playing)
resumeMood();
checkMood();
checkNeed();
checkRange();
@ -96,6 +110,10 @@ class Gel extends FlxSprite
{
if (_isAsleep)
CurrentMood = SLEEPING;
else if (CurrentMood == EXCITED)
return;
else if (CurrentMood == ASHAMED)
return;
else
{
if (Happiness >= 61)
@ -138,7 +156,6 @@ class Gel extends FlxSprite
CurrentNeed = SLEEPY;
else
CurrentNeed = NONE;
// TODO: Make/Play alert type sound effect when need change
}
public function EatFood():Void
@ -150,7 +167,7 @@ class Gel extends FlxSprite
{
Happiness -= 5; // Unhappy from over feeding
Discipline -= 5;
// TODO: Play ashamed animationx
beAshamed();
}
else
{
@ -173,12 +190,12 @@ class Gel extends FlxSprite
Happiness -= 5;
Fullness -= 5;
Sleepiness += 15;
// TODO: play ashamed animation
beExcited();
}
}
else
{
// TODO: Play ashamed animation
beAshamed();
}
// Can only study once per hour, even if check failed
_hasStudied = true;
@ -189,7 +206,7 @@ class Gel extends FlxSprite
if (!_isTired)
{
Happiness -= 5;
// TODO: Play ashamed animation
beAshamed();
}
else
{
@ -209,7 +226,7 @@ class Gel extends FlxSprite
Happiness += 10;
Discipline -= 10;
// TODO: Play excited animation
beExcited();
}
public function Scold():Void
@ -222,9 +239,8 @@ class Gel extends FlxSprite
Happiness -= 10;
Discipline += 10;
// TODO: Play ashamed animation
beAshamed();
}
public function Wipe():Void
{
Wait = true;
@ -233,7 +249,7 @@ class Gel extends FlxSprite
if (!_wasteReady && !_madeWaste)
{
Happiness -=5;
// TODO: Pay ashamed animation to show bad wipe
beAshamed();
return;
}
@ -242,7 +258,7 @@ class Gel extends FlxSprite
{
Happiness += 10;
Discipline += 10;
// TODO: Play excited animation to show good wipe
beExcited();
}
// Late Wipe
@ -284,12 +300,22 @@ class Gel extends FlxSprite
private function beExcited():Void
{
}
CurrentMood = EXCITED;
this.animation.play("excited");
_sndExcited.play(true);
}
private function beAshamed():Void
{
CurrentMood = ASHAMED;
this.animation.play("ashamed");
_sndAshamed.play(true);
}
private function resumeMood():Void
{
CurrentMood = NEUTRAL;
checkMood;
}
private function newHour():Void

View File

@ -32,8 +32,11 @@ class MenuState extends FlxState
_txtTitle.screenCenter(X);
add(_txtTitle);
// TODO: Animate this
_sprEgg = new FlxSprite(0, 0, AssetPaths.Egg__png);
_sprEgg = new FlxSprite(0, 0);
_sprEgg.loadGraphic(AssetPaths.Egg__png, true, 32, 32);
_sprEgg.animation.add("bounce", [0, 1, 2, 1], 7, true);
_sprEgg.animation.add("crack", [3, 4, 5], 3, false);
_sprEgg.x = (FlxG.width/2) - (_sprEgg.width/2);
_sprEgg.y = (FlxG.height/2) - (_sprEgg.height/2);
add(_sprEgg);
@ -54,6 +57,9 @@ class MenuState extends FlxState
if(FlxG.keys.pressed.ENTER || FlxG.gamepads.anyJustPressed(START))
pressStart();
if(_sprEgg.animation.curAnim == null)
_sprEgg.animation.play("bounce");
super.update(elapsed);
}
@ -61,7 +67,7 @@ class MenuState extends FlxState
{
_sndSelect.play(true);
// TODO: Play Egg cracking animation
_sprEgg.animation.play("crack");
FlxG.camera.fade(FlxColor.fromRGB(136, 192, 112, 0), 0.5, true, function()
{