From cb0ebfdbe1c2ba437f5c9f16fd6b56b25f61ae8a Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Sat, 21 Nov 2020 02:43:04 -0800 Subject: [PATCH] MAYBE DOIN CHART SHIT? --- source/ChartingState.hx | 24 ++++++++++++++++++++++++ source/MusicBeatState.hx | 7 ++++++- source/TitleState.hx | 2 +- 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/source/ChartingState.hx b/source/ChartingState.hx index 08e16730e..f83eae315 100644 --- a/source/ChartingState.hx +++ b/source/ChartingState.hx @@ -384,6 +384,8 @@ class ChartingState extends MusicBeatState override function update(elapsed:Float) { + curStep = recalculateSteps(); + Conductor.songPosition = FlxG.sound.music.time; _song.song = typingShit.text; @@ -520,6 +522,28 @@ class ChartingState extends MusicBeatState super.update(elapsed); } + function recalculateSteps():Int + { + var steps:Int = 0; + var timeShit:Float = 0; + + for (i in 0...curSection) + { + steps += 16; + + if (_song.notes[i].changeBPM) + timeShit += (((60 / _song.notes[i].bpm) * 1000) / 4) * 16; + else + timeShit += (((60 / _song.bpm) * 1000) / 4) * 16; + } + + steps += Math.floor((FlxG.sound.music.time - timeShit) / Conductor.stepCrochet); + curStep = steps; + updateBeat(); + + return curStep; + } + function changeSection(sec:Int = 0, ?updateMusic:Bool = true):Void { trace('changing section' + sec); diff --git a/source/MusicBeatState.hx b/source/MusicBeatState.hx index 029a495b8..0d3862002 100644 --- a/source/MusicBeatState.hx +++ b/source/MusicBeatState.hx @@ -35,11 +35,16 @@ class MusicBeatState extends FlxUIState updateCurStep(); // Needs to be ROUNED, rather than ceil or floor - curBeat = Math.round(curStep / 4); + updateBeat(); super.update(elapsed); } + private function updateBeat():Void + { + curBeat = Math.round(curStep / 4); + } + /** * CHECKS EVERY FRAME */ diff --git a/source/TitleState.hx b/source/TitleState.hx index f93f061ec..f2f1fff33 100644 --- a/source/TitleState.hx +++ b/source/TitleState.hx @@ -68,7 +68,7 @@ class TitleState extends MusicBeatState } #if SKIP_TO_PLAYSTATE - FlxG.switchState(new FreeplayState()); + FlxG.switchState(new ChartingState()); #else startIntro(); #end