1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2025-11-28 15:26:12 +00:00

Finish implementing smaller numbers.

This commit is contained in:
EliteMasterEric 2024-05-22 01:07:20 -04:00
parent b6b93bb0c6
commit f17f639304
4 changed files with 124 additions and 30 deletions

2
assets

@ -1 +1 @@
Subproject commit ce7dabffbebc154c9dda1f01e92dbef83e3405ab Subproject commit b6d930109eb69cfd368145e893d81ac1e97ed004

View file

@ -227,14 +227,14 @@ class InitState extends FlxState
tallies: tallies:
{ {
sick: 130, sick: 130,
good: 69, good: 70,
bad: 69, bad: 69,
shit: 69, shit: 69,
missed: 69, missed: 69,
combo: 69, combo: 69,
maxCombo: 69, maxCombo: 69,
totalNotesHit: 140, totalNotesHit: 140,
totalNotes: 2000, totalNotes: 200 // 0,
} }
}, },
})); }));

View file

@ -37,6 +37,7 @@ class ResultState extends MusicBeatSubState
final rank:ResultRank; final rank:ResultRank;
final songName:FlxBitmapText; final songName:FlxBitmapText;
final difficulty:FlxSprite; final difficulty:FlxSprite;
final clearPercentSmall:ClearPercentCounter;
final maskShaderSongName:LeftMaskShader = new LeftMaskShader(); final maskShaderSongName:LeftMaskShader = new LeftMaskShader();
final maskShaderDifficulty:LeftMaskShader = new LeftMaskShader(); final maskShaderDifficulty:LeftMaskShader = new LeftMaskShader();
@ -78,6 +79,10 @@ class ResultState extends MusicBeatSubState
difficulty = new FlxSprite(555); difficulty = new FlxSprite(555);
difficulty.zIndex = 1000; difficulty.zIndex = 1000;
clearPercentSmall = new ClearPercentCounter(FlxG.width / 2 + 300, FlxG.height / 2 - 100, 100, true);
clearPercentSmall.zIndex = 1000;
clearPercentSmall.visible = false;
bgFlash = FlxGradient.createGradientFlxSprite(FlxG.width, FlxG.height, [0xFFFFEB69, 0xFFFFE66A], 90); bgFlash = FlxGradient.createGradientFlxSprite(FlxG.width, FlxG.height, [0xFFFFEB69, 0xFFFFE66A], 90);
resultsAnim = FunkinSprite.createSparrow(-200, -10, "resultScreen/results"); resultsAnim = FunkinSprite.createSparrow(-200, -10, "resultScreen/results");
@ -194,7 +199,7 @@ class ResultState extends MusicBeatSubState
speedOfTween.x = -1.0 * Math.cos(angleRad); speedOfTween.x = -1.0 * Math.cos(angleRad);
speedOfTween.y = -1.0 * Math.sin(angleRad); speedOfTween.y = -1.0 * Math.sin(angleRad);
timerThenSongName(1.0); timerThenSongName(1.0, false);
songName.shader = maskShaderSongName; songName.shader = maskShaderSongName;
difficulty.shader = maskShaderDifficulty; difficulty.shader = maskShaderDifficulty;
@ -319,13 +324,15 @@ class ResultState extends MusicBeatSubState
function startRankTallySequence():Void function startRankTallySequence():Void
{ {
clearPercentTarget = Math.floor((params.scoreData.tallies.sick + params.scoreData.tallies.good) / params.scoreData.tallies.totalNotes * 100); var clearPercentFloat = (params.scoreData.tallies.sick + params.scoreData.tallies.good) / params.scoreData.tallies.totalNotes * 100;
clearPercentTarget = 100; clearPercentTarget = Math.floor(clearPercentFloat);
// Prevent off-by-one errors.
clearPercentLerp = Std.int(Math.max(0, clearPercentTarget - 36)); clearPercentLerp = Std.int(Math.max(0, clearPercentTarget - 36));
var clearPercentCounter:ClearPercentCounter = new ClearPercentCounter(FlxG.width / 2 + 300, FlxG.height / 2 - 100, clearPercentTarget); trace('Clear percent target: ' + clearPercentFloat + ', round: ' + clearPercentTarget);
clearPercentCounter.curNumber = clearPercentLerp;
var clearPercentCounter:ClearPercentCounter = new ClearPercentCounter(FlxG.width / 2 + 300, FlxG.height / 2 - 100, clearPercentLerp);
FlxTween.tween(clearPercentCounter, {curNumber: clearPercentTarget}, 1.5, FlxTween.tween(clearPercentCounter, {curNumber: clearPercentTarget}, 1.5,
{ {
ease: FlxEase.quartOut, ease: FlxEase.quartOut,
@ -345,10 +352,25 @@ class ResultState extends MusicBeatSubState
bgFlash.visible = true; bgFlash.visible = true;
FlxTween.tween(bgFlash, {alpha: 0}, 0.4); FlxTween.tween(bgFlash, {alpha: 0}, 0.4);
// Just to be sure that the lerp didn't mess things up.
clearPercentCounter.curNumber = clearPercentTarget;
clearPercentCounter.flash(true);
new FlxTimer().start(0.4, _ -> {
clearPercentCounter.flash(false);
});
displayRankText(); displayRankText();
new FlxTimer().start(2.0, _ -> { new FlxTimer().start(2.0, _ -> {
// remove(clearPercentCounter); FlxTween.tween(clearPercentCounter, {alpha: 0}, 0.5,
{
startDelay: 0.5,
ease: FlxEase.quartOut,
onComplete: _ -> {
remove(clearPercentCounter);
}
});
afterRankTallySequence(); afterRankTallySequence();
}); });
@ -406,6 +428,8 @@ class ResultState extends MusicBeatSubState
function afterRankTallySequence():Void function afterRankTallySequence():Void
{ {
showSmallClearPercent();
FunkinSound.playMusic(rank.getMusicPath(), FunkinSound.playMusic(rank.getMusicPath(),
{ {
startingVolume: 1.0, startingVolume: 1.0,
@ -490,7 +514,7 @@ class ResultState extends MusicBeatSubState
} }
} }
function timerThenSongName(timerLength:Float = 3.0):Void function timerThenSongName(timerLength:Float = 3.0, autoScroll:Bool = true):Void
{ {
movingSongStuff = false; movingSongStuff = false;
@ -501,10 +525,17 @@ class ResultState extends MusicBeatSubState
difficulty.y = -difficulty.height; difficulty.y = -difficulty.height;
FlxTween.tween(difficulty, {y: diffYTween}, 0.5, {ease: FlxEase.expoOut, startDelay: 0.8}); FlxTween.tween(difficulty, {y: diffYTween}, 0.5, {ease: FlxEase.expoOut, startDelay: 0.8});
if (clearPercentSmall != null)
{
clearPercentSmall.x = (difficulty.x + difficulty.width) + 60;
clearPercentSmall.y = -clearPercentSmall.height;
FlxTween.tween(clearPercentSmall, {y: 122 - 5}, 0.5, {ease: FlxEase.expoOut, startDelay: 0.8});
}
songName.y = -songName.height; songName.y = -songName.height;
var fuckedupnumber = (10) * (songName.text.length / 15); var fuckedupnumber = (10) * (songName.text.length / 15);
FlxTween.tween(songName, {y: diffYTween - 35 - fuckedupnumber}, 0.5, {ease: FlxEase.expoOut, startDelay: 0.9}); FlxTween.tween(songName, {y: diffYTween - 25 - fuckedupnumber}, 0.5, {ease: FlxEase.expoOut, startDelay: 0.9});
songName.x = (difficulty.x + difficulty.width) + 20; songName.x = clearPercentSmall.x + clearPercentSmall.width - 30;
new FlxTimer().start(timerLength, _ -> { new FlxTimer().start(timerLength, _ -> {
var tempSpeed = FlxPoint.get(speedOfTween.x, speedOfTween.y); var tempSpeed = FlxPoint.get(speedOfTween.x, speedOfTween.y);
@ -512,10 +543,29 @@ class ResultState extends MusicBeatSubState
speedOfTween.set(0, 0); speedOfTween.set(0, 0);
FlxTween.tween(speedOfTween, {x: tempSpeed.x, y: tempSpeed.y}, 0.7, {ease: FlxEase.quadIn}); FlxTween.tween(speedOfTween, {x: tempSpeed.x, y: tempSpeed.y}, 0.7, {ease: FlxEase.quadIn});
movingSongStuff = true; movingSongStuff = (autoScroll);
}); });
} }
function showSmallClearPercent():Void
{
if (clearPercentSmall != null)
{
add(clearPercentSmall);
clearPercentSmall.visible = true;
clearPercentSmall.flash(true);
new FlxTimer().start(0.4, _ -> {
clearPercentSmall.flash(false);
});
clearPercentSmall.curNumber = clearPercentTarget;
clearPercentSmall.zIndex = 1000;
refresh();
}
movingSongStuff = true;
}
var movingSongStuff:Bool = false; var movingSongStuff:Bool = false;
var speedOfTween:FlxPoint = FlxPoint.get(-1, 1); var speedOfTween:FlxPoint = FlxPoint.get(-1, 1);
@ -523,7 +573,8 @@ class ResultState extends MusicBeatSubState
{ {
super.draw(); super.draw();
songName.clipRect = FlxRect.get(Math.max(0, 540 - songName.x), 0, FlxG.width, songName.height); songName.clipRect = FlxRect.get(Math.max(0, 520 - songName.x), 0, FlxG.width, songName.height);
// PROBABLY SHOULD FIX MEMORY FREE OR WHATEVER THE PUT() FUNCTION DOES !!!! FEELS LIKE IT STUTTERS!!! // PROBABLY SHOULD FIX MEMORY FREE OR WHATEVER THE PUT() FUNCTION DOES !!!! FEELS LIKE IT STUTTERS!!!
// if (songName != null && songName.frame != null) // if (songName != null && songName.frame != null)
@ -539,8 +590,10 @@ class ResultState extends MusicBeatSubState
{ {
songName.x += speedOfTween.x; songName.x += speedOfTween.x;
difficulty.x += speedOfTween.x; difficulty.x += speedOfTween.x;
clearPercentSmall.x += speedOfTween.x;
songName.y += speedOfTween.y; songName.y += speedOfTween.y;
difficulty.y += speedOfTween.y; difficulty.y += speedOfTween.y;
clearPercentSmall.y += speedOfTween.y;
if (songName.x + songName.width < 100) if (songName.x + songName.width < 100)
{ {

View file

@ -1,6 +1,7 @@
package funkin.play.components; package funkin.play.components;
import funkin.graphics.FunkinSprite; import funkin.graphics.FunkinSprite;
import funkin.graphics.shaders.PureColor;
import flixel.FlxSprite; import flixel.FlxSprite;
import flixel.group.FlxGroup.FlxTypedGroup; import flixel.group.FlxGroup.FlxTypedGroup;
import flixel.group.FlxSpriteGroup.FlxTypedSpriteGroup; import flixel.group.FlxSpriteGroup.FlxTypedSpriteGroup;
@ -9,25 +10,54 @@ import flixel.tweens.FlxEase;
import flixel.tweens.FlxTween; import flixel.tweens.FlxTween;
import flixel.text.FlxText.FlxTextAlign; import flixel.text.FlxText.FlxTextAlign;
import funkin.util.MathUtil; import funkin.util.MathUtil;
import flixel.util.FlxColor;
/** /**
* Numerical counters used to display the clear percent. * Numerical counters used to display the clear percent.
*/ */
class ClearPercentCounter extends FlxTypedSpriteGroup<FlxSprite> class ClearPercentCounter extends FlxTypedSpriteGroup<FlxSprite>
{ {
public var curNumber:Int = 0; public var curNumber(default, set):Int = 0;
public var neededNumber:Int = 0;
public function new(x:Float, y:Float, neededNumber:Int = 0) var numberChanged:Bool = false;
function set_curNumber(val:Int):Int
{
numberChanged = true;
return curNumber = val;
}
var small:Bool = false;
var flashShader:PureColor;
public function new(x:Float, y:Float, startingNumber:Int = 0, small:Bool = false)
{ {
super(x, y); super(x, y);
this.neededNumber = neededNumber; flashShader = new PureColor(FlxColor.WHITE);
flashShader.colorSet = true;
var clearPercentText:FunkinSprite = FunkinSprite.create(0, 0, 'resultScreen/clearPercent/clearPercentText'); curNumber = startingNumber;
this.small = small;
var clearPercentText:FunkinSprite = FunkinSprite.create(0, 0, 'resultScreen/clearPercent/clearPercentText${small ? 'Small' : ''}');
clearPercentText.x = small ? 40 : 0;
add(clearPercentText); add(clearPercentText);
if (curNumber == neededNumber) drawNumbers(); drawNumbers();
}
/**
* Make the counter flash turn white or stop being all white.
* @param enabled Whether the counter should be white.
*/
public function flash(enabled:Bool):Void
{
for (member in members)
{
member.shader = enabled ? flashShader : null;
}
} }
var tmr:Float = 0; var tmr:Float = 0;
@ -36,7 +66,7 @@ class ClearPercentCounter extends FlxTypedSpriteGroup<FlxSprite>
{ {
super.update(elapsed); super.update(elapsed);
if (curNumber < neededNumber) drawNumbers(); if (numberChanged) drawNumbers();
} }
function drawNumbers() function drawNumbers()
@ -44,8 +74,6 @@ class ClearPercentCounter extends FlxTypedSpriteGroup<FlxSprite>
var seperatedScore:Array<Int> = []; var seperatedScore:Array<Int> = [];
var tempCombo:Int = Math.round(curNumber); var tempCombo:Int = Math.round(curNumber);
var fullNumberDigits:Int = Std.int(Math.max(1, Math.ceil(MathUtil.logBase(10, neededNumber))));
while (tempCombo != 0) while (tempCombo != 0)
{ {
seperatedScore.push(tempCombo % 10); seperatedScore.push(tempCombo % 10);
@ -59,19 +87,32 @@ class ClearPercentCounter extends FlxTypedSpriteGroup<FlxSprite>
for (ind => num in seperatedScore) for (ind => num in seperatedScore)
{ {
var digitIndex = ind + 1; var digitIndex = ind + 1;
// If there's only one digit, move it to the right
// If there's three digits, move them all to the left
var digitOffset = (seperatedScore.length == 1) ? 1 : (seperatedScore.length == 3) ? -1 : 0;
var digitSize = small ? 32 : 72;
var digitHeightOffset = small ? -4 : 0;
var xPos = (digitIndex - 1 + digitOffset) * (digitSize * this.scale.x);
xPos += small ? -24 : 0;
var yPos = (digitIndex - 1 + digitOffset) * (digitHeightOffset * this.scale.y);
yPos += small ? 0 : 72;
if (digitIndex >= members.length) if (digitIndex >= members.length)
{ {
var xPos = (digitIndex - 1) * (72 * this.scale.x); // Three digits = LLR because the 1 and 0 won't be the same anyway.
var yPos = 72; var variant:Bool = (seperatedScore.length == 3) ? (digitIndex >= 2) : (digitIndex >= 1);
// Three digits = LRL so two different numbers aren't adjacent to each other. // var variant:Bool = (seperatedScore.length % 2 != 0) ? (digitIndex % 2 == 0) : (digitIndex % 2 == 1);
var variant:Bool = (fullNumberDigits % 2 != 0) ? (digitIndex % 2 == 0) : (digitIndex % 2 == 1); var numb:ClearPercentNumber = new ClearPercentNumber(xPos, yPos, num, variant, this.small);
var numb:ClearPercentNumber = new ClearPercentNumber(xPos, yPos, num);
numb.scale.set(this.scale.x, this.scale.y); numb.scale.set(this.scale.x, this.scale.y);
add(numb); add(numb);
} }
else else
{ {
members[digitIndex].animation.play(Std.string(num)); members[digitIndex].animation.play(Std.string(num));
// Reset the position of the number
members[digitIndex].x = xPos + this.x;
members[digitIndex].y = yPos + this.y;
} }
} }
} }
@ -79,11 +120,11 @@ class ClearPercentCounter extends FlxTypedSpriteGroup<FlxSprite>
class ClearPercentNumber extends FlxSprite class ClearPercentNumber extends FlxSprite
{ {
public function new(x:Float, y:Float, digit:Int, variant:Bool = false) public function new(x:Float, y:Float, digit:Int, variant:Bool, small:Bool)
{ {
super(x, y); super(x, y);
frames = Paths.getSparrowAtlas('resultScreen/clearPercent/clearPercentNumber${variant ? 'Right' : 'Left'}'); frames = Paths.getSparrowAtlas('resultScreen/clearPercent/clearPercentNumber${small ? 'Small' : variant ? 'Right' : 'Left'}');
for (i in 0...10) for (i in 0...10)
{ {