mirror of
https://github.com/Melon-Bread/Pet.GB
synced 2024-11-28 13:58:20 -05:00
Made it more alive 💧
- Added internal clock - Can dev needs naturaly - Slowed down animations
This commit is contained in:
parent
9d3c665b95
commit
bcfca242a4
170
source/Gel.hx
170
source/Gel.hx
@ -23,45 +23,64 @@ class Gel extends FlxSprite
|
|||||||
//private var _inEgg:Bool = true;
|
//private var _inEgg:Bool = true;
|
||||||
public var _isHungry:Bool = false;
|
public var _isHungry:Bool = false;
|
||||||
public var _wasteReady:Bool = false;
|
public var _wasteReady:Bool = false;
|
||||||
private var _madeWaste:Bool = false;
|
public var _madeWaste:Bool = false;
|
||||||
public var _isTired:Bool = false;
|
public var _isTired:Bool = false;
|
||||||
private var _isAsleep:Bool = false;
|
public var _isAsleep:Bool = false;
|
||||||
|
|
||||||
// Mood/Needs
|
// Mood/Needs
|
||||||
public var CurrentMood:Mood = HAPPY;
|
public var CurrentMood:Mood = NEUTRAL;
|
||||||
public var CurrentNeed:Need = NONE;
|
public var CurrentNeed:Need = NONE;
|
||||||
|
|
||||||
//
|
//
|
||||||
public var Wait:Bool = false;
|
public var Wait:Bool = false;
|
||||||
|
|
||||||
|
// Gels internal clock
|
||||||
|
private var _clock:Clock;
|
||||||
|
|
||||||
public function new(?X:Float=0, ?Y:Float=0)
|
public function new(?X:Float=0, ?Y:Float=0)
|
||||||
{
|
{
|
||||||
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, 5, 2, 1], 4, true);
|
animation.add("neutral", [0, 1, 2, 3, 4, 5, 4, 3, 2, 1], 2, true);
|
||||||
animation.add("happy", [6, 7, 8, 9, 10, 11, 10, 9, 8, 7], 4, true);
|
animation.add("happy", [6, 7, 8, 9, 10, 11, 10, 9, 8, 7], 2, true);
|
||||||
animation.add("angry", [12, 13, 14, 13], 4, true);
|
animation.add("angry", [12, 13, 14, 13], 2, true);
|
||||||
animation.add("sleeping", [15, 16, 17, 16], 3, true);
|
animation.add("sleeping", [15, 16, 17, 16], 2, true);
|
||||||
animation.add("excited", [18, 19, 20, 19], 5, false);
|
animation.add("excited", [18, 19, 20, 19], 3, false);
|
||||||
animation.add("ashamed", [21, 22, 23, 22], 5, false);
|
animation.add("ashamed", [21, 22, 23, 22], 3, false);
|
||||||
|
|
||||||
|
_clock = new Clock();
|
||||||
|
|
||||||
// DEBUG
|
// DEBUG
|
||||||
|
FlxG.watch.add(this, "Age");
|
||||||
FlxG.watch.add(this, "CurrentMood");
|
FlxG.watch.add(this, "CurrentMood");
|
||||||
FlxG.watch.add(this, "CurrentNeed");
|
FlxG.watch.add(this, "CurrentNeed");
|
||||||
FlxG.watch.add(this.animation, "curAnim");
|
|
||||||
FlxG.watch.add(this, "Wait");
|
FlxG.watch.add(this, "Wait");
|
||||||
FlxG.watch.add(this, "Happiness");
|
FlxG.watch.add(this, "Happiness");
|
||||||
FlxG.watch.add(this, "Discipline");
|
FlxG.watch.add(this, "Discipline");
|
||||||
FlxG.watch.add(this, "Fullness");
|
FlxG.watch.add(this, "Fullness");
|
||||||
|
FlxG.watch.add(this, "_isHungry");
|
||||||
|
FlxG.watch.add(this, "Waste");
|
||||||
|
FlxG.watch.add(this, "_wasteReady");
|
||||||
|
FlxG.watch.add(this, "_madeWaste");
|
||||||
|
FlxG.watch.add(this, "Sleepiness");
|
||||||
|
FlxG.watch.add(this, "_isTired");
|
||||||
|
FlxG.watch.add(this, "_isAsleep");
|
||||||
}
|
}
|
||||||
|
|
||||||
override function update(elapsed:Float):Void
|
override function update(elapsed:Float):Void
|
||||||
{
|
{
|
||||||
super.update(elapsed);
|
super.update(elapsed);
|
||||||
|
|
||||||
|
_clock.update();
|
||||||
|
if (_clock.HourPassed)
|
||||||
|
newHour();
|
||||||
|
if (_clock.DayPassed)
|
||||||
|
newDay();
|
||||||
|
|
||||||
checkMood();
|
checkMood();
|
||||||
checkNeed();
|
checkNeed();
|
||||||
|
checkRange();
|
||||||
}
|
}
|
||||||
|
|
||||||
private function checkMood():Void
|
private function checkMood():Void
|
||||||
@ -72,12 +91,27 @@ class Gel extends FlxSprite
|
|||||||
CurrentMood = NEUTRAL;
|
CurrentMood = NEUTRAL;
|
||||||
else if (Happiness <= 39)
|
else if (Happiness <= 39)
|
||||||
CurrentMood = ANGRY;
|
CurrentMood = ANGRY;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function checkNeed():Void
|
private function checkNeed():Void
|
||||||
{
|
{
|
||||||
// TODO: Add need flah triggers
|
// TODO: Add need stat triggers
|
||||||
|
|
||||||
|
// Fullness Checks
|
||||||
|
if(Fullness < 50)
|
||||||
|
_isHungry = true;
|
||||||
|
else
|
||||||
|
_isHungry = false;
|
||||||
|
|
||||||
|
// Waste Check
|
||||||
|
if(Waste > 75 && Waste < 100)
|
||||||
|
_wasteReady = true;
|
||||||
|
else if (Waste >= 100)
|
||||||
|
makeWaste();
|
||||||
|
else
|
||||||
|
_wasteReady = false;
|
||||||
|
|
||||||
|
|
||||||
if (_isHungry)
|
if (_isHungry)
|
||||||
CurrentNeed = HUNGRY;
|
CurrentNeed = HUNGRY;
|
||||||
else if (_wasteReady)
|
else if (_wasteReady)
|
||||||
@ -86,7 +120,6 @@ class Gel extends FlxSprite
|
|||||||
CurrentNeed = SLEEPY;
|
CurrentNeed = SLEEPY;
|
||||||
else
|
else
|
||||||
CurrentNeed = NONE;
|
CurrentNeed = NONE;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -98,6 +131,7 @@ class Gel extends FlxSprite
|
|||||||
if ((Fullness + 25) > 100)
|
if ((Fullness + 25) > 100)
|
||||||
{
|
{
|
||||||
Happiness -= 5; // Unhappy from over feeding
|
Happiness -= 5; // Unhappy from over feeding
|
||||||
|
// TODO: Play ashamed animationx
|
||||||
// TODO: Add another penelty
|
// TODO: Add another penelty
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -105,36 +139,109 @@ class Gel extends FlxSprite
|
|||||||
Fullness += 25;
|
Fullness += 25;
|
||||||
Happiness += 10;
|
Happiness += 10;
|
||||||
Discipline -=5;
|
Discipline -=5;
|
||||||
|
Waste +=5;
|
||||||
}
|
}
|
||||||
|
}x
|
||||||
checkRange();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function Praise():Void
|
public function Praise():Void
|
||||||
{
|
{
|
||||||
Wait = true;
|
Wait = true;
|
||||||
|
|
||||||
|
// Can't Prasie if you have no Happiness to give
|
||||||
|
if (Discipline < 10)
|
||||||
|
return;
|
||||||
|
|
||||||
Happiness += 10;
|
Happiness += 10;
|
||||||
Discipline -= 10;
|
Discipline -= 10;
|
||||||
checkRange();
|
// TODO: Play excited animation
|
||||||
}
|
}
|
||||||
|
|
||||||
public function Scold():Void
|
public function Scold():Void
|
||||||
{
|
{
|
||||||
Wait = true;
|
Wait = true;
|
||||||
|
|
||||||
|
// Can't Scold if you have no Discipline to give
|
||||||
|
if (Discipline < 10)
|
||||||
|
return;
|
||||||
|
|
||||||
Happiness -= 10;
|
Happiness -= 10;
|
||||||
Discipline += 10;
|
Discipline += 10;
|
||||||
checkRange();
|
// TODO: Play ashamed animation
|
||||||
|
}
|
||||||
|
|
||||||
|
public function Wipe():Void
|
||||||
|
{
|
||||||
|
Wait = true;
|
||||||
|
// TODO: Lock Wipe down for the rest of hour
|
||||||
|
|
||||||
|
// Early Wipe
|
||||||
|
if (!_wasteReady)
|
||||||
|
{
|
||||||
|
Happiness -=5;
|
||||||
|
// TODO: Pay ashamed animation to show bad wipe
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Good Wipe
|
||||||
|
if (!_madeWaste)
|
||||||
|
{
|
||||||
|
Happiness += 10;
|
||||||
|
Discipline += 10;
|
||||||
|
// TODO: Play excited animation to show good wipe
|
||||||
|
}
|
||||||
|
|
||||||
|
// Late Wipe
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Happiness -= 10;
|
||||||
|
Discipline -= 10;
|
||||||
|
_madeWaste = false;
|
||||||
|
}
|
||||||
|
Waste = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function makeWaste():Void
|
||||||
|
{
|
||||||
|
Waste = 0;
|
||||||
|
_madeWaste = true;
|
||||||
|
_wasteReady = false;
|
||||||
|
}
|
||||||
|
private function newHour():Void
|
||||||
|
{
|
||||||
|
Fullness -= 10;
|
||||||
|
Sleepiness += 5;
|
||||||
|
if (!_madeWaste)
|
||||||
|
Waste += (FlxG.random.int(2, 5) * 5);
|
||||||
|
|
||||||
|
// TODO: Add other stat changing conditions
|
||||||
|
if (_isHungry)
|
||||||
|
Happiness -= 10;
|
||||||
|
if (_isTired)
|
||||||
|
{
|
||||||
|
Happiness -= 10;
|
||||||
|
Discipline -= 5;
|
||||||
|
}
|
||||||
|
if (_madeWaste)
|
||||||
|
{
|
||||||
|
Happiness -=10;
|
||||||
|
Discipline -=10;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// TODO: Unlock Wipe
|
||||||
|
_clock.HourPassed = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function newDay():Void
|
||||||
|
{
|
||||||
|
Age++;
|
||||||
|
// TODO: Add END_GAME checks here
|
||||||
|
_clock.DayPassed = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function checkRange():Void
|
private function checkRange():Void
|
||||||
{
|
{
|
||||||
if (Fullness > MAX_LEVEL)
|
// TODO: clean this up, make a for loop to loop array ints
|
||||||
Fullness = MAX_LEVEL;
|
|
||||||
else if (Fullness < MIN_LEVEL)
|
|
||||||
Fullness = MIN_LEVEL;
|
|
||||||
|
|
||||||
if (Happiness > MAX_LEVEL)
|
if (Happiness > MAX_LEVEL)
|
||||||
Happiness = MAX_LEVEL;
|
Happiness = MAX_LEVEL;
|
||||||
else if (Happiness < MIN_LEVEL)
|
else if (Happiness < MIN_LEVEL)
|
||||||
@ -144,6 +251,21 @@ class Gel extends FlxSprite
|
|||||||
Discipline = MAX_LEVEL;
|
Discipline = MAX_LEVEL;
|
||||||
else if (Discipline < MIN_LEVEL)
|
else if (Discipline < MIN_LEVEL)
|
||||||
Discipline = MIN_LEVEL;
|
Discipline = MIN_LEVEL;
|
||||||
|
|
||||||
|
if (Fullness > MAX_LEVEL)
|
||||||
|
Fullness = MAX_LEVEL;
|
||||||
|
else if (Fullness < MIN_LEVEL)
|
||||||
|
Fullness = MIN_LEVEL;
|
||||||
|
|
||||||
|
if (Sleepiness > MAX_LEVEL)
|
||||||
|
Sleepiness = MAX_LEVEL;
|
||||||
|
else if (Sleepiness < MIN_LEVEL)
|
||||||
|
Sleepiness = MIN_LEVEL;
|
||||||
|
|
||||||
|
if (Waste > MAX_LEVEL)
|
||||||
|
Waste = MAX_LEVEL;
|
||||||
|
else if (Waste < MIN_LEVEL)
|
||||||
|
Waste = MIN_LEVEL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,8 +274,6 @@ enum Mood
|
|||||||
NEUTRAL;
|
NEUTRAL;
|
||||||
HAPPY;
|
HAPPY;
|
||||||
ANGRY;
|
ANGRY;
|
||||||
|
|
||||||
WASTING;
|
|
||||||
SLEEPING;
|
SLEEPING;
|
||||||
|
|
||||||
ENCOURAGED;
|
ENCOURAGED;
|
||||||
|
Loading…
Reference in New Issue
Block a user