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 d115ef59a8
commit 9d8211186b
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
}
}

View File

@ -14,9 +14,6 @@ class MusicBeatSubstate extends FlxSubState
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;
@ -39,11 +36,11 @@ class MusicBeatSubstate extends FlxSubState
var oldStep:Int = curStep;
updateCurStep();
curBeat = Math.floor(curStep / 4);
if (oldStep != curStep && curStep > 0)
stepHit();
curBeat = Math.floor(curStep / 4);
super.update(elapsed);
}
@ -66,16 +63,12 @@ class MusicBeatSubstate extends FlxSubState
public function stepHit():Void
{
totalSteps += 1;
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
}
}

View File

@ -1446,13 +1446,13 @@ class PlayState extends MusicBeatState
camHUD.zoom = FlxMath.lerp(1, camHUD.zoom, 0.95);
}
FlxG.watch.addQuick("beatShit", totalBeats);
FlxG.watch.addQuick("stepShit", totalSteps);
FlxG.watch.addQuick("beatShit", curBeat);
FlxG.watch.addQuick("stepShit", curStep);
if (curSong == 'Fresh')
{
switch (totalBeats)
switch (curBeat)
{
case 16:
camZooming = true;
@ -1471,7 +1471,7 @@ class PlayState extends MusicBeatState
if (curSong == 'Bopeebo')
{
switch (totalBeats)
switch (curBeat)
{
case 128, 129, 130:
vocals.volume = 0;
@ -2240,6 +2240,7 @@ class PlayState extends MusicBeatState
override function stepHit()
{
super.stepHit();
if (SONG.needsVoices)
{
if (vocals.time > Conductor.songPosition + 20 || vocals.time < Conductor.songPosition - 20)
@ -2248,12 +2249,10 @@ class PlayState extends MusicBeatState
}
}
if (dad.curCharacter == 'spooky' && totalSteps % 4 == 2)
if (dad.curCharacter == 'spooky' && curStep % 4 == 2)
{
// dad.dance();
}
super.stepHit();
}
var lightningStrikeBeat:Int = 0;
@ -2292,7 +2291,7 @@ class PlayState extends MusicBeatState
camHUD.zoom += 0.03;
}
if (camZooming && FlxG.camera.zoom < 1.35 && totalBeats % 4 == 0)
if (camZooming && FlxG.camera.zoom < 1.35 && curBeat % 4 == 0)
{
FlxG.camera.zoom += 0.015;
camHUD.zoom += 0.03;
@ -2304,7 +2303,7 @@ class PlayState extends MusicBeatState
iconP1.updateHitbox();
iconP2.updateHitbox();
if (totalBeats % gfSpeed == 0)
if (curBeat % gfSpeed == 0)
{
gf.dance();
}
@ -2314,7 +2313,7 @@ class PlayState extends MusicBeatState
boyfriend.playAnim('idle');
}
if (totalBeats % 8 == 7 && curSong == 'Bopeebo')
if (curBeat % 8 == 7 && curSong == 'Bopeebo')
{
boyfriend.playAnim('hey', true);
@ -2346,7 +2345,7 @@ class PlayState extends MusicBeatState
if (!trainMoving)
trainCooldown += 1;
if (totalBeats % 4 == 0)
if (curBeat % 4 == 0)
{
phillyCityLights.forEach(function(light:FlxSprite)
{
@ -2359,7 +2358,7 @@ class PlayState extends MusicBeatState
// phillyCityLights.members[curLight].alpha = 1;
}
if (totalBeats % 8 == 4 && FlxG.random.bool(30) && !trainMoving && trainCooldown > 8)
if (curBeat % 8 == 4 && FlxG.random.bool(30) && !trainMoving && trainCooldown > 8)
{
trainCooldown = FlxG.random.int(-4, 0);
trainStart();