From 5778e979d989547492c900d783b6aa4cebfd290f Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Mon, 11 Jul 2022 15:14:59 -0400 Subject: [PATCH] lil fix for end number hehe --- source/funkin/LatencyState.hx | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/source/funkin/LatencyState.hx b/source/funkin/LatencyState.hx index 79885d1bd..713601057 100644 --- a/source/funkin/LatencyState.hx +++ b/source/funkin/LatencyState.hx @@ -25,6 +25,7 @@ class LatencyState extends MusicBeatSubstate var beatTrail:FlxSprite; var diffGrp:FlxTypedGroup; + var offsetsPerBeat:Array = []; override function create() { @@ -61,6 +62,8 @@ class LatencyState extends MusicBeatSubstate var offsetTxt:FlxText = new FlxText(songPosToX(beat * Conductor.crochet), FlxG.height - 26, 0, "swag"); offsetTxt.alpha = 0.5; diffGrp.add(offsetTxt); + + offsetsPerBeat.push(0); } songVisFollowAudio = new FlxSprite(0, FlxG.height - 20).makeGraphic(2, 20, FlxColor.YELLOW); @@ -129,11 +132,16 @@ class LatencyState extends MusicBeatSubstate var getDiff:Float = Conductor.songPosition - (closestBeat * Conductor.crochet); getDiff -= Conductor.visualOffset; + // lil fix for end of song + if (closestBeat == 0 && getDiff >= Conductor.crochet * 2) + getDiff -= FlxG.sound.music.length; + trace("\tDISTANCE TO CLOSEST BEAT: " + getDiff + "ms"); trace("\tCLOSEST BEAT: " + closestBeat); beatTrail.x = songPosVis.x; - if (closestBeat < FlxG.sound.music.length / Conductor.crochet) - diffGrp.members[closestBeat].text = getDiff + "ms"; + + diffGrp.members[closestBeat].text = getDiff + "ms"; + offsetsPerBeat[closestBeat] = Std.int(getDiff); } if (FlxG.keys.justPressed.SPACE) @@ -158,6 +166,15 @@ class LatencyState extends MusicBeatSubstate offsetText.text += "\ncurStep: " + curStep; offsetText.text += "\ncurBeat: " + curBeat; + var avgOffsetInput:Float = 0; + + for (offsetThing in offsetsPerBeat) + avgOffsetInput += offsetThing; + + avgOffsetInput /= offsetsPerBeat.length; + + offsetText.text += "\naverage input offset needed: " + avgOffsetInput; + var multiply:Float = 10; if (FlxG.keys.pressed.SHIFT)