From c60bd8b12f11eea9995afa61bbefe7b7ea765022 Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Sun, 18 Apr 2021 16:54:21 -0400 Subject: [PATCH] optimiiiizeeee --- source/PlayState.hx | 147 ++++++++++++++++++++++---------------------- source/TankmenBG.hx | 5 ++ 2 files changed, 79 insertions(+), 73 deletions(-) diff --git a/source/PlayState.hx b/source/PlayState.hx index 79eb75c2f..ee584215f 100644 --- a/source/PlayState.hx +++ b/source/PlayState.hx @@ -649,15 +649,15 @@ class PlayState extends MusicBeatState gf.x -= 50; gf.y -= 200; + var tempTankman:TankmenBG = new TankmenBG(20, 500, true); + tempTankman.strumTime = 10; + tempTankman.resetShit(20, 600, true); + tankmanRun.add(tempTankman); + for (i in 0...TankmenBG.animationNotes.length) { if (FlxG.random.bool(16)) { - var tempTankman:TankmenBG = new TankmenBG(20, 500, true); - tempTankman.strumTime = 10; - tempTankman.resetShit(20, 600, true); - tankmanRun.add(tempTankman); - var tankman:TankmenBG = tankmanRun.recycle(TankmenBG); // new TankmenBG(500, 200 + FlxG.random.int(50, 100), TankmenBG.animationNotes[i][1] < 2); tankman.strumTime = TankmenBG.animationNotes[i][0]; @@ -957,86 +957,87 @@ class PlayState extends MusicBeatState function ughIntro() { inCutscene = true; + /* + var blackShit:FlxSprite = new FlxSprite(-200, -200).makeGraphic(FlxG.width * 2, FlxG.height * 2, FlxColor.BLACK); + blackShit.scrollFactor.set(); + add(blackShit); - var blackShit:FlxSprite = new FlxSprite(-200, -200).makeGraphic(FlxG.width * 2, FlxG.height * 2, FlxColor.BLACK); - blackShit.scrollFactor.set(); - add(blackShit); + var vid:FlxVideo = new FlxVideo('music/ughCutscene.mp4'); + vid.finishCallback = function() + { + remove(blackShit); + FlxTween.tween(FlxG.camera, {zoom: defaultCamZoom}, (Conductor.crochet / 1000) * 5, {ease: FlxEase.quadInOut}); + startCountdown(); + cameraMovement(); + }; - var vid:FlxVideo = new FlxVideo('music/ughCutscene.mp4'); - vid.finishCallback = function() - { - remove(blackShit); - FlxTween.tween(FlxG.camera, {zoom: defaultCamZoom}, (Conductor.crochet / 1000) * 5, {ease: FlxEase.quadInOut}); - startCountdown(); - cameraMovement(); - }; + FlxG.camera.zoom = defaultCamZoom * 1.2; - FlxG.camera.zoom = defaultCamZoom * 1.2; + camFollow.x += 100; + camFollow.y += 100; + */ - camFollow.x += 100; + FlxG.sound.playMusic(Paths.music('DISTORTO'), 0); + FlxG.sound.music.fadeIn(5, 0, 0.5); + + dad.visible = false; + var tankCutscene:TankCutscene = new TankCutscene(-20, 320); + tankCutscene.frames = Paths.getSparrowAtlas('cutsceneStuff/tankTalkSong1'); + tankCutscene.animation.addByPrefix('wellWell', 'TANK TALK 1 P1', 24, false); + tankCutscene.animation.addByPrefix('killYou', 'TANK TALK 1 P2', 24, false); + tankCutscene.animation.play('wellWell'); + tankCutscene.antialiasing = true; + gfCutsceneLayer.add(tankCutscene); + + camHUD.visible = false; + + FlxG.camera.zoom *= 1.2; camFollow.y += 100; - /* FlxG.sound.playMusic(Paths.music('DISTORTO'), 0); - FlxG.sound.music.fadeIn(5, 0, 0.5); + tankCutscene.startSyncAudio = FlxG.sound.load(Paths.sound('wellWellWell')); - dad.visible = false; - var tankCutscene:TankCutscene = new TankCutscene(-20, 320); - tankCutscene.frames = Paths.getSparrowAtlas('cutsceneStuff/tankTalkSong1'); - tankCutscene.animation.addByPrefix('wellWell', 'TANK TALK 1 P1', 24, false); - tankCutscene.animation.addByPrefix('killYou', 'TANK TALK 1 P2', 24, false); - tankCutscene.animation.play('wellWell'); - tankCutscene.antialiasing = true; - gfCutsceneLayer.add(tankCutscene); - - camHUD.visible = false; - - FlxG.camera.zoom *= 1.2; + new FlxTimer().start(3, function(tmr:FlxTimer) + { + camFollow.x += 800; camFollow.y += 100; + FlxTween.tween(FlxG.camera, {zoom: defaultCamZoom * 1.2}, 0.27, {ease: FlxEase.quadInOut}); - tankCutscene.startSyncAudio = FlxG.sound.load(Paths.sound('wellWellWell')); - - new FlxTimer().start(3, function(tmr:FlxTimer) + new FlxTimer().start(1.5, function(bep:FlxTimer) { - camFollow.x += 800; - camFollow.y += 100; - FlxTween.tween(FlxG.camera, {zoom: defaultCamZoom * 1.2}, 0.27, {ease: FlxEase.quadInOut}); - - new FlxTimer().start(1.5, function(bep:FlxTimer) + boyfriend.playAnim('singUP'); + // play sound + FlxG.sound.play(Paths.sound('bfBeep'), function() { - boyfriend.playAnim('singUP'); - // play sound - FlxG.sound.play(Paths.sound('bfBeep'), function() - { - boyfriend.playAnim('idle'); - }); + boyfriend.playAnim('idle'); }); + }); - new FlxTimer().start(3, function(swaggy:FlxTimer) + new FlxTimer().start(3, function(swaggy:FlxTimer) + { + camFollow.x -= 800; + camFollow.y -= 100; + FlxTween.tween(FlxG.camera, {zoom: defaultCamZoom * 1.2}, 0.5, {ease: FlxEase.quadInOut}); + tankCutscene.animation.play('killYou'); + FlxG.sound.play(Paths.sound('killYou')); + new FlxTimer().start(6.1, function(swagasdga:FlxTimer) { - camFollow.x -= 800; - camFollow.y -= 100; - FlxTween.tween(FlxG.camera, {zoom: defaultCamZoom * 1.2}, 0.5, {ease: FlxEase.quadInOut}); - tankCutscene.animation.play('killYou'); - FlxG.sound.play(Paths.sound('killYou')); - new FlxTimer().start(6.1, function(swagasdga:FlxTimer) + FlxTween.tween(FlxG.camera, {zoom: defaultCamZoom}, (Conductor.crochet / 1000) * 5, {ease: FlxEase.quadInOut}); + + FlxG.sound.music.fadeOut((Conductor.crochet / 1000) * 5, 0); + + new FlxTimer().start((Conductor.crochet / 1000) * 5, function(money:FlxTimer) { - FlxTween.tween(FlxG.camera, {zoom: defaultCamZoom}, (Conductor.crochet / 1000) * 5, {ease: FlxEase.quadInOut}); - - FlxG.sound.music.fadeOut((Conductor.crochet / 1000) * 5, 0); - - new FlxTimer().start((Conductor.crochet / 1000) * 5, function(money:FlxTimer) - { - dad.visible = true; - gfCutsceneLayer.remove(tankCutscene); - }); - - cameraMovement(); - - startCountdown(); - camHUD.visible = true; + dad.visible = true; + gfCutsceneLayer.remove(tankCutscene); }); + + cameraMovement(); + + startCountdown(); + camHUD.visible = true; }); - });*/ + }); + }); } function gunsIntro() @@ -1935,7 +1936,7 @@ class PlayState extends MusicBeatState vocals.pause(); FlxG.sound.music.play(); - Conductor.songPosition = FlxG.sound.music.time; + Conductor.songPosition = FlxG.sound.music.time + Conductor.offset; if (vocalsFinished) return; @@ -1972,8 +1973,8 @@ class PlayState extends MusicBeatState } else { - // Conductor.songPosition = FlxG.sound.music.time; - Conductor.songPosition += FlxG.elapsed * 1000; + Conductor.songPosition = FlxG.sound.music.time + Conductor.offset; // 20 is THE MILLISECONDS?? + // Conductor.songPosition += FlxG.elapsed * 1000; if (!paused) { @@ -2977,8 +2978,8 @@ class PlayState extends MusicBeatState override function stepHit() { super.stepHit(); - if (Math.abs(FlxG.sound.music.time - Conductor.songPosition) > 20 - || (SONG.needsVoices && Math.abs(vocals.time - Conductor.songPosition) > 20)) + if (Math.abs(FlxG.sound.music.time - (Conductor.songPosition - Conductor.offset)) > 20 + || (SONG.needsVoices && Math.abs(vocals.time - (Conductor.songPosition - Conductor.offset)) > 20)) { resyncVocals(); } diff --git a/source/TankmenBG.hx b/source/TankmenBG.hx index 37c56f061..b08c1473d 100644 --- a/source/TankmenBG.hx +++ b/source/TankmenBG.hx @@ -49,6 +49,11 @@ class TankmenBG extends FlxSprite { super.update(elapsed); + if (x >= FlxG.width * 1.2 || x <= FlxG.width * -0.5) + visible = false; + else + visible = true; + if (animation.curAnim.name == 'run') { var endDirection:Float = (FlxG.width * 0.74) + endingOffset;