1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2024-12-23 13:48:23 +00:00

Reimplement rank-based results animations.

This commit is contained in:
EliteMasterEric 2024-05-09 22:37:21 -04:00
parent a243b167b2
commit 5d5cf74020
4 changed files with 240 additions and 97 deletions

View file

@ -23,7 +23,7 @@ Please check out our [Contributor's guide](./CONTRIBUTORS.md) on how you can act
## Programming ## Programming
- [ninjamuffin99](https://twitter.com/ninja_muffin99) - Lead Programmer - [ninjamuffin99](https://twitter.com/ninja_muffin99) - Lead Programmer
- [MasterEric](https://twitter.com/EliteMasterEric) - Programmer - [EliteMasterEric](https://twitter.com/EliteMasterEric) - Programmer
- [MtH](https://twitter.com/emmnyaa) - Charting and Additional Programming - [MtH](https://twitter.com/emmnyaa) - Charting and Additional Programming
- [GeoKureli](https://twitter.com/Geokureli/) - Additional Programming - [GeoKureli](https://twitter.com/Geokureli/) - Additional Programming
- Our contributors on GitHub - Our contributors on GitHub

2
assets

@ -1 +1 @@
Subproject commit fe52d20de7025d90cadb429dbdedf6d986727088 Subproject commit 6115eb6837e97b8b3ad82f3ccd2a49a4383ed35b

View file

@ -26,6 +26,7 @@ import funkin.play.components.TallyCounter;
/** /**
* The state for the results screen after a song or week is finished. * The state for the results screen after a song or week is finished.
*/ */
@:nullSafety
class ResultState extends MusicBeatSubState class ResultState extends MusicBeatSubState
{ {
final params:ResultsStateParams; final params:ResultsStateParams;
@ -42,91 +43,45 @@ class ResultState extends MusicBeatSubState
super(); super();
this.params = params; this.params = params;
resultsVariation = calculateVariation(params);
var fontLetters:String = "AaBbCcDdEeFfGgHhiIJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz:1234567890";
songName = new FlxBitmapText(FlxBitmapFont.fromMonospace(Paths.image("resultScreen/tardlingSpritesheet"), fontLetters, FlxPoint.get(49, 62)));
songName.text = params.title;
songName.letterSpacing = -15;
songName.angle = -4.4;
songName.zIndex = 1000;
difficulty = new FlxSprite(555);
difficulty.zIndex = 1000;
} }
override function create():Void override function create():Void
{ {
/* FunkinSound.playMusic(resultsVariation.getMusicPath(),
if (params.scoreData.sick == params.scoreData.totalNotesHit
&& params.scoreData.maxCombo == params.scoreData.totalNotesHit) resultsVariation = PERFECT;
else if (params.scoreData.missed + params.scoreData.bad + params.scoreData.shit >= params.scoreData.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;
*/
resultsVariation = NORMAL;
FunkinSound.playMusic('results$resultsVariation',
{ {
startingVolume: 1.0, startingVolume: 1.0,
overrideExisting: true, overrideExisting: true,
restartTrack: true, restartTrack: true,
loop: resultsVariation != SHIT loop: resultsVariation.shouldMusicLoop()
}); });
// Reset the camera zoom on the results screen. // Reset the camera zoom on the results screen.
FlxG.camera.zoom = 1.0; FlxG.camera.zoom = 1.0;
// TEMP-ish, just used to sorta "cache" the 3000x3000 image!
var cacheBullShit:FlxSprite = new FlxSprite().loadGraphic(Paths.image("resultScreen/soundSystem"));
add(cacheBullShit);
var dumb:FlxSprite = new FlxSprite().loadGraphic(Paths.image("resultScreen/scorePopin"));
add(dumb);
var bg:FlxSprite = FlxGradient.createGradientFlxSprite(FlxG.width, FlxG.height, [0xFFFECC5C, 0xFFFDC05C], 90); var bg:FlxSprite = FlxGradient.createGradientFlxSprite(FlxG.width, FlxG.height, [0xFFFECC5C, 0xFFFDC05C], 90);
bg.scrollFactor.set(); bg.scrollFactor.set();
bg.zIndex = 10;
add(bg); add(bg);
var bgFlash:FlxSprite = FlxGradient.createGradientFlxSprite(FlxG.width, FlxG.height, [0xFFFFEB69, 0xFFFFE66A], 90); var bgFlash:FlxSprite = FlxGradient.createGradientFlxSprite(FlxG.width, FlxG.height, [0xFFFFEB69, 0xFFFFE66A], 90);
bgFlash.scrollFactor.set(); bgFlash.scrollFactor.set();
bgFlash.visible = false; bgFlash.visible = false;
bg.zIndex = 20;
add(bgFlash); add(bgFlash);
// var bfGfExcellent:FlxAtlasSprite = new FlxAtlasSprite(380, -170, Paths.animateAtlas("resultScreen/resultsBoyfriendExcellent", "shared")); // The sound system which falls into place behind the score text. Plays every time!
// bfGfExcellent.visible = false;
// add(bfGfExcellent);
//
// var bfPerfect:FlxAtlasSprite = new FlxAtlasSprite(370, -180, Paths.animateAtlas("resultScreen/resultsBoyfriendPerfect", "shared"));
// bfPerfect.visible = false;
// add(bfPerfect);
//
// var bfSHIT:FlxAtlasSprite = new FlxAtlasSprite(0, 20, Paths.animateAtlas("resultScreen/resultsBoyfriendSHIT", "shared"));
// bfSHIT.visible = false;
// add(bfSHIT);
//
// bfGfExcellent.anim.onComplete = () -> {
// bfGfExcellent.anim.curFrame = 28;
// bfGfExcellent.anim.play(); // unpauses this anim, since it's on PlayOnce!
// };
//
// bfPerfect.anim.onComplete = () -> {
// bfPerfect.anim.curFrame = 136;
// bfPerfect.anim.play(); // unpauses this anim, since it's on PlayOnce!
// };
//
// bfSHIT.anim.onComplete = () -> {
// bfSHIT.anim.curFrame = 150;
// bfSHIT.anim.play(); // unpauses this anim, since it's on PlayOnce!
// };
var gf:FlxSprite = FunkinSprite.createSparrow(625, 325, '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 = FunkinSprite.createSparrow(640, -200, 'resultScreen/resultBoyfriendGOOD');
boyfriend.animation.addByPrefix("fall", "Boyfriend Good Anim0", 24, false);
boyfriend.visible = false;
boyfriend.animation.finishCallback = function(_) {
boyfriend.animation.play('fall', true, false, 14);
};
add(boyfriend);
var soundSystem:FlxSprite = FunkinSprite.createSparrow(-15, -180, 'resultScreen/soundSystem'); var soundSystem:FlxSprite = FunkinSprite.createSparrow(-15, -180, 'resultScreen/soundSystem');
soundSystem.animation.addByPrefix("idle", "sound system", 24, false); soundSystem.animation.addByPrefix("idle", "sound system", 24, false);
soundSystem.visible = false; soundSystem.visible = false;
@ -134,9 +89,66 @@ class ResultState extends MusicBeatSubState
soundSystem.animation.play("idle"); soundSystem.animation.play("idle");
soundSystem.visible = true; soundSystem.visible = true;
}); });
soundSystem.zIndex = 1100;
add(soundSystem); add(soundSystem);
difficulty = new FlxSprite(555); var bfPerfect:Null<FlxAtlasSprite> = null;
var bfExcellent:Null<FlxAtlasSprite> = null;
var bfGood:Null<FlxSprite> = null;
var gfGood:Null<FlxSprite> = null;
var bfShit:Null<FlxAtlasSprite> = null;
switch (resultsVariation)
{
case PERFECT | PERFECT_GOLD | PERFECT_PLATINUM:
bfPerfect = new FlxAtlasSprite(370, -180, Paths.animateAtlas("resultScreen/results-bf/resultsPERFECT", "shared"));
bfPerfect.visible = false;
bfPerfect.zIndex = 500;
add(bfPerfect);
bfPerfect.anim.onComplete = () -> {
bfPerfect.anim.curFrame = 136;
bfPerfect.anim.play(); // unpauses this anim, since it's on PlayOnce!
};
case EXCELLENT:
bfExcellent = new FlxAtlasSprite(380, -170, Paths.animateAtlas("resultScreen/results-bf/resultsEXCELLENT", "shared"));
bfExcellent.visible = false;
bfExcellent.zIndex = 500;
add(bfExcellent);
bfExcellent.onAnimationFinish.add((animName) -> {
bfExcellent.playAnimation('Loop Start');
});
case GOOD | GREAT:
gfGood = FunkinSprite.createSparrow(625, 325, 'resultScreen/results-bf/resultsGOOD/resultGirlfriendGOOD');
gfGood.animation.addByPrefix("clap", "Girlfriend Good Anim", 24, false);
gfGood.visible = false;
gfGood.zIndex = 500;
gfGood.animation.finishCallback = _ -> {
gfGood.animation.play('clap', true, false, 9);
};
add(gfGood);
bfGood = FunkinSprite.createSparrow(640, -200, 'resultScreen/results-bf/resultsGOOD/resultBoyfriendGOOD');
bfGood.animation.addByPrefix("fall", "Boyfriend Good Anim0", 24, false);
bfGood.visible = false;
bfGood.zIndex = 501;
bfGood.animation.finishCallback = function(_) {
bfGood.animation.play('fall', true, false, 14);
};
add(bfGood);
case SHIT:
bfShit = new FlxAtlasSprite(0, 20, Paths.animateAtlas("resultScreen/results-bf/resultsSHIT", "shared"));
bfShit.visible = false;
bfShit.zIndex = 500;
add(bfShit);
bfShit.onAnimationFinish.add((animName) -> {
bfShit.playAnimation('Loop Start');
});
}
var diffSpr:String = switch (PlayState.instance.currentDifficulty) var diffSpr:String = switch (PlayState.instance.currentDifficulty)
{ {
@ -157,11 +169,6 @@ class ResultState extends MusicBeatSubState
difficulty.loadGraphic(Paths.image("resultScreen/" + diffSpr)); difficulty.loadGraphic(Paths.image("resultScreen/" + diffSpr));
add(difficulty); add(difficulty);
var fontLetters:String = "AaBbCcDdEeFfGgHhiIJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz:1234567890";
songName = new FlxBitmapText(FlxBitmapFont.fromMonospace(Paths.image("resultScreen/tardlingSpritesheet"), fontLetters, FlxPoint.get(49, 62)));
songName.text = params.title;
songName.letterSpacing = -15;
songName.angle = -4.4;
add(songName); add(songName);
var angleRad = songName.angle * Math.PI / 180; var angleRad = songName.angle * Math.PI / 180;
@ -179,21 +186,25 @@ class ResultState extends MusicBeatSubState
var blackTopBar:FlxSprite = new FlxSprite().loadGraphic(Paths.image("resultScreen/topBarBlack")); var blackTopBar:FlxSprite = new FlxSprite().loadGraphic(Paths.image("resultScreen/topBarBlack"));
blackTopBar.y = -blackTopBar.height; blackTopBar.y = -blackTopBar.height;
FlxTween.tween(blackTopBar, {y: 0}, 0.4, {ease: FlxEase.quartOut, startDelay: 0.5}); FlxTween.tween(blackTopBar, {y: 0}, 0.4, {ease: FlxEase.quartOut, startDelay: 0.5});
blackTopBar.zIndex = 1010;
add(blackTopBar); add(blackTopBar);
var resultsAnim:FunkinSprite = FunkinSprite.createSparrow(-200, -10, "resultScreen/results"); var resultsAnim:FunkinSprite = FunkinSprite.createSparrow(-200, -10, "resultScreen/results");
resultsAnim.animation.addByPrefix("result", "results instance 1", 24, false); resultsAnim.animation.addByPrefix("result", "results instance 1", 24, false);
resultsAnim.animation.play("result"); resultsAnim.animation.play("result");
resultsAnim.zIndex = 1200;
add(resultsAnim); add(resultsAnim);
var ratingsPopin:FunkinSprite = FunkinSprite.createSparrow(-150, 120, "resultScreen/ratingsPopin"); var ratingsPopin:FunkinSprite = FunkinSprite.createSparrow(-150, 120, "resultScreen/ratingsPopin");
ratingsPopin.animation.addByPrefix("idle", "Categories", 24, false); ratingsPopin.animation.addByPrefix("idle", "Categories", 24, false);
ratingsPopin.visible = false; ratingsPopin.visible = false;
ratingsPopin.zIndex = 1200;
add(ratingsPopin); add(ratingsPopin);
var scorePopin:FunkinSprite = FunkinSprite.createSparrow(-180, 520, "resultScreen/scorePopin"); var scorePopin:FunkinSprite = FunkinSprite.createSparrow(-180, 520, "resultScreen/scorePopin");
scorePopin.animation.addByPrefix("score", "tally score", 24, false); scorePopin.animation.addByPrefix("score", "tally score", 24, false);
scorePopin.visible = false; scorePopin.visible = false;
scorePopin.zIndex = 1200;
add(scorePopin); add(scorePopin);
var highscoreNew:FlxSprite = new FlxSprite(310, 570); var highscoreNew:FlxSprite = new FlxSprite(310, 570);
@ -202,11 +213,13 @@ class ResultState extends MusicBeatSubState
highscoreNew.visible = false; highscoreNew.visible = false;
highscoreNew.setGraphicSize(Std.int(highscoreNew.width * 0.8)); highscoreNew.setGraphicSize(Std.int(highscoreNew.width * 0.8));
highscoreNew.updateHitbox(); highscoreNew.updateHitbox();
highscoreNew.zIndex = 1200;
add(highscoreNew); add(highscoreNew);
var hStuf:Int = 50; var hStuf:Int = 50;
var ratingGrp:FlxTypedGroup<TallyCounter> = new FlxTypedGroup<TallyCounter>(); var ratingGrp:FlxTypedGroup<TallyCounter> = new FlxTypedGroup<TallyCounter>();
ratingGrp.zIndex = 1200;
add(ratingGrp); add(ratingGrp);
/** /**
@ -238,6 +251,7 @@ class ResultState extends MusicBeatSubState
var score:ResultScore = new ResultScore(35, 305, 10, params.scoreData.score); var score:ResultScore = new ResultScore(35, 305, 10, params.scoreData.score);
score.visible = false; score.visible = false;
score.zIndex = 1200;
add(score); add(score);
for (ind => rating in ratingGrp.members) for (ind => rating in ratingGrp.members)
@ -275,13 +289,48 @@ class ResultState extends MusicBeatSubState
switch (resultsVariation) switch (resultsVariation)
{ {
// case SHIT: case PERFECT | PERFECT_GOLD | PERFECT_PLATINUM:
// bfSHIT.visible = true; if (bfPerfect == null)
// bfSHIT.playAnimation(""); {
trace("Could not build PERFECT animation!");
}
else
{
bfPerfect.visible = true;
bfPerfect.playAnimation('');
}
case NORMAL: case EXCELLENT:
boyfriend.animation.play('fall'); if (bfExcellent == null)
boyfriend.visible = true; {
trace("Could not build EXCELLENT animation!");
}
else
{
bfExcellent.visible = true;
bfExcellent.playAnimation('Intro');
}
case SHIT:
if (bfShit == null)
{
trace("Could not build SHIT animation!");
}
else
{
bfShit.visible = true;
bfShit.playAnimation('Intro');
}
case GREAT | GOOD:
if (bfGood == null || gfGood == null)
{
trace("Could not build GOOD animation!");
}
else
{
bfGood.animation.play('fall');
bfGood.visible = true;
new FlxTimer().start((1 / 24) * 12, _ -> { new FlxTimer().start((1 / 24) * 12, _ -> {
bgFlash.visible = true; bgFlash.visible = true;
@ -296,19 +345,16 @@ class ResultState extends MusicBeatSubState
new FlxTimer().start((1 / 24) * 22, _ -> { new FlxTimer().start((1 / 24) * 22, _ -> {
// plays about 22 frames (at 24fps timing) after bf spawns in // plays about 22 frames (at 24fps timing) after bf spawns in
gf.animation.play('clap', true); gfGood.animation.play('clap', true);
gf.visible = true; gfGood.visible = true;
}); });
// case PERFECT: }
// bfPerfect.visible = true;
// bfPerfect.playAnimation("");
// bfGfExcellent.visible = true;
// bfGfExcellent.playAnimation("");
default: default:
} }
}); });
refresh();
super.create(); super.create();
} }
@ -401,14 +447,100 @@ class ResultState extends MusicBeatSubState
super.update(elapsed); super.update(elapsed);
} }
public static function calculateVariation(params:ResultsStateParams):ResultVariations
{
// Perfect (Platinum) is a Sick Full Clear
var isPerfectPlat = (params.scoreData.tallies.sick + params.scoreData.tallies.good) == params.scoreData.tallies.totalNotes
&& params.scoreData.tallies.sick / params.scoreData.tallies.totalNotes >= Constants.RANK_PERFECT_PLAT_THRESHOLD;
if (isPerfectPlat) return ResultVariations.PERFECT_PLATINUM;
// Perfect (Gold) is an 85% Sick Full Clear
var isPerfectGold = (params.scoreData.tallies.sick + params.scoreData.tallies.good) == params.scoreData.tallies.totalNotes
&& params.scoreData.tallies.sick / params.scoreData.tallies.totalNotes >= Constants.RANK_PERFECT_GOLD_THRESHOLD;
if (isPerfectGold) return ResultVariations.PERFECT_GOLD;
// Else, use the standard grades
// Clear % (including bad and shit). 1.00 is a full clear but not a full combo
var clear = (params.scoreData.tallies.totalNotesHit) / params.scoreData.tallies.totalNotes;
if (clear == Constants.RANK_PERFECT_THRESHOLD)
{
return ResultVariations.PERFECT;
}
else if (clear >= Constants.RANK_EXCELLENT_THRESHOLD)
{
return ResultVariations.EXCELLENT;
}
else if (clear >= Constants.RANK_GREAT_THRESHOLD)
{
return ResultVariations.GREAT;
}
else if (clear >= Constants.RANK_GOOD_THRESHOLD)
{
return ResultVariations.GOOD;
}
else
{
return ResultVariations.SHIT;
}
}
} }
enum abstract ResultVariations(String) enum abstract ResultVariations(String)
{ {
var PERFECT_PLATINUM;
var PERFECT_GOLD;
var PERFECT; var PERFECT;
var EXCELLENT; var EXCELLENT;
var NORMAL; var GREAT;
var GOOD;
var SHIT; var SHIT;
public function getMusicPath():String
{
switch (abstract)
{
case PERFECT_PLATINUM:
return 'resultsPERFECT';
case PERFECT_GOLD:
return 'resultsPERFECT';
case PERFECT:
return 'resultsPERFECT';
case EXCELLENT:
return 'resultsNORMAL';
case GREAT:
return 'resultsNORMAL';
case GOOD:
return 'resultsNORMAL';
case SHIT:
return 'resultsSHIT';
}
}
public function shouldMusicLoop():Bool
{
switch (abstract)
{
case PERFECT_PLATINUM:
return true;
case PERFECT_GOLD:
return true;
case PERFECT:
return true;
case EXCELLENT:
return true;
case GREAT:
return true;
case GOOD:
return true;
case SHIT:
return false;
default:
return false;
}
}
} }
typedef ResultsStateParams = typedef ResultsStateParams =

View file

@ -455,6 +455,17 @@ class Constants
public static final JUDGEMENT_BAD_COMBO_BREAK:Bool = true; public static final JUDGEMENT_BAD_COMBO_BREAK:Bool = true;
public static final JUDGEMENT_SHIT_COMBO_BREAK:Bool = true; public static final JUDGEMENT_SHIT_COMBO_BREAK:Bool = true;
// % Sick
public static final RANK_PERFECT_PLAT_THRESHOLD:Float = 1.0; // % Sick
public static final RANK_PERFECT_GOLD_THRESHOLD:Float = 0.85; // % Sick
// % Hit
public static final RANK_PERFECT_THRESHOLD:Float = 1.00;
public static final RANK_EXCELLENT_THRESHOLD:Float = 0.90;
public static final RANK_GREAT_THRESHOLD:Float = 0.75;
public static final RANK_GOOD_THRESHOLD:Float = 0.60;
// public static final RANK_SHIT_THRESHOLD:Float = 0.00;
/** /**
* FILE EXTENSIONS * FILE EXTENSIONS
*/ */