From 22197cfb0d8c59e426830ecb789e2c9bc7a149ad Mon Sep 17 00:00:00 2001 From: Yoshman29 <81191621+YoshiCrafter29@users.noreply.github.com> Date: Sat, 12 Nov 2022 14:52:21 +0100 Subject: [PATCH] intro! --- buildnumber.txt | 2 +- source/funkin/debug/AnimationDebug.hx | 3 +- source/funkin/game/PlayState.hx | 92 ++++++++++++++----------- source/funkin/scripting/GlobalScript.hx | 1 - 4 files changed, 53 insertions(+), 45 deletions(-) diff --git a/buildnumber.txt b/buildnumber.txt index 8672b57d..1ca59347 100644 --- a/buildnumber.txt +++ b/buildnumber.txt @@ -1 +1 @@ -1284 \ No newline at end of file +1287 \ No newline at end of file diff --git a/source/funkin/debug/AnimationDebug.hx b/source/funkin/debug/AnimationDebug.hx index 4dbd738f..bb2c9c80 100644 --- a/source/funkin/debug/AnimationDebug.hx +++ b/source/funkin/debug/AnimationDebug.hx @@ -34,7 +34,8 @@ class AnimationDebug extends FlxState override function create() { - FlxG.sound.music.stop(); + if (FlxG.sound.music != null) + FlxG.sound.music.stop(); var gridBG:FlxSprite = FlxGridOverlay.create(10, 10); gridBG.scrollFactor.set(0.5, 0.5); diff --git a/source/funkin/game/PlayState.hx b/source/funkin/game/PlayState.hx index 641e9730..cd3d3f23 100644 --- a/source/funkin/game/PlayState.hx +++ b/source/funkin/game/PlayState.hx @@ -433,6 +433,8 @@ class PlayState extends MusicBeatState public var startTimer:FlxTimer; public var perfectMode:Bool = false; public var introLength:Int = 5; + public var introSprites:Array = [null, 'game/ready', "game/set", "game/go"]; + public var introSounds:Array = ['intro3', 'intro2', "intro1", "introGo"]; public function startCountdown():Void { @@ -449,8 +451,6 @@ class PlayState extends MusicBeatState var swagCounter:Int = 0; - var introSprites:Array = [null, 'game/ready', "game/set", "game/go"]; - var introSounds:Array = ['intro3', 'intro2', "intro1", "introGo"]; startTimer = new FlxTimer().start(Conductor.crochet / 1000, function(tmr:FlxTimer) { @@ -458,51 +458,59 @@ class PlayState extends MusicBeatState gf.dance(); boyfriend.dance(); - var event:CountdownEvent = scripts.event("onCountdown", new CountdownEvent( - swagCounter, - introSprites[swagCounter], - introSounds[swagCounter], - 1, 0.6, true)); + countdown(swagCounter); - var sprite:FlxSprite = null; - var sound:FlxSound = null; - var tween:FlxTween = null; - - if (!event.cancelled) { - if (event.spritePath != null) { - var spr = event.spritePath; - if (!Assets.exists(spr)) spr = Paths.image('$spr'); - - sprite = new FlxSprite().loadGraphic(spr); - sprite.scrollFactor.set(); - sprite.scale.set(event.scale, event.scale); - sprite.updateHitbox(); - sprite.screenCenter(); - add(sprite); - tween = FlxTween.tween(sprite, {y: sprite.y + 100, alpha: 0}, Conductor.crochet / 1000, { - ease: FlxEase.cubeInOut, - onComplete: function(twn:FlxTween) - { - sprite.destroy(); - } - }); - } - if (event.soundPath != null) { - var sfx = event.soundPath; - if (!Assets.exists(sfx)) sfx = Paths.sound(sfx); - sound = FlxG.sound.play(sfx, event.volume); - } - } - event.sprite = sprite; - event.sound = sound; - event.spriteTween = tween; - event.cancelled = false; - - scripts.event("onCountdownPost", event); swagCounter += 1; }, introLength); } + /** + * Creates a fake countdown. + */ + public function countdown(swagCounter:Int) { + var event:CountdownEvent = scripts.event("onCountdown", new CountdownEvent( + swagCounter, + introSprites[swagCounter], + introSounds[swagCounter], + 1, 0.6, true)); + + var sprite:FlxSprite = null; + var sound:FlxSound = null; + var tween:FlxTween = null; + + if (!event.cancelled) { + if (event.spritePath != null) { + var spr = event.spritePath; + if (!Assets.exists(spr)) spr = Paths.image('$spr'); + + sprite = new FlxSprite().loadGraphic(spr); + sprite.scrollFactor.set(); + sprite.scale.set(event.scale, event.scale); + sprite.updateHitbox(); + sprite.screenCenter(); + add(sprite); + tween = FlxTween.tween(sprite, {y: sprite.y + 100, alpha: 0}, Conductor.crochet / 1000, { + ease: FlxEase.cubeInOut, + onComplete: function(twn:FlxTween) + { + sprite.destroy(); + } + }); + } + if (event.soundPath != null) { + var sfx = event.soundPath; + if (!Assets.exists(sfx)) sfx = Paths.sound(sfx); + sound = FlxG.sound.play(sfx, event.volume); + } + } + event.sprite = sprite; + event.sound = sound; + event.spriteTween = tween; + event.cancelled = false; + + scripts.event("onCountdownPost", event); + } + public var previousFrameTime:Int = 0; public var lastReportedPlayheadPosition:Int = 0; public var songTime:Float = 0; diff --git a/source/funkin/scripting/GlobalScript.hx b/source/funkin/scripting/GlobalScript.hx index 78bbc3c1..3cc7ebcc 100644 --- a/source/funkin/scripting/GlobalScript.hx +++ b/source/funkin/scripting/GlobalScript.hx @@ -86,7 +86,6 @@ class GlobalScript { script.call(name, args); } public static function onModSwitch(newMod:String) { - trace(newMod); if (script != null) { script.destroy(); script = null;