basic result screen in progress counting tallies

This commit is contained in:
Cameron Taylor 2022-09-20 02:16:12 -04:00
parent 36e6d6bd91
commit 1dbb4099ec
3 changed files with 100 additions and 10 deletions

View file

@ -8,6 +8,8 @@ class Highscore
public static var songScores:Map<String, Int> = new Map<String, Int>();
#end
public static var tallies:Tallies = new Tallies();
public static function saveScore(song:String, score:Int = 0, ?diff:Int = 0):Void
{
var formattedSong:String = formatSong(song, diff);
@ -96,3 +98,35 @@ class Highscore
}
}
}
// i only do forward metadata cuz george did!
@:forward
abstract Tallies(RawTallies)
{
public function new()
{
this = {
combo: 0,
missed: 0,
shit: 0,
bad: 0,
good: 0,
sick: 0,
totalNotes: 0,
maxCombo: 0
}
}
}
typedef RawTallies =
{
var combo:Int;
var missed:Int;
var shit:Int;
var bad:Int;
var good:Int;
var sick:Int;
var maxCombo:Int;
var totalNotes:Int;
}

View file

@ -18,6 +18,7 @@ import flixel.ui.FlxBar;
import flixel.util.FlxColor;
import flixel.util.FlxSort;
import flixel.util.FlxTimer;
import funkin.Highscore.Tallies;
import funkin.Note;
import funkin.Note;
import funkin.Section.SwagSection;
@ -261,7 +262,7 @@ class PlayState extends MusicBeatState implements IHook
private var camZooming:Bool = false;
private var gfSpeed:Int = 1;
private var combo:Int = 0;
// private var combo:Int = 0;
private var generatedMusic:Bool = false;
private var startingSong:Bool = false;
@ -822,6 +823,9 @@ class PlayState extends MusicBeatState implements IHook
function regenNoteData():Void
{
// resets combo, should prob put somewhere else!
Highscore.tallies.combo = 0;
Highscore.tallies = new Tallies();
// make unspawn notes shit def empty
inactiveNotes = [];
@ -1316,12 +1320,12 @@ class PlayState extends MusicBeatState implements IHook
{
// Girlfriend gets sad if you combo break after hitting 5 notes.
if (currentStage != null && currentStage.getGirlfriend() != null)
if (combo > 5 && currentStage.getGirlfriend().hasAnimation('sad'))
if (Highscore.tallies.combo > 5 && currentStage.getGirlfriend().hasAnimation('sad'))
currentStage.getGirlfriend().playAnimation('sad');
if (combo != 0)
if (Highscore.tallies.combo != 0)
{
combo = comboPopUps.displayCombo(0);
Highscore.tallies.combo = comboPopUps.displayCombo(0);
}
}
@ -1440,7 +1444,10 @@ class PlayState extends MusicBeatState implements IHook
{
trace('WENT BACK TO FREEPLAY??');
// unloadAssets();
FlxG.switchState(new FreeplayState());
var res:ResultState = new ResultState();
res.camera = camHUD;
openSubState(res);
// FlxG.switchState(new FreeplayState());
}
}
@ -1462,18 +1469,21 @@ class PlayState extends MusicBeatState implements IHook
{
healthMulti *= 0; // no health on shit note
daRating = 'shit';
Highscore.tallies.shit += 1;
score = 50;
}
else if (noteDiff > Note.HIT_WINDOW * Note.GOOD_THRESHOLD)
{
healthMulti *= 0.2;
daRating = 'bad';
Highscore.tallies.bad += 1;
score = 100;
}
else if (noteDiff > Note.HIT_WINDOW * Note.SICK_THRESHOLD)
{
healthMulti *= 0.78;
daRating = 'good';
Highscore.tallies.good += 1;
score = 200;
}
else
@ -1483,6 +1493,8 @@ class PlayState extends MusicBeatState implements IHook
if (isSick)
{
Highscore.tallies.sick += 1;
var noteSplash:NoteSplash = grpNoteSplashes.recycle(NoteSplash);
noteSplash.setupNoteSplash(daNote.x, daNote.y, daNote.data.noteData);
// new NoteSplash(daNote.x, daNote.y, daNote.noteData);
@ -1495,8 +1507,8 @@ class PlayState extends MusicBeatState implements IHook
comboPopUps.displayRating(daRating);
if (combo >= 10 || combo == 0)
comboPopUps.displayCombo(combo);
if (Highscore.tallies.combo >= 10 || Highscore.tallies.combo == 0)
comboPopUps.displayCombo(Highscore.tallies.combo);
}
function controlCamera()
@ -1725,7 +1737,11 @@ class PlayState extends MusicBeatState implements IHook
if (!note.isSustainNote)
{
combo += 1;
Highscore.tallies.combo += 1;
if (Highscore.tallies.combo > Highscore.tallies.maxCombo)
Highscore.tallies.maxCombo = Highscore.tallies.combo;
popUpScore(note.data.strumTime, note);
}
@ -1812,14 +1828,14 @@ class PlayState extends MusicBeatState implements IHook
var shouldShowComboText:Bool = (curBeat % 8 == 7) // End of measure. TODO: Is this always the correct time?
&& (SongLoad.getSong()[Std.int(curStep / 16)].mustHitSection) // Current section is BF's.
&& (combo > 5) // Don't want to show on small combos.
&& (Highscore.tallies.combo > 5) // Don't want to show on small combos.
&& ((SongLoad.getSong().length < Std.int(curStep / 16)) // Show at the end of the song.
|| (!SongLoad.getSong()[Std.int(curStep / 16) + 1].mustHitSection) // Or when the next section is Dad's.
);
if (shouldShowComboText)
{
var animShit:ComboCounter = new ComboCounter(-100, 300, combo);
var animShit:ComboCounter = new ComboCounter(-100, 300, Highscore.tallies.combo);
animShit.scrollFactor.set(0.6, 0.6);
add(animShit);

View file

@ -0,0 +1,40 @@
package funkin.play;
import flixel.FlxSprite;
import flixel.text.FlxText;
class ResultState extends MusicBeatSubstate
{
override function create()
{
var bg:FlxSprite = new FlxSprite().makeGraphic(FlxG.width, FlxG.height, 0xFF000000);
bg.scrollFactor.set();
add(bg);
var results:FlxText = new FlxText(0, 0, 0, "RESULTS:", 32);
results.text += "\nMISSED: ";
results.text += Highscore.tallies.missed;
results.text += "\nSHIT: ";
results.text += Highscore.tallies.shit;
results.text += "\nBAD: ";
results.text += Highscore.tallies.bad;
results.text += "\nGOOD: ";
results.text += Highscore.tallies.good;
results.text += "\nSICK: ";
results.text += Highscore.tallies.sick;
results.text += "\nMAX COMBO: ";
results.text += Highscore.tallies.maxCombo;
add(results);
results.scrollFactor.set();
super.create();
}
override function update(elapsed:Float)
{
if (controls.PAUSE)
FlxG.switchState(new FreeplayState());
super.update(elapsed);
}
}