From 7766ddf9bd6752955184839e690a37021de515ae Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Wed, 24 Mar 2021 22:41:41 -0400 Subject: [PATCH] camera movement lerp fix for high framerates --- source/PlayState.hx | 111 +++++++++++++++++++++++--------------------- 1 file changed, 57 insertions(+), 54 deletions(-) diff --git a/source/PlayState.hx b/source/PlayState.hx index 2d6afdda2..9790aceff 100644 --- a/source/PlayState.hx +++ b/source/PlayState.hx @@ -1387,6 +1387,9 @@ class PlayState extends MusicBeatState override public function update(elapsed:Float) { + // makes the lerp non-dependant on the framerate + FlxG.camera.followLerp = 0.04 * (elapsed / (1 / 60)); + #if !debug perfectMode = false; #end @@ -1519,60 +1522,7 @@ class PlayState extends MusicBeatState if (generatedMusic && PlayState.SONG.notes[Std.int(curStep / 16)] != null) { - if (curBeat % 4 == 0) - { - // trace(PlayState.SONG.notes[Std.int(curStep / 16)].mustHitSection); - } - - if (camFollow.x != dad.getMidpoint().x + 150 && !PlayState.SONG.notes[Std.int(curStep / 16)].mustHitSection) - { - camFollow.setPosition(dad.getMidpoint().x + 150, dad.getMidpoint().y - 100); - // camFollow.setPosition(lucky.getMidpoint().x - 120, lucky.getMidpoint().y + 210); - - switch (dad.curCharacter) - { - case 'mom': - camFollow.y = dad.getMidpoint().y; - case 'senpai': - camFollow.y = dad.getMidpoint().y - 430; - camFollow.x = dad.getMidpoint().x - 100; - case 'senpai-angry': - camFollow.y = dad.getMidpoint().y - 430; - camFollow.x = dad.getMidpoint().x - 100; - } - - if (dad.curCharacter == 'mom') - vocals.volume = 1; - - if (SONG.song.toLowerCase() == 'tutorial') - { - tweenCamIn(); - } - } - - if (PlayState.SONG.notes[Std.int(curStep / 16)].mustHitSection && camFollow.x != boyfriend.getMidpoint().x - 100) - { - camFollow.setPosition(boyfriend.getMidpoint().x - 100, boyfriend.getMidpoint().y - 100); - - switch (curStage) - { - case 'limo': - camFollow.x = boyfriend.getMidpoint().x - 300; - case 'mall': - camFollow.y = boyfriend.getMidpoint().y - 200; - case 'school': - camFollow.x = boyfriend.getMidpoint().x - 200; - camFollow.y = boyfriend.getMidpoint().y - 200; - case 'schoolEvil': - camFollow.x = boyfriend.getMidpoint().x - 200; - camFollow.y = boyfriend.getMidpoint().y - 200; - } - - if (SONG.song.toLowerCase() == 'tutorial') - { - FlxTween.tween(FlxG.camera, {zoom: 1}, (Conductor.stepCrochet * 4 / 1000), {ease: FlxEase.elasticInOut}); - } - } + cameraMovement(); } if (camZooming) @@ -1994,6 +1944,59 @@ class PlayState extends MusicBeatState curSection += 1; } + function cameraMovement() + { + if (camFollow.x != dad.getMidpoint().x + 150 && !PlayState.SONG.notes[Std.int(curStep / 16)].mustHitSection) + { + camFollow.setPosition(dad.getMidpoint().x + 150, dad.getMidpoint().y - 100); + // camFollow.setPosition(lucky.getMidpoint().x - 120, lucky.getMidpoint().y + 210); + + switch (dad.curCharacter) + { + case 'mom': + camFollow.y = dad.getMidpoint().y; + case 'senpai': + camFollow.y = dad.getMidpoint().y - 430; + camFollow.x = dad.getMidpoint().x - 100; + case 'senpai-angry': + camFollow.y = dad.getMidpoint().y - 430; + camFollow.x = dad.getMidpoint().x - 100; + } + + if (dad.curCharacter == 'mom') + vocals.volume = 1; + + if (SONG.song.toLowerCase() == 'tutorial') + { + tweenCamIn(); + } + } + + if (PlayState.SONG.notes[Std.int(curStep / 16)].mustHitSection && camFollow.x != boyfriend.getMidpoint().x - 100) + { + camFollow.setPosition(boyfriend.getMidpoint().x - 100, boyfriend.getMidpoint().y - 100); + + switch (curStage) + { + case 'limo': + camFollow.x = boyfriend.getMidpoint().x - 300; + case 'mall': + camFollow.y = boyfriend.getMidpoint().y - 200; + case 'school': + camFollow.x = boyfriend.getMidpoint().x - 200; + camFollow.y = boyfriend.getMidpoint().y - 200; + case 'schoolEvil': + camFollow.x = boyfriend.getMidpoint().x - 200; + camFollow.y = boyfriend.getMidpoint().y - 200; + } + + if (SONG.song.toLowerCase() == 'tutorial') + { + FlxTween.tween(FlxG.camera, {zoom: 1}, (Conductor.stepCrochet * 4 / 1000), {ease: FlxEase.elasticInOut}); + } + } + } + private function keyShit():Void { // HOLDING