entirely phase out totalBeats/totalSteps in favor of the more reliable curStep/curBeat

This commit is contained in:
MtH
2021-02-12 03:19:27 +01:00
parent 7d0f5c4045
commit e4f17360b6
3 changed files with 17 additions and 40 deletions

View File

@ -12,9 +12,6 @@ class MusicBeatState extends FlxUIState
private var lastBeat:Float = 0;
private var lastStep:Float = 0;
private var totalBeats:Int = 0;
private var totalSteps:Int = 0;
private var curStep:Int = 0;
private var curBeat:Int = 0;
private var controls(get, never):Controls;
@ -40,12 +37,11 @@ class MusicBeatState extends FlxUIState
var oldStep:Int = curStep;
updateCurStep();
updateBeat();
if (oldStep != curStep && curStep > 0)
stepHit();
updateBeat();
super.update(elapsed);
}
@ -72,23 +68,12 @@ class MusicBeatState extends FlxUIState
public function stepHit():Void
{
totalSteps += 1;
lastStep += Conductor.stepCrochet;
// If the song is at least 3 steps behind
if (Conductor.songPosition > lastStep + (Conductor.stepCrochet * 3))
{
lastStep = Conductor.songPosition;
totalSteps = Math.ceil(lastStep / Conductor.stepCrochet);
}
if (totalSteps % 4 == 0)
if (curStep % 4 == 0)
beatHit();
}
public function beatHit():Void
{
lastBeat += Conductor.crochet;
totalBeats += 1;
//do literally nothing dumbass
}
}