1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2024-11-10 00:34:40 +00:00
Funkin/source/funkin/play/ResultState.hx

202 lines
6.2 KiB
Haxe
Raw Normal View History

package funkin.play;
2022-09-22 01:03:31 +00:00
import flixel.FlxBasic;
import flixel.FlxSprite;
import flixel.graphics.frames.FlxAtlasFrames;
2022-09-22 20:21:31 +00:00
import flixel.group.FlxGroup.FlxTypedGroup;
import flixel.text.FlxText;
import flixel.tweens.FlxEase;
import flixel.tweens.FlxTween;
import flixel.util.FlxColor;
import flixel.util.FlxGradient;
import flixel.util.FlxTimer;
2022-09-22 08:09:06 +00:00
import funkin.ui.TallyCounter;
class ResultState extends MusicBeatSubstate
{
2022-09-20 17:18:40 +00:00
var resultsVariation:ResultVariations;
override function create()
{
2022-09-20 17:18:40 +00:00
if (Highscore.tallies.sick == Highscore.tallies.totalNotes && Highscore.tallies.maxCombo == Highscore.tallies.totalNotes)
resultsVariation = PERFECT;
else if (Highscore.tallies.missed + Highscore.tallies.bad + Highscore.tallies.shit >= Highscore.tallies.totalNotes * 0.50)
resultsVariation = SHIT; // if more than half of your song was missed, bad, or shit notes, you get shit ending!
else
resultsVariation = NORMAL;
FlxG.sound.playMusic(Paths.music("results" + resultsVariation));
2022-09-20 17:01:37 +00:00
2022-09-22 00:26:16 +00:00
// TEMP-ish, just used to sorta "cache" the 3000x3000 image!
var cacheBullShit = new FlxSprite().loadGraphic(Paths.image("resultScreen/soundSystem"));
add(cacheBullShit);
2022-09-23 19:42:12 +00:00
var dumb = new FlxSprite().loadGraphic(Paths.image("resultScreen/scorePopin"));
add(dumb);
var bg:FlxSprite = FlxGradient.createGradientFlxSprite(FlxG.width, FlxG.height, [0xFFFECC5C, 0xFFFDC05C], 90);
bg.scrollFactor.set();
add(bg);
2022-09-23 18:26:50 +00:00
var gf:FlxSprite = new FlxSprite(500, 300);
gf.frames = Paths.getSparrowAtlas('resultScreen/resultGirlfriendGOOD');
gf.animation.addByPrefix("clap", "Girlfriend Good Anim", 24, false);
gf.visible = false;
gf.animation.finishCallback = _ ->
{
gf.animation.play('clap', true, false, 9);
};
add(gf);
var boyfriend:FlxSprite = new FlxSprite(640, -200);
boyfriend.frames = Paths.getSparrowAtlas('resultScreen/resultBoyfriendGOOD');
boyfriend.animation.addByPrefix("fall", "Boyfriend Good", 24, false);
boyfriend.visible = false;
boyfriend.animation.finishCallback = function(_)
{
boyfriend.animation.play('fall', true, false, 14);
};
add(boyfriend);
2022-09-22 00:26:16 +00:00
var soundSystem:FlxSprite = new FlxSprite(-15, -180);
soundSystem.frames = Paths.getSparrowAtlas("resultScreen/soundSystem");
soundSystem.animation.addByPrefix("idle", "sound system", 24, false);
soundSystem.visible = false;
new FlxTimer().start(0.4, _ ->
{
soundSystem.animation.play("idle");
soundSystem.visible = true;
});
2022-09-22 08:09:06 +00:00
soundSystem.antialiasing = true;
2022-09-22 00:26:16 +00:00
add(soundSystem);
2022-09-22 01:03:31 +00:00
var difficulty:FlxSprite = new FlxSprite(680);
var diffSpr:String = switch (CoolUtil.difficultyString())
{
case "EASY":
"difEasy";
case "NORMAL":
"difNormal";
case "HARD":
"difHard";
case _:
"difNormal";
}
difficulty.loadGraphic(Paths.image("resultScreen/" + diffSpr));
difficulty.y = -difficulty.height;
FlxTween.tween(difficulty, {y: 110}, 0.5, {ease: FlxEase.quartOut, startDelay: 0.8});
2022-09-22 08:09:06 +00:00
difficulty.antialiasing = true;
2022-09-22 01:03:31 +00:00
add(difficulty);
var blackTopBar:FlxSprite = new FlxSprite().loadGraphic(Paths.image("resultScreen/topBarBlack"));
blackTopBar.y = -blackTopBar.height;
FlxTween.tween(blackTopBar, {y: 0}, 0.4, {ease: FlxEase.quartOut, startDelay: 0.5});
2022-09-22 08:09:06 +00:00
blackTopBar.antialiasing = true;
add(blackTopBar);
2022-09-22 08:09:06 +00:00
var resultsAnim:FlxSprite = new FlxSprite(-200, -10);
resultsAnim.frames = Paths.getSparrowAtlas("resultScreen/results");
resultsAnim.animation.addByPrefix("result", "results", 24, false);
resultsAnim.animation.play("result");
2022-09-22 08:09:06 +00:00
resultsAnim.antialiasing = true;
add(resultsAnim);
2022-09-22 00:26:16 +00:00
var ratingsPopin:FlxSprite = new FlxSprite(-150, 120);
ratingsPopin.frames = Paths.getSparrowAtlas("resultScreen/ratingsPopin");
ratingsPopin.animation.addByPrefix("idle", "Categories", 24, false);
// ratingsPopin.animation.play("idle");
ratingsPopin.visible = false;
2022-09-22 08:09:06 +00:00
ratingsPopin.antialiasing = true;
add(ratingsPopin);
2022-09-23 19:42:12 +00:00
var scorePopin:FlxSprite = new FlxSprite(-180, 520);
scorePopin.frames = Paths.getSparrowAtlas("resultScreen/scorePopin");
scorePopin.animation.addByPrefix("score", "tally score", 24, false);
scorePopin.visible = false;
add(scorePopin);
2022-09-22 08:09:06 +00:00
var hStuf:Int = 50;
2022-09-22 20:21:31 +00:00
var ratingGrp:FlxTypedGroup<TallyCounter> = new FlxTypedGroup<TallyCounter>();
add(ratingGrp);
2022-09-22 08:09:06 +00:00
var totalHit:TallyCounter = new TallyCounter(375, hStuf * 3, Highscore.tallies.totalNotes);
2022-09-22 20:21:31 +00:00
ratingGrp.add(totalHit);
2022-09-22 08:09:06 +00:00
var maxCombo:TallyCounter = new TallyCounter(375, hStuf * 4, Highscore.tallies.maxCombo);
2022-09-22 20:21:31 +00:00
ratingGrp.add(maxCombo);
2022-09-22 08:09:06 +00:00
2022-09-22 19:48:27 +00:00
hStuf += 2;
var extraYOffset:Float = 5;
var tallySick:TallyCounter = new TallyCounter(230, (hStuf * 5) + extraYOffset, Highscore.tallies.sick, 0xFF89E59E);
2022-09-22 20:21:31 +00:00
ratingGrp.add(tallySick);
2022-09-22 08:09:06 +00:00
2022-09-22 19:48:27 +00:00
var tallyGood:TallyCounter = new TallyCounter(210, (hStuf * 6) + extraYOffset, Highscore.tallies.good, 0xFF89C9E5);
2022-09-22 20:21:31 +00:00
ratingGrp.add(tallyGood);
2022-09-22 08:09:06 +00:00
2022-09-22 19:48:27 +00:00
var tallyBad:TallyCounter = new TallyCounter(190, (hStuf * 7) + extraYOffset, Highscore.tallies.bad, 0xffE6CF8A);
2022-09-22 20:21:31 +00:00
ratingGrp.add(tallyBad);
2022-09-22 08:09:06 +00:00
2022-09-22 19:48:27 +00:00
var tallyShit:TallyCounter = new TallyCounter(220, (hStuf * 8) + extraYOffset, Highscore.tallies.shit, 0xFFE68C8A);
2022-09-22 20:21:31 +00:00
ratingGrp.add(tallyShit);
2022-09-22 08:09:06 +00:00
2022-09-22 19:48:27 +00:00
var tallyMissed:TallyCounter = new TallyCounter(260, (hStuf * 9) + extraYOffset, Highscore.tallies.missed, 0xFFC68AE6);
2022-09-22 20:21:31 +00:00
ratingGrp.add(tallyMissed);
for (ind => rating in ratingGrp.members)
{
rating.visible = false;
new FlxTimer().start((0.3 * ind) + 0.55, _ ->
{
rating.visible = true;
FlxTween.tween(rating, {curNumber: rating.neededNumber}, 0.5, {ease: FlxEase.quartOut});
});
}
2022-09-22 08:09:06 +00:00
new FlxTimer().start(0.5, _ ->
{
ratingsPopin.animation.play("idle");
ratingsPopin.visible = true;
2022-09-23 18:26:50 +00:00
2022-09-23 19:42:12 +00:00
ratingsPopin.animation.finishCallback = anim ->
{
scorePopin.animation.play("score");
scorePopin.visible = true;
};
2022-09-23 18:26:50 +00:00
boyfriend.animation.play('fall');
boyfriend.visible = true;
new FlxTimer().start((1 / 24) * 22, _ ->
{
// plays about 22 frames (at 24fps timing) after bf spawns in
gf.animation.play('clap', true);
gf.visible = true;
});
});
2022-09-23 20:12:18 +00:00
if (Highscore.tallies.isNewHighscore)
trace("ITS A NEW HIGHSCORE!!!");
super.create();
}
override function update(elapsed:Float)
{
if (controls.PAUSE)
FlxG.switchState(new FreeplayState());
super.update(elapsed);
}
}
2022-09-20 17:18:40 +00:00
enum abstract ResultVariations(String)
{
var PERFECT;
var NORMAL;
var SHIT;
}