Skip to content

Commit

Permalink
entirely phase out totalBeats/totalSteps in favor of the more reliabl…
Browse files Browse the repository at this point in the history
…e curStep/curBeat
  • Loading branch information
PrincessMtH committed Feb 12, 2021
1 parent d115ef5 commit 9d82111
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 40 deletions.
21 changes: 3 additions & 18 deletions source/MusicBeatState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -40,12 +37,11 @@ class MusicBeatState extends FlxUIState
var oldStep:Int = curStep;

updateCurStep();
updateBeat();

if (oldStep != curStep && curStep > 0)
stepHit();

updateBeat();

super.update(elapsed);
}

Expand All @@ -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
}
}
13 changes: 3 additions & 10 deletions source/MusicBeatSubstate.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}
Expand All @@ -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
}
}
23 changes: 11 additions & 12 deletions source/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -1471,7 +1471,7 @@ class PlayState extends MusicBeatState

if (curSong == 'Bopeebo')
{
switch (totalBeats)
switch (curBeat)
{
case 128, 129, 130:
vocals.volume = 0;
Expand Down Expand Up @@ -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)
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -2304,7 +2303,7 @@ class PlayState extends MusicBeatState
iconP1.updateHitbox();
iconP2.updateHitbox();

if (totalBeats % gfSpeed == 0)
if (curBeat % gfSpeed == 0)
{
gf.dance();
}
Expand All @@ -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);

Expand Down Expand Up @@ -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)
{
Expand All @@ -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();
Expand Down

0 comments on commit 9d82111

Please sign in to comment.