1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2024-11-15 11:22:55 +00:00

Merge branch 'results-scrolling' into anim-rename-fixins

This commit is contained in:
Cameron Taylor 2024-06-03 18:11:45 -04:00
commit 8c4709c25e
3 changed files with 369 additions and 61 deletions

View file

@ -2,11 +2,16 @@ package funkin.play;
import flixel.FlxSprite;
import flixel.group.FlxSpriteGroup.FlxTypedSpriteGroup;
import flixel.tweens.FlxTween;
import flixel.util.FlxTimer;
import flixel.tweens.FlxEase;
class ResultScore extends FlxTypedSpriteGroup<ScoreNum>
{
public var scoreShit(default, set):Int = 0;
public var scoreStart:Int = 0;
function set_scoreShit(val):Int
{
if (group == null || group.members == null) return val;
@ -16,7 +21,8 @@ class ResultScore extends FlxTypedSpriteGroup<ScoreNum>
while (dumbNumb > 0)
{
group.members[loopNum].digit = dumbNumb % 10;
scoreStart += 1;
group.members[loopNum].finalDigit = dumbNumb % 10;
// var funnyNum = group.members[loopNum];
// prevNum = group.members[loopNum + 1];
@ -44,9 +50,15 @@ class ResultScore extends FlxTypedSpriteGroup<ScoreNum>
public function animateNumbers():Void
{
for (i in group.members)
for (i in group.members.length-scoreStart...group.members.length)
{
i.playAnim();
// if(i.finalDigit == 10) continue;
new FlxTimer().start((i-1)/24, _ -> {
group.members[i].finalDelay = scoreStart - (i-1);
group.members[i].playAnim();
group.members[i].shuffle();
});
}
}
@ -71,12 +83,26 @@ class ResultScore extends FlxTypedSpriteGroup<ScoreNum>
class ScoreNum extends FlxSprite
{
public var digit(default, set):Int = 10;
public var finalDigit(default, set):Int = 10;
public var glow:Bool = true;
function set_finalDigit(val):Int
{
animation.play('GONE', true, false, 0);
return finalDigit = val;
}
function set_digit(val):Int
{
if (val >= 0 && animation.curAnim != null && animation.curAnim.name != numToString[val])
{
animation.play(numToString[val], true, false, 0);
if(glow){
animation.play(numToString[val], true, false, 0);
glow = false;
}else{
animation.play(numToString[val], true, false, 4);
}
updateHitbox();
switch (val)
@ -107,6 +133,10 @@ class ScoreNum extends FlxSprite
animation.play(numToString[digit], true, false, 0);
}
public var shuffleTimer:FlxTimer;
public var finalTween:FlxTween;
public var finalDelay:Float = 0;
public var baseY:Float = 0;
public var baseX:Float = 0;
@ -114,6 +144,47 @@ class ScoreNum extends FlxSprite
"ZERO", "ONE", "TWO", "THREE", "FOUR", "FIVE", "SIX", "SEVEN", "EIGHT", "NINE", "DISABLED"
];
function finishShuffleTween():Void{
var tweenFunction = function(x) {
var digitRounded = Math.floor(x);
//if(digitRounded == finalDigit) glow = true;
digit = digitRounded;
};
finalTween = FlxTween.num(0.0, finalDigit, 23/24, {
ease: FlxEase.quadOut,
onComplete: function (input) {
new FlxTimer().start((finalDelay)/24, _ -> {
animation.play(animation.curAnim.name, true, false, 0);
});
// fuck
}
}, tweenFunction);
}
function shuffleProgress(shuffleTimer:FlxTimer):Void
{
var tempDigit:Int = digit;
tempDigit += 1;
if(tempDigit > 9) tempDigit = 0;
if(tempDigit < 0) tempDigit = 0;
digit = tempDigit;
if (shuffleTimer.loops > 0 && shuffleTimer.loopsLeft == 0)
{
//digit = finalDigit;
finishShuffleTween();
}
}
public function shuffle():Void{
var duration:Float = 41/24;
var interval:Float = 1/24;
shuffleTimer = new FlxTimer().start(interval, shuffleProgress, Std.int(duration / interval));
}
public function new(x:Float, y:Float)
{
super(x, y);
@ -130,6 +201,7 @@ class ScoreNum extends FlxSprite
}
animation.addByPrefix('DISABLED', 'DISABLED', 24, false);
animation.addByPrefix('GONE', 'GONE', 24, false);
this.digit = 10;

View file

@ -5,6 +5,7 @@ import funkin.ui.story.StoryMenuState;
import funkin.graphics.adobeanimate.FlxAtlasSprite;
import flixel.FlxSprite;
import funkin.graphics.FunkinSprite;
import flixel.effects.FlxFlicker;
import flixel.graphics.frames.FlxBitmapFont;
import flixel.group.FlxGroup.FlxTypedGroup;
import flixel.math.FlxPoint;
@ -55,8 +56,10 @@ class ResultState extends MusicBeatSubState
final score:ResultScore;
var bfPerfect:Null<FlxAtlasSprite> = null;
var heartsPerfect:Null<FlxAtlasSprite> = null;
var bfExcellent:Null<FlxAtlasSprite> = null;
var bfGreat:Null<FlxAtlasSprite> = null;
var gfGreat:Null<FlxAtlasSprite> = null;
var bfGood:Null<FlxSprite> = null;
var gfGood:Null<FlxSprite> = null;
var bfShit:Null<FlxAtlasSprite> = null;
@ -95,15 +98,15 @@ class ResultState extends MusicBeatSubState
clearPercentSmall.zIndex = 1000;
clearPercentSmall.visible = false;
bgFlash = FlxGradient.createGradientFlxSprite(FlxG.width, FlxG.height, [0xFFFFEB69, 0xFFFFE66A], 90);
bgFlash = FlxGradient.createGradientFlxSprite(FlxG.width, FlxG.height, [0xFFFFF1A6, 0xFFFFF1BE], 90);
resultsAnim = FunkinSprite.createSparrow(-200, -10, "resultScreen/results");
ratingsPopin = FunkinSprite.createSparrow(-150, 120, "resultScreen/ratingsPopin");
ratingsPopin = FunkinSprite.createSparrow(-135, 135, "resultScreen/ratingsPopin");
scorePopin = FunkinSprite.createSparrow(-180, 520, "resultScreen/scorePopin");
scorePopin = FunkinSprite.createSparrow(-180, 515, "resultScreen/scorePopin");
highscoreNew = new FlxSprite(310, 570);
highscoreNew = new FlxSprite(44, 557);
score = new ResultScore(35, 305, 10, params.scoreData.score);
@ -140,14 +143,14 @@ class ResultState extends MusicBeatSubState
bgFlash.scrollFactor.set();
bgFlash.visible = false;
bgFlash.zIndex = 20;
bgFlash.cameras = [cameraBG];
//bgFlash.cameras = [cameraBG];
add(bgFlash);
// The sound system which falls into place behind the score text. Plays every time!
var soundSystem:FlxSprite = FunkinSprite.createSparrow(-15, -180, 'resultScreen/soundSystem');
soundSystem.animation.addByPrefix("idle", "sound system", 24, false);
soundSystem.visible = false;
new FlxTimer().start(0.3, _ -> {
new FlxTimer().start(8/24, _ -> {
soundSystem.animation.play("idle");
soundSystem.visible = true;
});
@ -157,7 +160,22 @@ class ResultState extends MusicBeatSubState
switch (rank)
{
case PERFECT | PERFECT_GOLD:
bfPerfect = new FlxAtlasSprite(370, -180, Paths.animateAtlas("resultScreen/results-bf/resultsPERFECT", "shared"));
heartsPerfect = new FlxAtlasSprite(1342, 370, Paths.animateAtlas("resultScreen/results-bf/resultsPERFECT/hearts", "shared"));
heartsPerfect.visible = false;
heartsPerfect.zIndex = 501;
add(heartsPerfect);
heartsPerfect.anim.onComplete = () -> {
if (heartsPerfect != null)
{
//bfPerfect.anim.curFrame = 137;
heartsPerfect.anim.curFrame = 43;
heartsPerfect.anim.play(); // unpauses this anim, since it's on PlayOnce!
}
};
bfPerfect = new FlxAtlasSprite(1342, 370, Paths.animateAtlas("resultScreen/results-bf/resultsPERFECT", "shared"));
bfPerfect.visible = false;
bfPerfect.zIndex = 500;
add(bfPerfect);
@ -165,36 +183,57 @@ class ResultState extends MusicBeatSubState
bfPerfect.anim.onComplete = () -> {
if (bfPerfect != null)
{
//bfPerfect.anim.curFrame = 137;
bfPerfect.anim.curFrame = 137;
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 = new FlxAtlasSprite(1329, 429, Paths.animateAtlas("resultScreen/results-bf/resultsEXCELLENT", "shared"));
bfExcellent.visible = false;
bfExcellent.zIndex = 500;
add(bfExcellent);
bfExcellent.onAnimationFinish.add((animName) -> {
bfExcellent.anim.onComplete = () -> {
if (bfExcellent != null)
{
bfExcellent.playAnimation('Loop Start');
bfExcellent.anim.curFrame = 28;
bfExcellent.anim.play(); // unpauses this anim, since it's on PlayOnce!
}
});
};
case GREAT:
bfGreat = new FlxAtlasSprite(640, 200, Paths.animateAtlas("resultScreen/results-bf/resultsGREAT", "shared"));
gfGreat = new FlxAtlasSprite(802, 331, Paths.animateAtlas("resultScreen/results-bf/resultsGREAT/gf", "shared"));
gfGreat.visible = false;
gfGreat.zIndex = 499;
add(gfGreat);
gfGreat.scale.set(0.93, 0.93);
gfGreat.anim.onComplete = () -> {
if (gfGreat != null)
{
gfGreat.anim.curFrame = 9;
gfGreat.anim.play(); // unpauses this anim, since it's on PlayOnce!
}
};
bfGreat = new FlxAtlasSprite(929, 363, Paths.animateAtlas("resultScreen/results-bf/resultsGREAT/bf", "shared"));
bfGreat.visible = false;
bfGreat.zIndex = 500;
add(bfGreat);
bfGreat.onAnimationFinish.add((animName) -> {
bfGreat.scale.set(0.93, 0.93);
bfGreat.anim.onComplete = () -> {
if (bfGreat != null)
{
bfGreat.playAnimation('Loop Start');
bfGreat.anim.curFrame = 15;
bfGreat.anim.play(); // unpauses this anim, since it's on PlayOnce!
}
});
};
case GOOD:
gfGood = FunkinSprite.createSparrow(625, 325, 'resultScreen/results-bf/resultsGOOD/resultGirlfriendGOOD');
@ -254,7 +293,7 @@ class ResultState extends MusicBeatSubState
var blackTopBar:FlxSprite = new FlxSprite().loadGraphic(Paths.image("resultScreen/topBarBlack"));
blackTopBar.y = -blackTopBar.height;
FlxTween.tween(blackTopBar, {y: 0}, 0.4, {ease: FlxEase.quartOut});
FlxTween.tween(blackTopBar, {y: 0}, 7/24, {ease: FlxEase.quartOut, startDelay: 3/24});
blackTopBar.zIndex = 1010;
add(blackTopBar);
@ -262,7 +301,7 @@ class ResultState extends MusicBeatSubState
resultsAnim.visible = false;
resultsAnim.zIndex = 1200;
add(resultsAnim);
new FlxTimer().start(0.3, _ -> {
new FlxTimer().start(6/24, _ -> {
resultsAnim.visible = true;
resultsAnim.animation.play("result");
});
@ -271,7 +310,7 @@ class ResultState extends MusicBeatSubState
ratingsPopin.visible = false;
ratingsPopin.zIndex = 1200;
add(ratingsPopin);
new FlxTimer().start(1.0, _ -> {
new FlxTimer().start(21/24, _ -> {
ratingsPopin.visible = true;
ratingsPopin.animation.play("idle");
});
@ -280,23 +319,49 @@ class ResultState extends MusicBeatSubState
scorePopin.visible = false;
scorePopin.zIndex = 1200;
add(scorePopin);
new FlxTimer().start(1.0, _ -> {
new FlxTimer().start(36/24, _ -> {
scorePopin.visible = true;
scorePopin.animation.play("score");
scorePopin.animation.finishCallback = anim -> {
score.visible = true;
score.animateNumbers();
};
});
new FlxTimer().start(37/24, _ -> {
score.visible = true;
score.animateNumbers();
startRankTallySequence();
});
new FlxTimer().start(rank.getBFDelay(), _ -> {
afterRankTallySequence();
});
new FlxTimer().start(rank.getFlashDelay(), _ -> {
displayRankText();
});
highscoreNew.frames = Paths.getSparrowAtlas("resultScreen/highscoreNew");
highscoreNew.animation.addByPrefix("new", "NEW HIGHSCORE", 24);
highscoreNew.animation.addByPrefix("new", "highscoreAnim0", 24, false);
highscoreNew.visible = false;
highscoreNew.setGraphicSize(Std.int(highscoreNew.width * 0.8));
//highscoreNew.setGraphicSize(Std.int(highscoreNew.width * 0.8));
highscoreNew.updateHitbox();
highscoreNew.zIndex = 1200;
add(highscoreNew);
new FlxTimer().start(rank.getHighscoreDelay(), _ -> {
if (params.isNewHighscore ?? false)
{
highscoreNew.visible = true;
highscoreNew.animation.play("new");
highscoreNew.animation.finishCallback = _ -> highscoreNew.animation.play("new", true, false, 16);
}
else
{
highscoreNew.visible = false;
}
});
var hStuf:Int = 50;
var ratingGrp:FlxTypedGroup<TallyCounter> = new FlxTypedGroup<TallyCounter>();
@ -314,7 +379,10 @@ class ResultState extends MusicBeatSubState
ratingGrp.add(maxCombo);
hStuf += 2;
var extraYOffset:Float = 5;
var extraYOffset:Float = 7;
hStuf += 2;
var tallySick:TallyCounter = new TallyCounter(230, (hStuf * 5) + extraYOffset, params.scoreData.tallies.sick, 0xFF89E59E);
ratingGrp.add(tallySick);
@ -343,20 +411,17 @@ class ResultState extends MusicBeatSubState
});
}
ratingsPopin.animation.finishCallback = anim -> {
startRankTallySequence();
if (params.isNewHighscore ?? false)
{
highscoreNew.visible = true;
highscoreNew.animation.play("new");
FlxTween.tween(highscoreNew, {y: highscoreNew.y + 10}, 0.8, {ease: FlxEase.quartOut});
}
else
{
highscoreNew.visible = false;
}
};
// if (params.isNewHighscore ?? false)
// {
// highscoreNew.visible = true;
// highscoreNew.animation.play("new");
// //FlxTween.tween(highscoreNew, {y: highscoreNew.y + 10}, 0.8, {ease: FlxEase.quartOut});
// }
// else
// {
// highscoreNew.visible = false;
// }
new FlxTimer().start(rank.getMusicDelay(), _ -> {
if (rank.hasMusicIntro())
@ -402,6 +467,8 @@ class ResultState extends MusicBeatSubState
function startRankTallySequence():Void
{
bgFlash.visible = true;
FlxTween.tween(bgFlash, {alpha: 0}, 5/24);
var clearPercentFloat = (params.scoreData.tallies.sick + params.scoreData.tallies.good) / params.scoreData.tallies.totalNotes * 100;
clearPercentTarget = Math.floor(clearPercentFloat);
// Prevent off-by-one errors.
@ -410,8 +477,8 @@ class ResultState extends MusicBeatSubState
trace('Clear percent target: ' + clearPercentFloat + ', round: ' + clearPercentTarget);
var clearPercentCounter:ClearPercentCounter = new ClearPercentCounter(FlxG.width / 2 + 300, FlxG.height / 2 - 100, clearPercentLerp);
FlxTween.tween(clearPercentCounter, {curNumber: clearPercentTarget}, 1.5,
var clearPercentCounter:ClearPercentCounter = new ClearPercentCounter(FlxG.width / 2 + 190, FlxG.height / 2 - 70, clearPercentLerp);
FlxTween.tween(clearPercentCounter, {curNumber: clearPercentTarget}, 58/24,
{
ease: FlxEase.quartOut,
onUpdate: _ -> {
@ -426,10 +493,6 @@ class ResultState extends MusicBeatSubState
// Play confirm sound.
FunkinSound.playOnce(Paths.sound('confirmMenu'));
// Flash background.
bgFlash.visible = true;
FlxTween.tween(bgFlash, {alpha: 0}, 0.4);
// Just to be sure that the lerp didn't mess things up.
clearPercentCounter.curNumber = clearPercentTarget;
@ -438,7 +501,7 @@ class ResultState extends MusicBeatSubState
clearPercentCounter.flash(false);
});
displayRankText();
//displayRankText();
// previously 2.0 seconds
new FlxTimer().start(0.25, _ -> {
@ -451,7 +514,7 @@ class ResultState extends MusicBeatSubState
}
});
afterRankTallySequence();
//afterRankTallySequence();
});
}
});
@ -476,7 +539,6 @@ class ResultState extends MusicBeatSubState
{
highscoreNew.visible = true;
highscoreNew.animation.play("new");
FlxTween.tween(highscoreNew, {y: highscoreNew.y + 10}, 0.8, {ease: FlxEase.quartOut});
}
else
{
@ -490,27 +552,36 @@ class ResultState extends MusicBeatSubState
function displayRankText():Void
{
bgFlash.visible = true;
bgFlash.alpha = 1;
FlxTween.tween(bgFlash, {alpha: 0}, 14/24);
var rankTextVert:FlxBackdrop = new FlxBackdrop(Paths.image(rank.getVerTextAsset()), Y, 0, 30);
rankTextVert.x = FlxG.width - 64;
rankTextVert.x = FlxG.width - 44;
rankTextVert.y = 100;
rankTextVert.zIndex = 990;
add(rankTextVert);
// Scrolling.
rankTextVert.velocity.y = -50;
FlxFlicker.flicker(rankTextVert, 2/24 * 3, 2/24, true);
for (i in 0...10)
// Scrolling.
new FlxTimer().start(30/24, _ -> {
rankTextVert.velocity.y = -80;
});
for (i in 0...12)
{
var rankTextBack:FlxBackdrop = new FlxBackdrop(Paths.image(rank.getHorTextAsset()), X, 10, 0);
rankTextBack.x = FlxG.width / 2 - 320;
rankTextBack.y = 50 + (150 * i / 2) + 10;
rankTextBack.y = 50 + (135 * i / 2) + 10;
// rankTextBack.angle = -3.8;
rankTextBack.zIndex = 100;
rankTextBack.cameras = [cameraScroll];
add(rankTextBack);
// Scrolling.
rankTextBack.velocity.x = (i % 2 == 0) ? -10.0 : 10.0;
rankTextBack.velocity.x = (i % 2 == 0) ? -7.0 : 7.0;
}
refresh();
@ -518,6 +589,7 @@ class ResultState extends MusicBeatSubState
function afterRankTallySequence():Void
{
showSmallClearPercent();
switch (rank)
@ -532,6 +604,17 @@ class ResultState extends MusicBeatSubState
bfPerfect.visible = true;
bfPerfect.playAnimation('');
}
new FlxTimer().start(106 / 24, _ -> {
if (heartsPerfect == null)
{
trace("Could not build heartsPerfect animation!");
}
else
{
heartsPerfect.visible = true;
heartsPerfect.playAnimation('');
}
});
case EXCELLENT:
if (bfExcellent == null)
{
@ -540,7 +623,7 @@ class ResultState extends MusicBeatSubState
else
{
bfExcellent.visible = true;
bfExcellent.playAnimation('Intro');
bfExcellent.playAnimation('');
}
case GREAT:
if (bfGreat == null)
@ -550,8 +633,20 @@ class ResultState extends MusicBeatSubState
else
{
bfGreat.visible = true;
bfGreat.playAnimation('Intro');
bfGreat.playAnimation('');
}
new FlxTimer().start(6 / 24, _ -> {
if (gfGreat == null)
{
trace("Could not build GREAT animation for gf!");
}
else
{
gfGreat.visible = true;
gfGreat.playAnimation('');
}
});
case SHIT:
if (bfShit == null)
{
@ -637,7 +732,9 @@ class ResultState extends MusicBeatSubState
refresh();
}
movingSongStuff = true;
new FlxTimer().start(2.5, _ -> {
movingSongStuff = true;
});
}
var movingSongStuff:Bool = false;
@ -657,6 +754,79 @@ class ResultState extends MusicBeatSubState
override function update(elapsed:Float):Void
{
// if(FlxG.keys.justPressed.R){
// FlxG.switchState(() -> new funkin.play.ResultState(
// {
// storyMode: false,
// title: "Cum Song Erect by Kawai Sprite",
// songId: "cum",
// difficultyId: "nightmare",
// isNewHighscore: true,
// scoreData:
// {
// score: 1_234_567,
// tallies:
// {
// sick: 200,
// good: 0,
// bad: 0,
// shit: 0,
// missed: 0,
// combo: 0,
// maxCombo: 69,
// totalNotesHit: 200,
// totalNotes: 200 // 0,
// }
// },
// }));
// }
// if(heartsPerfect != null){
// if (FlxG.keys.justPressed.I)
// {
// heartsPerfect.y -= 1;
// trace(heartsPerfect.x, heartsPerfect.y);
// }
// if (FlxG.keys.justPressed.J)
// {
// heartsPerfect.x -= 1;
// trace(heartsPerfect.x, heartsPerfect.y);
// }
// if (FlxG.keys.justPressed.L)
// {
// heartsPerfect.x += 1;
// trace(heartsPerfect.x, heartsPerfect.y);
// }
// if (FlxG.keys.justPressed.K)
// {
// heartsPerfect.y += 1;
// trace(heartsPerfect.x, heartsPerfect.y);
// }
// }
// if(bfGreat != null){
// if (FlxG.keys.justPressed.W)
// {
// bfGreat.y -= 1;
// trace(bfGreat.x, bfGreat.y);
// }
// if (FlxG.keys.justPressed.A)
// {
// bfGreat.x -= 1;
// trace(bfGreat.x, bfGreat.y);
// }
// if (FlxG.keys.justPressed.D)
// {
// bfGreat.x += 1;
// trace(bfGreat.x, bfGreat.y);
// }
// if (FlxG.keys.justPressed.S)
// {
// bfGreat.y += 1;
// trace(bfGreat.x, bfGreat.y);
// }
// }
// maskShaderSongName.swagSprX = songName.x;
maskShaderDifficulty.swagSprX = difficulty.x;

View file

@ -462,9 +462,75 @@ enum abstract ScoringRank(String)
{
case PERFECT_GOLD | PERFECT:
// return 2.5;
return 5.0;
return 95/24;
case EXCELLENT:
return 1.75;
return 0;
case GREAT:
return 5/24;
case GOOD:
return 3/24;
case SHIT:
return 2/24;
default:
return 3.5;
}
}
public function getBFDelay():Float
{
switch (abstract)
{
case PERFECT_GOLD | PERFECT:
// return 2.5;
return 95/24;
case EXCELLENT:
return 97/24;
case GREAT:
return 95/24;
case GOOD:
return 95/24;
case SHIT:
return 95/24;
default:
return 3.5;
}
}
public function getFlashDelay():Float
{
switch (abstract)
{
case PERFECT_GOLD | PERFECT:
// return 2.5;
return 129/24;
case EXCELLENT:
return 122/24;
case GREAT:
return 109/24;
case GOOD:
return 107/24;
case SHIT:
return 186/24;
default:
return 3.5;
}
}
public function getHighscoreDelay():Float
{
switch (abstract)
{
case PERFECT_GOLD | PERFECT:
// return 2.5;
return 140/24;
case EXCELLENT:
return 140/24;
case GREAT:
return 129/24;
case GOOD:
return 127/24;
case SHIT:
return 207/24;
default:
return 3.5;
}