Funkin/source/MusicBeatState.hx

54 lines
1.1 KiB
Haxe
Raw Normal View History

package;
import flixel.addons.transition.FlxTransitionableState;
class MusicBeatState extends FlxTransitionableState
{
private var lastBeat:Float = 0;
private var lastStep:Float = 0;
private var totalBeats:Int = 0;
private var totalSteps:Int = 0;
override function create()
{
super.create();
}
private function everyBeat():Void
{
if (Conductor.songPosition > lastBeat + Conductor.crochet - Conductor.safeZoneOffset
|| Conductor.songPosition < lastBeat + Conductor.safeZoneOffset)
{
if (Conductor.songPosition > lastBeat + Conductor.crochet)
{
beatHit();
}
}
}
private function everyStep():Void
{
if (Conductor.songPosition > lastStep + Conductor.stepCrochet - Conductor.safeZoneOffset
|| Conductor.songPosition < lastStep + Conductor.safeZoneOffset)
{
if (Conductor.songPosition > lastStep + Conductor.stepCrochet)
{
stepHit();
}
}
}
public function stepHit():Void
{
totalSteps += 1;
lastStep += Conductor.stepCrochet;
}
public function beatHit():Void
{
lastBeat += Conductor.crochet;
totalBeats += 1;
}
}