From 69e51cb635e7e38b1871bda581417ae6d1822f18 Mon Sep 17 00:00:00 2001 From: MtH Date: Wed, 17 Mar 2021 18:33:26 +0100 Subject: [PATCH] mitigate countdown dancing issues (might still fuck up on higher bpm) --- source/MusicBeatState.hx | 2 +- source/MusicBeatSubstate.hx | 2 +- source/PlayState.hx | 80 +++++++++++++++++++++---------------- 3 files changed, 47 insertions(+), 37 deletions(-) diff --git a/source/MusicBeatState.hx b/source/MusicBeatState.hx index 88c58a624..1c7359798 100644 --- a/source/MusicBeatState.hx +++ b/source/MusicBeatState.hx @@ -35,7 +35,7 @@ class MusicBeatState extends FlxUIState updateCurStep(); updateBeat(); - if (oldStep != curStep && curStep > 0) + if (oldStep != curStep && curStep >= 0) stepHit(); super.update(elapsed); diff --git a/source/MusicBeatSubstate.hx b/source/MusicBeatSubstate.hx index c6da0fb59..480d6ed16 100644 --- a/source/MusicBeatSubstate.hx +++ b/source/MusicBeatSubstate.hx @@ -29,7 +29,7 @@ class MusicBeatSubstate extends FlxSubState updateCurStep(); curBeat = Math.floor(curStep / 4); - if (oldStep != curStep && curStep > 0) + if (oldStep != curStep && curStep >= 0) stepHit(); diff --git a/source/PlayState.hx b/source/PlayState.hx index baea8bf77..ce428753f 100644 --- a/source/PlayState.hx +++ b/source/PlayState.hx @@ -908,9 +908,18 @@ class PlayState extends MusicBeatState startTimer = new FlxTimer().start(Conductor.crochet / 1000, function(tmr:FlxTimer) { - dad.dance(); - gf.dance(); - boyfriend.playAnim('idle'); + // this just based on beatHit stuff but compact + if (swagCounter % gfSpeed == 0) + gf.dance(); + if (swagCounter % 2 == 0) + { + if (!boyfriend.animation.curAnim.name.startsWith("sing")) + boyfriend.playAnim('idle'); + if (!dad.animation.curAnim.name.startsWith("sing")) + dad.dance(); + } + else if (dad.curCharacter == 'spooky' && !dad.animation.curAnim.name.startsWith("sing")) + dad.dance(); var introAssets:Map> = new Map>(); introAssets.set('default', ['ready', "set", "go"]); @@ -1286,6 +1295,39 @@ class PlayState extends MusicBeatState iconP1.animation.play('bf-old'); } + // do this BEFORE super.update() so songPosition is accurate + if (startingSong) + { + if (startedCountdown) + { + Conductor.songPosition += FlxG.elapsed * 1000; + if (Conductor.songPosition >= 0) + startSong(); + } + } + else + { + // Conductor.songPosition = FlxG.sound.music.time; + Conductor.songPosition += FlxG.elapsed * 1000; + + if (!paused) + { + songTime += FlxG.game.ticks - previousFrameTime; + previousFrameTime = FlxG.game.ticks; + + // Interpolation type beat + if (Conductor.lastSongPos != Conductor.songPosition) + { + songTime = (songTime + Conductor.songPosition) / 2; + Conductor.lastSongPos = Conductor.songPosition; + // Conductor.songPosition += FlxG.elapsed * 1000; + // trace('MISSED FRAME'); + } + } + + // Conductor.lastSongPos = FlxG.sound.music.time; + } + switch (curStage) { case 'philly': @@ -1362,38 +1404,6 @@ class PlayState extends MusicBeatState FlxG.switchState(new AnimationDebug(SONG.player2)); #end - if (startingSong) - { - if (startedCountdown) - { - Conductor.songPosition += FlxG.elapsed * 1000; - if (Conductor.songPosition >= 0) - startSong(); - } - } - else - { - // Conductor.songPosition = FlxG.sound.music.time; - Conductor.songPosition += FlxG.elapsed * 1000; - - if (!paused) - { - songTime += FlxG.game.ticks - previousFrameTime; - previousFrameTime = FlxG.game.ticks; - - // Interpolation type beat - if (Conductor.lastSongPos != Conductor.songPosition) - { - songTime = (songTime + Conductor.songPosition) / 2; - Conductor.lastSongPos = Conductor.songPosition; - // Conductor.songPosition += FlxG.elapsed * 1000; - // trace('MISSED FRAME'); - } - } - - // Conductor.lastSongPos = FlxG.sound.music.time; - } - if (generatedMusic && PlayState.SONG.notes[Std.int(curStep / 16)] != null) { if (curBeat % 4 == 0)