From 1033754ad3551d4c9bcb3e46388ec87b7ff0f4cf Mon Sep 17 00:00:00 2001 From: MtH Date: Tue, 7 Sep 2021 22:14:14 +0200 Subject: [PATCH 1/6] notesplash framerate & use finishCallback instead of checking every frame --- source/NoteSplash.hx | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/source/NoteSplash.hx b/source/NoteSplash.hx index 5851be7fc..36acc86a0 100644 --- a/source/NoteSplash.hx +++ b/source/NoteSplash.hx @@ -31,17 +31,12 @@ class NoteSplash extends FlxSprite alpha = 0.6; animation.play('note' + noteData + '-' + FlxG.random.int(0, 1), true); - animation.curAnim.frameRate += FlxG.random.int(-2, 2); + animation.curAnim.frameRate = 24 + FlxG.random.int(-2, 2); + animation.finishCallback = function(name){ + kill(); + }; updateHitbox(); offset.set(width * 0.3, height * 0.3); } - - override function update(elapsed:Float) - { - if (animation.curAnim.finished) - kill(); - - super.update(elapsed); - } } From d0800fcd3954d370baa6d645e8cac734c2c4be29 Mon Sep 17 00:00:00 2001 From: MtH Date: Tue, 7 Sep 2021 23:09:34 +0200 Subject: [PATCH 2/6] titlestate spring cleaning, move shit into new initstate this is a huge ass commit so cam pls dont merge until u thoroughly check it and know what changed and moved and whatever. got rid of a lot of ludum dare era commented out shit as well. feel free to ask for clarification or add shit back if it's better suited here --- source/InitState.hx | 126 +++++++++++++++++++ source/Main.hx | 2 +- source/TitleState.hx | 292 ++++++++++--------------------------------- 3 files changed, 190 insertions(+), 230 deletions(-) create mode 100644 source/InitState.hx diff --git a/source/InitState.hx b/source/InitState.hx new file mode 100644 index 000000000..964bb1b34 --- /dev/null +++ b/source/InitState.hx @@ -0,0 +1,126 @@ +package; + +import flixel.addons.transition.FlxTransitionSprite.GraphicTransTileDiamond; +import flixel.addons.transition.FlxTransitionableState; +import flixel.addons.transition.TransitionData; +import flixel.graphics.FlxGraphic; +import flixel.math.FlxPoint; +import flixel.math.FlxRect; +import flixel.util.FlxColor; +import openfl.display.BitmapData; +import ui.PreferencesMenu; + +#if colyseus +import io.colyseus.Client; +import io.colyseus.Room; +#end +#if discord_rpc +import Discord.DiscordClient; +#end +#if desktop +import sys.FileSystem; +import sys.io.File; +import sys.thread.Thread; +#end + +using StringTools; + +class InitState extends FlxTransitionableState +{ + override public function create():Void + { + #if android + FlxG.android.preventDefaultKeys = [FlxAndroidKey.BACK]; + #end + #if newgrounds + NGio.init(); + #end + #if discord_rpc + DiscordClient.initialize(); + + Application.current.onExit.add(function(exitCode){ + DiscordClient.shutdown(); + }); + #end + + + // ==== flixel shit ==== // + + FlxG.debugger.addButton(LEFT, new BitmapData(200, 200), function(){ + FlxG.debugger.visible = false; + }); + + FlxG.sound.muteKeys = [ZERO]; + FlxG.game.focusLostFramerate = 60; + + // FlxG.stage.window.borderless = true; + // FlxG.stage.window.mouseLock = true; + + var diamond:FlxGraphic = FlxGraphic.fromClass(GraphicTransTileDiamond); + diamond.persist = true; + diamond.destroyOnNoUse = false; + + FlxTransitionableState.defaultTransIn = new TransitionData(FADE, FlxColor.BLACK, 1, new FlxPoint(0, -1), {asset: diamond, width: 32, height: 32}, + new FlxRect(-200, -200, FlxG.width * 1.4, FlxG.height * 1.4)); + FlxTransitionableState.defaultTransOut = new TransitionData(FADE, FlxColor.BLACK, 0.7, new FlxPoint(0, 1), + {asset: diamond, width: 32, height: 32}, new FlxRect(-200, -200, FlxG.width * 1.4, FlxG.height * 1.4)); + + // ===== save shit ===== // + + FlxG.save.bind('funkin', 'ninjamuffin99'); + + // https://github.com/HaxeFlixel/flixel/pull/2396 + // IF/WHEN MY PR GOES THRU AND IT GETS INTO MAIN FLIXEL, DELETE THIS CHUNKOF CODE, AND THEN UNCOMMENT THE LINE BELOW + // FlxG.sound.loadSavedPrefs(); + + if (FlxG.save.data.volume != null) + FlxG.sound.volume = FlxG.save.data.volume; + if (FlxG.save.data.mute != null) + FlxG.sound.muted = FlxG.save.data.mute; + + // FlxG.save.close(); + // FlxG.sound.loadSavedPrefs(); + PreferencesMenu.initPrefs(); + PlayerSettings.init(); + Highscore.load(); + + if (FlxG.save.data.weekUnlocked != null) + { + // FIX LATER!!! + // WEEK UNLOCK PROGRESSION!! + // StoryMenuState.weekUnlocked = FlxG.save.data.weekUnlocked; + + if (StoryMenuState.weekUnlocked.length < 4) + StoryMenuState.weekUnlocked.insert(0, true); + + // QUICK PATCH OOPS! + if (!StoryMenuState.weekUnlocked[0]) + StoryMenuState.weekUnlocked[0] = true; + } + + if (FlxG.save.data.seenVideo != null) + VideoState.seenVideo = FlxG.save.data.seenVideo; + + // ===== fuck outta here ===== // + + // FlxTransitionableState.skipNextTransOut = true; + FlxTransitionableState.skipNextTransIn = true; + + #if FREEPLAY + FlxG.switchState(new FreeplayState()); + #elseif ANIMATE + FlxG.switchState(new animate.AnimTestStage()); + #elseif CHARTING + FlxG.switchState(new ChartingState()); + #elseif STAGEBUILD + FlxG.switchState(new StageBuilderState()); + #elseif ANIMDEBUG + FlxG.switchState(new ui.animDebugShit.DebugBoundingState()); + #elseif NETTEST + FlxG.switchState(new netTest.NetTest()); + #else + FlxG.sound.cache(Paths.music('freakyMenu')); + FlxG.switchState(new TitleState()); + #end + } +} diff --git a/source/Main.hx b/source/Main.hx index a394d5dd1..7b4429484 100644 --- a/source/Main.hx +++ b/source/Main.hx @@ -19,7 +19,7 @@ class Main extends Sprite { var gameWidth:Int = 1280; // Width of the game in pixels (might be less / more in actual pixels depending on your zoom). var gameHeight:Int = 720; // Height of the game in pixels (might be less / more in actual pixels depending on your zoom). - var initialState:Class = TitleState; // The FlxState the game starts with. + var initialState:Class = InitState; // The FlxState the game starts with. var zoom:Float = -1; // If -1, zoom is automatically calculated to fit the window dimensions. #if web var framerate:Int = 60; // How many frames per second the game should run at. diff --git a/source/TitleState.hx b/source/TitleState.hx index 1dbbed244..754cf2d9c 100644 --- a/source/TitleState.hx +++ b/source/TitleState.hx @@ -1,12 +1,8 @@ package; -import flixel.FlxGame; import flixel.FlxObject; import flixel.FlxSprite; -import flixel.addons.transition.FlxTransitionSprite.GraphicTransTileDiamond; -import flixel.addons.transition.FlxTransitionableState; -import flixel.addons.transition.TransitionData; -import flixel.graphics.FlxGraphic; +import flixel.FlxState; import flixel.group.FlxGroup; import flixel.input.android.FlxAndroidKey; import flixel.input.android.FlxAndroidKeys; @@ -14,8 +10,6 @@ import flixel.input.gamepad.FlxGamepad; import flixel.input.gamepad.id.SwitchJoyconLeftID; import flixel.math.FlxPoint; import flixel.math.FlxRect; -import flixel.system.FlxAssets.FlxGraphicAsset; -import flixel.system.FlxAssets; import flixel.text.FlxText; import flixel.tweens.FlxEase; import flixel.tweens.FlxTween; @@ -26,17 +20,14 @@ import lime.graphics.Image; import lime.media.AudioContext; import lime.ui.Window; import openfl.Assets; -import openfl.display.BitmapData; import openfl.display.Sprite; import openfl.events.AsyncErrorEvent; -import openfl.events.AsyncErrorEvent; import openfl.events.Event; import openfl.events.MouseEvent; import openfl.events.NetStatusEvent; import openfl.media.Video; import openfl.net.NetConnection; import openfl.net.NetStream; -import shaderslmfao.BuildingShaders.BuildingShader; import shaderslmfao.BuildingShaders; import shaderslmfao.ColorSwap; import shaderslmfao.TitleOutline; @@ -45,13 +36,6 @@ import ui.stageBuildShit.StageBuilderState; using StringTools; -#if colyseus -import io.colyseus.Client; -import io.colyseus.Room; -#end -#if discord_rpc -import Discord.DiscordClient; -#end #if desktop import sys.FileSystem; import sys.io.File; @@ -62,20 +46,15 @@ class TitleState extends MusicBeatState { public static var initialized:Bool = false; - var startedIntro:Bool; - var blackScreen:FlxSprite; var credGroup:FlxGroup; - var credTextShit:Alphabet; var textGroup:FlxGroup; var ngSpr:FlxSprite; var curWacky:Array = []; - var wackyImage:FlxSprite; - var lastBeat:Int = 0; + var lastBeat:Int = -1; var swagShader:ColorSwap; var alphaShader:BuildingShaders; - var thingie:FlxSprite; var video:Video; var netStream:NetStream; @@ -83,24 +62,9 @@ class TitleState extends MusicBeatState override public function create():Void { - #if android - FlxG.android.preventDefaultKeys = [FlxAndroidKey.BACK]; - #end - - FlxG.debugger.addButton(LEFT, new BitmapData(200, 200), function() - { - FlxG.debugger.visible = false; - }); - - startedIntro = false; - - FlxG.game.focusLostFramerate = 60; - swagShader = new ColorSwap(); alphaShader = new BuildingShaders(); - FlxG.sound.muteKeys = [ZERO]; - curWacky = FlxG.random.getObject(getIntroTextShit()); FlxG.sound.cache(Paths.music('freakyMenu')); @@ -108,57 +72,6 @@ class TitleState extends MusicBeatState super.create(); - FlxG.save.bind('funkin', 'ninjamuffin99'); - - // https://github.com/HaxeFlixel/flixel/pull/2396 - // IF/WHEN MY PR GOES THRU AND IT GETS INTO MAIN FLIXEL, DELETE THIS CHUNKOF CODE, AND THEN UNCOMMENT THE LINE BELOW - // FlxG.sound.loadSavedPrefs(); - - if (FlxG.save.data.volume != null) - { - FlxG.sound.volume = FlxG.save.data.volume; - } - - if (FlxG.save.data.mute != null) - { - FlxG.sound.muted = FlxG.save.data.mute; - } - - // FlxG.save.close(); - // FlxG.sound.loadSavedPrefs(); - PreferencesMenu.initPrefs(); - PlayerSettings.init(); - Highscore.load(); - - #if newgrounds - NGio.init(); - #end - - if (FlxG.save.data.weekUnlocked != null) - { - // FIX LATER!!! - // WEEK UNLOCK PROGRESSION!! - // StoryMenuState.weekUnlocked = FlxG.save.data.weekUnlocked; - - if (StoryMenuState.weekUnlocked.length < 4) - StoryMenuState.weekUnlocked.insert(0, true); - - // QUICK PATCH OOPS! - if (!StoryMenuState.weekUnlocked[0]) - StoryMenuState.weekUnlocked[0] = true; - } - - if (FlxG.save.data.seenVideo != null) - { - VideoState.seenVideo = FlxG.save.data.seenVideo; - } - - #if FREEPLAY - FlxG.switchState(new FreeplayState()); - #elseif ANIMATE - FlxG.switchState(new animate.AnimTestStage()); - #elseif CHARTING - FlxG.switchState(new ChartingState()); /* #elseif web @@ -190,30 +103,10 @@ class TitleState extends MusicBeatState */ // netConnection.addEventListener(MouseEvent.MOUSE_DOWN, overlay_onMouseDown); - #elseif STAGEBUILD - FlxG.switchState(new StageBuilderState()); - #elseif ANIMDEBUG - FlxG.switchState(new ui.animDebugShit.DebugBoundingState()); - #elseif NETTEST - FlxG.switchState(new netTest.NetTest()); - #else new FlxTimer().start(1, function(tmr:FlxTimer) { startIntro(); }); - #end - - #if discord_rpc - DiscordClient.initialize(); - - Application.current.onExit.add(function(exitCode) - { - DiscordClient.shutdown(); - }); - #end - - // FlxG.stage.window.borderless = true; - // FlxG.stage.window.mouseLock = true; } private function client_onMetaData(metaData:Dynamic) @@ -261,18 +154,6 @@ class TitleState extends MusicBeatState function startIntro() { - if (!initialized) - { - var diamond:FlxGraphic = FlxGraphic.fromClass(GraphicTransTileDiamond); - diamond.persist = true; - diamond.destroyOnNoUse = false; - - FlxTransitionableState.defaultTransIn = new TransitionData(FADE, FlxColor.BLACK, 1, new FlxPoint(0, -1), {asset: diamond, width: 32, height: 32}, - new FlxRect(-200, -200, FlxG.width * 1.4, FlxG.height * 1.4)); - FlxTransitionableState.defaultTransOut = new TransitionData(FADE, FlxColor.BLACK, 0.7, new FlxPoint(0, 1), - {asset: diamond, width: 32, height: 32}, new FlxRect(-200, -200, FlxG.width * 1.4, FlxG.height * 1.4)); - } - if (FlxG.sound.music == null || !FlxG.sound.music.playing) { FlxG.sound.playMusic(Paths.music('freakyMenu'), 0); @@ -283,10 +164,6 @@ class TitleState extends MusicBeatState persistentUpdate = true; var bg:FlxSprite = new FlxSprite().makeGraphic(FlxG.width, FlxG.height, FlxColor.BLACK); - // bg.antialiasing = true; - // bg.setGraphicSize(Std.int(bg.width * 0.6)); - // bg.updateHitbox(); - add(bg); logoBl = new FlxSprite(-150, -100); @@ -334,34 +211,18 @@ class TitleState extends MusicBeatState // titleText.screenCenter(X); add(titleText); - var logo:FlxSprite = new FlxSprite().loadGraphic(Paths.image('logo')); - logo.screenCenter(); - logo.antialiasing = true; - // add(logo); - - // FlxTween.tween(logoBl, {y: logoBl.y + 50}, 0.6, {ease: FlxEase.quadInOut, type: PINGPONG}); - // FlxTween.tween(logo, {y: logoBl.y + 50}, 0.6, {ease: FlxEase.quadInOut, type: PINGPONG, startDelay: 0.1}); - var animShit:ComboCounter = new ComboCounter(200, 200, 1423); - // add(animShit); credGroup = new FlxGroup(); add(credGroup); textGroup = new FlxGroup(); - blackScreen = new FlxSprite().makeGraphic(FlxG.width, FlxG.height, FlxColor.BLACK); + blackScreen = bg.clone(); credGroup.add(blackScreen); // var atlasBullShit:FlxSprite = new FlxSprite(); // atlasBullShit.frames = CoolUtil.fromAnimate(Paths.image('money'), Paths.file('images/money.json')); // credGroup.add(atlasBullShit); - credTextShit = new Alphabet(0, 0, "ninjamuffin99\nPhantomArcade\nkawaisprite\nevilsk8er", true); - credTextShit.screenCenter(); - - // credTextShit.alignment = CENTER; - - credTextShit.visible = false; - ngSpr = new FlxSprite(0, FlxG.height * 0.52); if (FlxG.random.bool(1)) @@ -388,8 +249,6 @@ class TitleState extends MusicBeatState ngSpr.screenCenter(X); ngSpr.antialiasing = true; - FlxTween.tween(credTextShit, {y: credTextShit.y + 20}, 2.9, {ease: FlxEase.quadInOut, type: PINGPONG}); - FlxG.mouse.visible = false; if (initialized) @@ -399,9 +258,6 @@ class TitleState extends MusicBeatState if (FlxG.sound.music != null) FlxG.sound.music.onComplete = function() FlxG.switchState(new VideoState()); - - startedIntro = true; - // credGroup.add(credTextShit); } function getIntroTextShit():Array> @@ -421,9 +277,6 @@ class TitleState extends MusicBeatState var transitioning:Bool = false; - var fnfShit:String = "Friday Night Funkin'"; - var thingOffset:Int = 0; - override function update(elapsed:Float) { /* if (FlxG.onMobile) @@ -501,9 +354,10 @@ class TitleState extends MusicBeatState if (FlxG.sound.music != null) Conductor.songPosition = FlxG.sound.music.time; - // FlxG.watch.addQuick('amp', FlxG.sound.music.amplitude); if (FlxG.keys.justPressed.F) FlxG.fullscreen = !FlxG.fullscreen; + + // do controls.PAUSE | controls.ACCEPT instead? var pressedEnter:Bool = FlxG.keys.justPressed.ENTER; if (FlxG.onMobile) @@ -542,13 +396,8 @@ class TitleState extends MusicBeatState FlxG.camera.flash(FlxColor.WHITE, 1); FlxG.sound.play(Paths.sound('confirmMenu'), 0.7); transitioning = true; - // FlxG.sound.music.stop(); - // These assets are very unlikely to be used for the rest of gameplay, so it unloads them from cache/memory - // Saves about 50mb of RAM or so??? - Assets.cache.clear(Paths.image('gfDanceTitle')); - Assets.cache.clear(Paths.image('logoBumpin')); - Assets.cache.clear(Paths.image('titleEnter')); + var targetState:FlxState = new MainMenuState(); #if newgrounds if (!OutdatedSubState.leftState) @@ -561,19 +410,26 @@ class TitleState extends MusicBeatState if (version.trim() != onlineVersion) { trace('OLD VERSION!'); - // FlxG.switchState(new OutdatedSubState()); + // targetState = new OutdatedSubState(); } else { - // FlxG.switchState(new MainMenuState()); + // targetState = new MainMenuState(); } // REDO FOR ITCH/FINAL SHIT - FlxG.switchState(new MainMenuState()); }); } - #else - FlxG.switchState(new MainMenuState()); #end + new FlxTimer().start(2, function(tmr:FlxTimer) + { + // These assets are very unlikely to be used for the rest of gameplay, so it unloads them from cache/memory + // Saves about 50mb of RAM or so??? + Assets.cache.clear(Paths.image('gfDanceTitle')); + Assets.cache.clear(Paths.image('logoBumpin')); + Assets.cache.clear(Paths.image('titleEnter')); + // ngSpr?? + FlxG.switchState(targetState); + }); // FlxG.sound.play(Paths.music('titleShoot'), 0.7); } if (pressedEnter && !skippedIntro && initialized) @@ -591,8 +447,6 @@ class TitleState extends MusicBeatState #end */ - // if (FlxG.keys.justPressed.SPACE) - // swagShader.hasOutline = !swagShader.hasOutline; if (controls.UI_LEFT) swagShader.update(-elapsed * 0.1); if (controls.UI_RIGHT) @@ -678,11 +532,56 @@ class TitleState extends MusicBeatState } var isRainbow:Bool = false; + var skippedIntro:Bool = false; override function beatHit() { super.beatHit(); + if (!skippedIntro) + { + FlxG.log.add(curBeat); + // if the user is draggin the window some beats will + // be missed so this is just to compensate + if (curBeat > lastBeat) + { + for (i in lastBeat...curBeat) + { + switch (i + 1) + { + case 1: + createCoolText(['ninjamuffin99', 'phantomArcade', 'kawaisprite', 'evilsk8er']); + case 3: + addMoreText('present'); + case 4: + deleteCoolText(); + case 5: + createCoolText(['In association', 'with']); + case 7: + addMoreText('newgrounds'); + ngSpr.visible = true; + case 8: + deleteCoolText(); + ngSpr.visible = false; + case 9: + createCoolText([curWacky[0]]); + case 11: + addMoreText(curWacky[1]); + case 12: + deleteCoolText(); + case 13: + addMoreText('Friday'); + case 14: + addMoreText('Night'); + case 15: + addMoreText('Funkin'); + case 16: + skipIntro(); + } + } + } + lastBeat = curBeat; + } if (skippedIntro) { if (cheatActive && curBeat % 2 == 0) @@ -697,73 +596,8 @@ class TitleState extends MusicBeatState else gfDance.animation.play('danceLeft'); } - else - { - FlxG.log.add(curBeat); - // if the user is draggin the window some beats will - // be missed so this is just to compensate - if (curBeat > lastBeat) - { - for (i in lastBeat...curBeat) - { - switch (i + 1) - { - case 1: - createCoolText(['ninjamuffin99', 'phantomArcade', 'kawaisprite', 'evilsk8er']); - // credTextShit.visible = true; - case 3: - addMoreText('present'); - // credTextShit.text += '\npresent...'; - // credTextShit.addText(); - case 4: - deleteCoolText(); - // credTextShit.visible = false; - // credTextShit.text = 'In association \nwith'; - // credTextShit.screenCenter(); - case 5: - createCoolText(['In association', 'with']); - case 7: - addMoreText('newgrounds'); - ngSpr.visible = true; - // credTextShit.text += '\nNewgrounds'; - case 8: - deleteCoolText(); - ngSpr.visible = false; - // credTextShit.visible = false; - - // credTextShit.text = 'Shoutouts Tom Fulp'; - // credTextShit.screenCenter(); - case 9: - createCoolText([curWacky[0]]); - // credTextShit.visible = true; - case 11: - addMoreText(curWacky[1]); - // credTextShit.text += '\nlmao'; - case 12: - deleteCoolText(); - // credTextShit.visible = false; - // credTextShit.text = "Friday"; - // credTextShit.screenCenter(); - case 13: - addMoreText('Friday'); - // credTextShit.visible = true; - case 14: - addMoreText('Night'); - // credTextShit.text += '\nNight'; - case 15: - addMoreText('Funkin'); // credTextShit.text += '\nFunkin'; - - case 16: - skipIntro(); - } - } - } - lastBeat = curBeat; - } } - var skippedIntro:Bool = false; - function skipIntro():Void { if (!skippedIntro) From ba4793cef4abf76d771e5ca1840973a0ca8cac98 Mon Sep 17 00:00:00 2001 From: MtH Date: Tue, 7 Sep 2021 23:10:43 +0200 Subject: [PATCH 3/6] allow shared lib to be used without needing to have a level selected --- source/Paths.hx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/Paths.hx b/source/Paths.hx index 6494de623..aa8c17fd5 100644 --- a/source/Paths.hx +++ b/source/Paths.hx @@ -25,12 +25,12 @@ class Paths var levelPath = getLibraryPathForce(file, currentLevel); if (OpenFlAssets.exists(levelPath, type)) return levelPath; - - levelPath = getLibraryPathForce(file, "shared"); - if (OpenFlAssets.exists(levelPath, type)) - return levelPath; } + var levelPath = getLibraryPathForce(file, "shared"); + if (OpenFlAssets.exists(levelPath, type)) + return levelPath; + return getPreloadPath(file); } From 63341f0bc9d8e266a24c4c1d6d70688611fe265c Mon Sep 17 00:00:00 2001 From: MtH Date: Wed, 8 Sep 2021 17:16:16 +0200 Subject: [PATCH 4/6] fix imports for stagebuild in init/title, also GPG test like cam? --- source/InitState.hx | 1 + source/TitleState.hx | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/source/InitState.hx b/source/InitState.hx index 964bb1b34..d84954325 100644 --- a/source/InitState.hx +++ b/source/InitState.hx @@ -9,6 +9,7 @@ import flixel.math.FlxRect; import flixel.util.FlxColor; import openfl.display.BitmapData; import ui.PreferencesMenu; +import ui.stageBuildShit.StageBuilderState; #if colyseus import io.colyseus.Client; diff --git a/source/TitleState.hx b/source/TitleState.hx index 754cf2d9c..7b6e6977a 100644 --- a/source/TitleState.hx +++ b/source/TitleState.hx @@ -32,7 +32,6 @@ import shaderslmfao.BuildingShaders; import shaderslmfao.ColorSwap; import shaderslmfao.TitleOutline; import ui.PreferencesMenu; -import ui.stageBuildShit.StageBuilderState; using StringTools; From 187706c71c267f18559b37f8b166e9f4da65241a Mon Sep 17 00:00:00 2001 From: MtH Date: Wed, 8 Sep 2021 19:28:11 +0200 Subject: [PATCH 5/6] note hit, scoring windows & stricter sustain note holding this is some big impact shit so feel it out first --- source/Conductor.hx | 3 --- source/Note.hx | 17 ++++++++++++----- source/PlayState.hx | 6 +++--- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/source/Conductor.hx b/source/Conductor.hx index 9f3f50031..49d2cd290 100644 --- a/source/Conductor.hx +++ b/source/Conductor.hx @@ -23,9 +23,6 @@ class Conductor public static var lastSongPos:Float; public static var offset:Float = 0; - public static var safeFrames:Int = 10; - public static var safeZoneOffset:Float = (safeFrames / 60) * 1000; // is calculated in create(), is safeFrames in milliseconds - public static var bpmChangeMap:Array = []; public function new() diff --git a/source/Note.hx b/source/Note.hx index ef57dc6f1..acde0b250 100644 --- a/source/Note.hx +++ b/source/Note.hx @@ -34,7 +34,6 @@ class Note extends FlxSprite public var isSustainNote:Bool = false; public var colorSwap:ColorSwap; - public var noteScore:Float = 1; public static var swagWidth:Float = 160 * 0.7; public static var PURP_NOTE:Int = 0; @@ -42,6 +41,15 @@ class Note extends FlxSprite public static var BLUE_NOTE:Int = 1; public static var RED_NOTE:Int = 3; + // SCORING STUFF + public static var safeFrames:Int = 10; + public static var HIT_WINDOW:Float = (safeFrames / 60) * 1000; // 166.67 ms hit window + // anything above bad threshold is shit + public static var BAD_THRESHOLD:Float = 0.8; // 125ms , 8 frames + public static var GOOD_THRESHOLD:Float = 0.55; // 91.67ms , 5.5 frames + public static var SICK_THRESHOLD:Float = 0.2; // 33.33ms , 2 frames + // anything below sick threshold is sick + public static var arrowColors:Array = [1, 1, 1, 1]; public function new(strumTime:Float, noteData:Int, ?prevNote:Note, ?sustainNote:Bool = false) @@ -145,7 +153,6 @@ class Note extends FlxSprite if (isSustainNote && prevNote != null) { - noteScore * 0.2; alpha = 0.6; if (PreferencesMenu.getPref('downscroll')) @@ -224,9 +231,9 @@ class Note extends FlxSprite } else { - if (strumTime > Conductor.songPosition - Conductor.safeZoneOffset) - { // The * 0.5 is so that it's easier to hit them too late, instead of too early - if (strumTime < Conductor.songPosition + (Conductor.safeZoneOffset * 0.5)) + if (strumTime > Conductor.songPosition - HIT_WINDOW) + { // * 0.2 if sustain note, so u have to keep holding it closer to all the way thru! + if (strumTime < Conductor.songPosition + (HIT_WINDOW * (isSustainNote ? 0.2 : 1))) canBeHit = true; } else diff --git a/source/PlayState.hx b/source/PlayState.hx index 51ea7d0d1..832c6d42a 100644 --- a/source/PlayState.hx +++ b/source/PlayState.hx @@ -2339,19 +2339,19 @@ class PlayState extends MusicBeatState var isSick:Bool = true; - if (noteDiff > Conductor.safeZoneOffset * 0.9) + if (noteDiff > Note.HIT_WINDOW * Note.BAD_THRESHOLD) { daRating = 'shit'; score = 50; isSick = false; // shitty copypaste on this literally just because im lazy and tired lol! } - else if (noteDiff > Conductor.safeZoneOffset * 0.75) + else if (noteDiff > Note.HIT_WINDOW * Note.GOOD_THRESHOLD) { daRating = 'bad'; score = 100; isSick = false; } - else if (noteDiff > Conductor.safeZoneOffset * 0.2) + else if (noteDiff > Note.HIT_WINDOW * Note.SICK_THRESHOLD) { daRating = 'good'; score = 200; From 908372d2964ffa6351bfbc6c61c9fb60944d0042 Mon Sep 17 00:00:00 2001 From: MtH Date: Wed, 8 Sep 2021 22:28:30 +0200 Subject: [PATCH 6/6] lil oopsies and random cleanup of old shit --- source/PlayState.hx | 30 +++--------------------------- source/TitleState.hx | 2 +- 2 files changed, 4 insertions(+), 28 deletions(-) diff --git a/source/PlayState.hx b/source/PlayState.hx index 832c6d42a..9c9ca52a5 100644 --- a/source/PlayState.hx +++ b/source/PlayState.hx @@ -1770,7 +1770,7 @@ class PlayState extends MusicBeatState if (vocalsFinished) return; - vocals.time = Conductor.songPosition; + vocals.time = FlxG.sound.music.time; vocals.play(); } @@ -1780,9 +1780,6 @@ class PlayState extends MusicBeatState override public function update(elapsed:Float) { - // makes the lerp non-dependant on the framerate - // FlxG.camera.followLerp = CoolUtil.camLerpShit(0.04); - #if !debug perfectMode = false; #else @@ -1873,6 +1870,7 @@ class PlayState extends MusicBeatState paused = true; // 1 / 1000 chance for Gitaroo Man easter egg + // can this please move to dying it's kinda fucked up that pausing has a 1/1000 chance ur forced to restart if (FlxG.random.bool(0.1)) { // gitaroo man easter egg @@ -1904,9 +1902,6 @@ class PlayState extends MusicBeatState if (FlxG.keys.justPressed.NINE) iconP1.swapOldIcon(); - // FlxG.watch.addQuick('VOL', vocals.amplitudeLeft); - // FlxG.watch.addQuick('VOLRight', vocals.amplitudeRight); - iconP1.setGraphicSize(Std.int(CoolUtil.coolLerp(iconP1.width, 150, 0.15))); iconP2.setGraphicSize(Std.int(CoolUtil.coolLerp(iconP2.width, 150, 0.15))); @@ -1973,24 +1968,9 @@ class PlayState extends MusicBeatState gfSpeed = 2; case 112: gfSpeed = 1; - case 163: - // FlxG.sound.music.stop(); - // FlxG.switchState(new TitleState()); } } - if (curSong == 'Bopeebo') - { - switch (curBeat) - { - case 128, 129, 130: - vocals.volume = 0; - // FlxG.sound.music.stop(); - // FlxG.switchState(new PlayState()); - } - } - // better streaming of shit - if (!inCutscene && !_exiting) { // RESET = Quick Game Over Screen @@ -2223,6 +2203,7 @@ class PlayState extends MusicBeatState daPos += 4 * (1000 * 60 / daBPM); } Conductor.songPosition = FlxG.sound.music.time = daPos; + Conductor.songPosition += Conductor.offset; updateCurStep(); resyncVocals(); } @@ -2963,11 +2944,6 @@ class PlayState extends MusicBeatState { resyncVocals(); } - - if (dad.curCharacter == 'spooky' && curStep % 4 == 2) - { - // dad.dance(); - } } var lightningStrikeBeat:Int = 0; diff --git a/source/TitleState.hx b/source/TitleState.hx index 7b6e6977a..fa0e8e9eb 100644 --- a/source/TitleState.hx +++ b/source/TitleState.hx @@ -51,7 +51,7 @@ class TitleState extends MusicBeatState var ngSpr:FlxSprite; var curWacky:Array = []; - var lastBeat:Int = -1; + var lastBeat:Int = 0; var swagShader:ColorSwap; var alphaShader:BuildingShaders;