mirror of
https://github.com/FunkinCrew/Funkin.git
synced 2024-11-23 16:17:53 -05:00
freeplay highscore stuff
This commit is contained in:
parent
0b24dd537e
commit
e1f53d288d
6 changed files with 112 additions and 11 deletions
|
@ -47,6 +47,9 @@ class FreeplayState extends MusicBeatSubstate
|
||||||
var curDifficulty:Int = 1;
|
var curDifficulty:Int = 1;
|
||||||
|
|
||||||
var fp:FreeplayScore;
|
var fp:FreeplayScore;
|
||||||
|
var txtCompletion:FlxText;
|
||||||
|
var lerpCompletion:Float = 0;
|
||||||
|
var intendedCompletion:Float = 0;
|
||||||
var lerpScore:Float = 0;
|
var lerpScore:Float = 0;
|
||||||
var intendedScore:Int = 0;
|
var intendedScore:Int = 0;
|
||||||
|
|
||||||
|
@ -233,10 +236,30 @@ class FreeplayState extends MusicBeatSubstate
|
||||||
fnfFreeplay.shader = sillyStroke;
|
fnfFreeplay.shader = sillyStroke;
|
||||||
add(fnfFreeplay);
|
add(fnfFreeplay);
|
||||||
|
|
||||||
fp = new FreeplayScore(420, 40, 100);
|
var fnfHighscoreSpr:FlxSprite = new FlxSprite(890, 70);
|
||||||
|
fnfHighscoreSpr.frames = Paths.getSparrowAtlas('freeplay/highscore');
|
||||||
|
fnfHighscoreSpr.animation.addByPrefix("highscore", "highscore", 24, false);
|
||||||
|
fnfHighscoreSpr.visible = false;
|
||||||
|
fnfHighscoreSpr.setGraphicSize(0, Std.int(fnfHighscoreSpr.height * 1));
|
||||||
|
fnfHighscoreSpr.antialiasing = true;
|
||||||
|
fnfHighscoreSpr.updateHitbox();
|
||||||
|
add(fnfHighscoreSpr);
|
||||||
|
|
||||||
|
new FlxTimer().start(FlxG.random.float(12, 50), function(tmr)
|
||||||
|
{
|
||||||
|
fnfHighscoreSpr.animation.play("highscore");
|
||||||
|
tmr.time = FlxG.random.float(20, 60);
|
||||||
|
}, 0);
|
||||||
|
|
||||||
|
fp = new FreeplayScore(460, 60, 100);
|
||||||
fp.visible = false;
|
fp.visible = false;
|
||||||
add(fp);
|
add(fp);
|
||||||
|
|
||||||
|
txtCompletion = new FlxText(1200, 77, 0, "0", 32);
|
||||||
|
txtCompletion.font = "VCR OSD Mono";
|
||||||
|
txtCompletion.visible = false;
|
||||||
|
add(txtCompletion);
|
||||||
|
|
||||||
dj.onIntroDone.add(function()
|
dj.onIntroDone.add(function()
|
||||||
{
|
{
|
||||||
FlxTween.tween(grpDifficulties, {x: 90}, 0.6, {ease: FlxEase.quartOut});
|
FlxTween.tween(grpDifficulties, {x: 90}, 0.6, {ease: FlxEase.quartOut});
|
||||||
|
@ -262,9 +285,13 @@ class FreeplayState extends MusicBeatSubstate
|
||||||
|
|
||||||
new FlxTimer().start(1 / 24, function(handShit)
|
new FlxTimer().start(1 / 24, function(handShit)
|
||||||
{
|
{
|
||||||
|
fnfHighscoreSpr.visible = true;
|
||||||
fnfFreeplay.visible = true;
|
fnfFreeplay.visible = true;
|
||||||
fp.visible = true;
|
fp.visible = true;
|
||||||
fp.updateScore(FlxG.random.int(0, 1000));
|
fp.updateScore(0);
|
||||||
|
|
||||||
|
txtCompletion.visible = true;
|
||||||
|
intendedCompletion = 0;
|
||||||
|
|
||||||
new FlxTimer().start(1.5 / 24, function(bold)
|
new FlxTimer().start(1.5 / 24, function(bold)
|
||||||
{
|
{
|
||||||
|
@ -384,7 +411,7 @@ class FreeplayState extends MusicBeatSubstate
|
||||||
funnyMenu.songText.visible = false;
|
funnyMenu.songText.visible = false;
|
||||||
funnyMenu.favIcon.visible = tempSongs[i].isFav;
|
funnyMenu.favIcon.visible = tempSongs[i].isFav;
|
||||||
|
|
||||||
fp.updateScore(0);
|
// fp.updateScore(0);
|
||||||
|
|
||||||
new FlxTimer().start((1 / 24) * i, function(doShit)
|
new FlxTimer().start((1 / 24) * i, function(doShit)
|
||||||
{
|
{
|
||||||
|
@ -479,7 +506,6 @@ class FreeplayState extends MusicBeatSubstate
|
||||||
songs[curSelected].isFav = !songs[curSelected].isFav;
|
songs[curSelected].isFav = !songs[curSelected].isFav;
|
||||||
if (songs[curSelected].isFav)
|
if (songs[curSelected].isFav)
|
||||||
{
|
{
|
||||||
|
|
||||||
FlxTween.tween(grpCapsules.members[realShit], {angle: 360}, 0.4, {
|
FlxTween.tween(grpCapsules.members[realShit], {angle: 360}, 0.4, {
|
||||||
ease: FlxEase.elasticOut,
|
ease: FlxEase.elasticOut,
|
||||||
onComplete: _ ->
|
onComplete: _ ->
|
||||||
|
@ -515,8 +541,16 @@ class FreeplayState extends MusicBeatSubstate
|
||||||
}
|
}
|
||||||
|
|
||||||
lerpScore = CoolUtil.coolLerp(lerpScore, intendedScore, 0.2);
|
lerpScore = CoolUtil.coolLerp(lerpScore, intendedScore, 0.2);
|
||||||
|
lerpCompletion = CoolUtil.coolLerp(lerpCompletion, intendedCompletion, 0.9);
|
||||||
|
|
||||||
fp.scoreShit = Std.int(lerpScore);
|
fp.updateScore(Std.int(lerpScore));
|
||||||
|
|
||||||
|
txtCompletion.text = Math.floor(lerpCompletion * 100) + "%";
|
||||||
|
trace(Highscore.getCompletion(songs[curSelected].songName, curDifficulty));
|
||||||
|
|
||||||
|
// trace(intendedScore);
|
||||||
|
// trace(lerpScore);
|
||||||
|
// Highscore.getAllScores();
|
||||||
|
|
||||||
var upP = controls.UI_UP_P;
|
var upP = controls.UI_UP_P;
|
||||||
var downP = controls.UI_DOWN_P;
|
var downP = controls.UI_DOWN_P;
|
||||||
|
@ -736,6 +770,7 @@ class FreeplayState extends MusicBeatSubstate
|
||||||
|
|
||||||
// intendedScore = Highscore.getScore(songs[curSelected].songName, curDifficulty);
|
// intendedScore = Highscore.getScore(songs[curSelected].songName, curDifficulty);
|
||||||
intendedScore = Highscore.getScore(songs[curSelected].songName, curDifficulty);
|
intendedScore = Highscore.getScore(songs[curSelected].songName, curDifficulty);
|
||||||
|
intendedCompletion = Highscore.getCompletion(songs[curSelected].songName, curDifficulty);
|
||||||
|
|
||||||
PlayState.storyDifficulty = curDifficulty;
|
PlayState.storyDifficulty = curDifficulty;
|
||||||
PlayState.storyDifficulty_NEW = switch (curDifficulty)
|
PlayState.storyDifficulty_NEW = switch (curDifficulty)
|
||||||
|
@ -799,7 +834,8 @@ class FreeplayState extends MusicBeatSubstate
|
||||||
// selector.y = (70 * curSelected) + 30;
|
// selector.y = (70 * curSelected) + 30;
|
||||||
|
|
||||||
// intendedScore = Highscore.getScore(songs[curSelected].songName, curDifficulty);
|
// intendedScore = Highscore.getScore(songs[curSelected].songName, curDifficulty);
|
||||||
intendedScore = FlxG.random.int(0, 1000000);
|
intendedScore = Highscore.getScore(songs[curSelected].songName, curDifficulty);
|
||||||
|
intendedCompletion = Highscore.getCompletion(songs[curSelected].songName, curDifficulty);
|
||||||
// lerpScore = 0;
|
// lerpScore = 0;
|
||||||
|
|
||||||
#if PRELOAD_ALL
|
#if PRELOAD_ALL
|
||||||
|
|
|
@ -8,6 +8,12 @@ class Highscore
|
||||||
public static var songScores:Map<String, Int> = new Map<String, Int>();
|
public static var songScores:Map<String, Int> = new Map<String, Int>();
|
||||||
#end
|
#end
|
||||||
|
|
||||||
|
#if (haxe >= "4.0.0")
|
||||||
|
public static var songCompletion:Map<String, Float> = new Map();
|
||||||
|
#else
|
||||||
|
public static var songCompletion:Map<String, Float> = new Map<String, Float>();
|
||||||
|
#end
|
||||||
|
|
||||||
public static var tallies:Tallies = new Tallies();
|
public static var tallies:Tallies = new Tallies();
|
||||||
|
|
||||||
public static function saveScore(song:String, score:Int = 0, ?diff:Int = 0):Bool
|
public static function saveScore(song:String, score:Int = 0, ?diff:Int = 0):Bool
|
||||||
|
@ -33,6 +39,24 @@ class Highscore
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function saveCompletion(song:String, completion:Float, ?diff:Int = 0):Bool
|
||||||
|
{
|
||||||
|
var formattedSong:String = formatSong(song, diff);
|
||||||
|
|
||||||
|
if (songCompletion.exists(formattedSong))
|
||||||
|
{
|
||||||
|
if (songCompletion.get(formattedSong) < completion)
|
||||||
|
{
|
||||||
|
setCompletion(formattedSong, completion);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
setCompletion(formattedSong, completion);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public static function saveWeekScore(week:Int = 1, score:Int = 0, ?diff:Int = 0):Void
|
public static function saveWeekScore(week:Int = 1, score:Int = 0, ?diff:Int = 0):Void
|
||||||
{
|
{
|
||||||
#if newgrounds
|
#if newgrounds
|
||||||
|
@ -50,6 +74,13 @@ class Highscore
|
||||||
setScore(formattedSong, score);
|
setScore(formattedSong, score);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static function setCompletion(formattedSong:String, completion:Float):Void
|
||||||
|
{
|
||||||
|
songCompletion.set(formattedSong, completion);
|
||||||
|
FlxG.save.data.songCompletion = songCompletion;
|
||||||
|
FlxG.save.flush();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* YOU SHOULD FORMAT SONG WITH formatSong() BEFORE TOSSING IN SONG VARIABLE
|
* YOU SHOULD FORMAT SONG WITH formatSong() BEFORE TOSSING IN SONG VARIABLE
|
||||||
*/
|
*/
|
||||||
|
@ -88,6 +119,19 @@ class Highscore
|
||||||
return songScores.get(formatSong(song, diff));
|
return songScores.get(formatSong(song, diff));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function getCompletion(song, diff):Float
|
||||||
|
{
|
||||||
|
if (!songCompletion.exists(formatSong(song, diff)))
|
||||||
|
setCompletion(formatSong(song, diff), 0);
|
||||||
|
|
||||||
|
return songCompletion.get(formatSong(song, diff));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getAllScores()
|
||||||
|
{
|
||||||
|
trace(songScores.toString());
|
||||||
|
}
|
||||||
|
|
||||||
public static function getWeekScore(week:Int, diff:Int):Int
|
public static function getWeekScore(week:Int, diff:Int):Int
|
||||||
{
|
{
|
||||||
if (!songScores.exists(formatSong('week' + week, diff)))
|
if (!songScores.exists(formatSong('week' + week, diff)))
|
||||||
|
@ -102,6 +146,9 @@ class Highscore
|
||||||
{
|
{
|
||||||
songScores = FlxG.save.data.songScores;
|
songScores = FlxG.save.data.songScores;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (FlxG.save.data.songCompletion != null)
|
||||||
|
songCompletion = FlxG.save.data.songCompletion;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,6 +167,7 @@ abstract Tallies(RawTallies)
|
||||||
good: 0,
|
good: 0,
|
||||||
sick: 0,
|
sick: 0,
|
||||||
totalNotes: 0,
|
totalNotes: 0,
|
||||||
|
totalNotesHit: 0,
|
||||||
maxCombo: 0,
|
maxCombo: 0,
|
||||||
isNewHighscore: false
|
isNewHighscore: false
|
||||||
}
|
}
|
||||||
|
@ -145,5 +193,10 @@ typedef RawTallies =
|
||||||
/**
|
/**
|
||||||
* How many notes total that you hit. (NOT how many notes total in the song!)
|
* How many notes total that you hit. (NOT how many notes total in the song!)
|
||||||
*/
|
*/
|
||||||
|
var totalNotesHit:Int;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* How many notes PASSED BY AND/OR HIT!!!
|
||||||
|
*/
|
||||||
var totalNotes:Int;
|
var totalNotes:Int;
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,6 +81,9 @@ class PauseSubState extends MusicBeatSubstate
|
||||||
|
|
||||||
var deathCounter:FlxText = new FlxText(20, 15 + 64, 0, "", 32);
|
var deathCounter:FlxText = new FlxText(20, 15 + 64, 0, "", 32);
|
||||||
deathCounter.text = "Blue balled: " + PlayState.deathCounter;
|
deathCounter.text = "Blue balled: " + PlayState.deathCounter;
|
||||||
|
deathCounter.text += "\n" + Highscore.tallies.totalNotesHit;
|
||||||
|
deathCounter.text += "\n" + Highscore.tallies.totalNotes;
|
||||||
|
deathCounter.text += "\n" + Std.string(Highscore.tallies.totalNotesHit / Highscore.tallies.totalNotes);
|
||||||
deathCounter.scrollFactor.set();
|
deathCounter.scrollFactor.set();
|
||||||
deathCounter.setFormat(Paths.font('vcr.ttf'), 32);
|
deathCounter.setFormat(Paths.font('vcr.ttf'), 32);
|
||||||
deathCounter.updateHitbox();
|
deathCounter.updateHitbox();
|
||||||
|
|
|
@ -51,7 +51,7 @@ class FreeplayScore extends FlxTypedSpriteGroup<ScoreNum>
|
||||||
|
|
||||||
for (i in 0...7)
|
for (i in 0...7)
|
||||||
{
|
{
|
||||||
add(new ScoreNum(x + (35 * i), y, 0));
|
add(new ScoreNum(x + (45 * i), y, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
this.scoreShit = scoreShit;
|
this.scoreShit = scoreShit;
|
||||||
|
@ -122,7 +122,7 @@ class ScoreNum extends FlxSprite
|
||||||
animation.play(numToString[digit], true);
|
animation.play(numToString[digit], true);
|
||||||
antialiasing = true;
|
antialiasing = true;
|
||||||
|
|
||||||
setGraphicSize(Std.int(width * 0.3));
|
setGraphicSize(Std.int(width * 0.4));
|
||||||
updateHitbox();
|
updateHitbox();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1196,6 +1196,9 @@ class PlayState extends MusicBeatState
|
||||||
|
|
||||||
function regenNoteData_NEW():Void
|
function regenNoteData_NEW():Void
|
||||||
{
|
{
|
||||||
|
Highscore.tallies.combo = 0;
|
||||||
|
Highscore.tallies = new Tallies();
|
||||||
|
|
||||||
// Reset song events.
|
// Reset song events.
|
||||||
songEvents = currentChart.getEvents();
|
songEvents = currentChart.getEvents();
|
||||||
SongEventHandler.resetEvents(songEvents);
|
SongEventHandler.resetEvents(songEvents);
|
||||||
|
@ -1637,6 +1640,10 @@ class PlayState extends MusicBeatState
|
||||||
while (inactiveNotes[0] != null && inactiveNotes[0].data.strumTime - Conductor.songPosition < 1800 / SongLoad.getSpeed())
|
while (inactiveNotes[0] != null && inactiveNotes[0].data.strumTime - Conductor.songPosition < 1800 / SongLoad.getSpeed())
|
||||||
{
|
{
|
||||||
var dunceNote:Note = inactiveNotes[0];
|
var dunceNote:Note = inactiveNotes[0];
|
||||||
|
|
||||||
|
if (dunceNote.mustPress && !dunceNote.isSustainNote)
|
||||||
|
Highscore.tallies.totalNotes++;
|
||||||
|
|
||||||
activeNotes.add(dunceNote);
|
activeNotes.add(dunceNote);
|
||||||
|
|
||||||
inactiveNotes.shift();
|
inactiveNotes.shift();
|
||||||
|
@ -1834,6 +1841,8 @@ class PlayState extends MusicBeatState
|
||||||
{
|
{
|
||||||
// crackhead double thingie, sets whether was new highscore, AND saves the song!
|
// crackhead double thingie, sets whether was new highscore, AND saves the song!
|
||||||
Highscore.tallies.isNewHighscore = Highscore.saveScore(currentSong.song, songScore, storyDifficulty);
|
Highscore.tallies.isNewHighscore = Highscore.saveScore(currentSong.song, songScore, storyDifficulty);
|
||||||
|
|
||||||
|
Highscore.saveCompletion(currentSong.song, Highscore.tallies.totalNotesHit / Highscore.tallies.totalNotes, storyDifficulty);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isStoryMode)
|
if (isStoryMode)
|
||||||
|
@ -2261,7 +2270,7 @@ class PlayState extends MusicBeatState
|
||||||
if (!note.isSustainNote)
|
if (!note.isSustainNote)
|
||||||
{
|
{
|
||||||
Highscore.tallies.combo++;
|
Highscore.tallies.combo++;
|
||||||
Highscore.tallies.totalNotes++;
|
Highscore.tallies.totalNotesHit++;
|
||||||
|
|
||||||
if (Highscore.tallies.combo > Highscore.tallies.maxCombo)
|
if (Highscore.tallies.combo > Highscore.tallies.maxCombo)
|
||||||
Highscore.tallies.maxCombo = Highscore.tallies.combo;
|
Highscore.tallies.maxCombo = Highscore.tallies.combo;
|
||||||
|
|
|
@ -28,7 +28,7 @@ class ResultState extends MusicBeatSubstate
|
||||||
|
|
||||||
override function create()
|
override function create()
|
||||||
{
|
{
|
||||||
if (Highscore.tallies.sick == Highscore.tallies.totalNotes && Highscore.tallies.maxCombo == Highscore.tallies.totalNotes)
|
if (Highscore.tallies.sick == Highscore.tallies.totalNotesHit && Highscore.tallies.maxCombo == Highscore.tallies.totalNotesHit)
|
||||||
resultsVariation = PERFECT;
|
resultsVariation = PERFECT;
|
||||||
else if (Highscore.tallies.missed + Highscore.tallies.bad + Highscore.tallies.shit >= Highscore.tallies.totalNotes * 0.50)
|
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!
|
resultsVariation = SHIT; // if more than half of your song was missed, bad, or shit notes, you get shit ending!
|
||||||
|
@ -165,7 +165,7 @@ class ResultState extends MusicBeatSubstate
|
||||||
var ratingGrp:FlxTypedGroup<TallyCounter> = new FlxTypedGroup<TallyCounter>();
|
var ratingGrp:FlxTypedGroup<TallyCounter> = new FlxTypedGroup<TallyCounter>();
|
||||||
add(ratingGrp);
|
add(ratingGrp);
|
||||||
|
|
||||||
var totalHit:TallyCounter = new TallyCounter(375, hStuf * 3, Highscore.tallies.totalNotes);
|
var totalHit:TallyCounter = new TallyCounter(375, hStuf * 3, Highscore.tallies.totalNotesHit);
|
||||||
ratingGrp.add(totalHit);
|
ratingGrp.add(totalHit);
|
||||||
|
|
||||||
var maxCombo:TallyCounter = new TallyCounter(375, hStuf * 4, Highscore.tallies.maxCombo);
|
var maxCombo:TallyCounter = new TallyCounter(375, hStuf * 4, Highscore.tallies.maxCombo);
|
||||||
|
|
Loading…
Reference in a new issue