From 24acbc5f7477e79fdb50d80cc6163d6395183f99 Mon Sep 17 00:00:00 2001 From: Lil-Parrot Date: Sun, 8 Aug 2021 00:10:12 -0500 Subject: [PATCH 1/3] Instant Respawn --- source/GameOverState.hx | 10 ++++++++++ source/GameOverSubstate.hx | 5 +++++ source/KadeEngineData.hx | 3 +++ source/Options.hx | 21 +++++++++++++++++++++ source/OptionsMenu.hx | 1 + 5 files changed, 40 insertions(+) diff --git a/source/GameOverState.hx b/source/GameOverState.hx index c26c063..8da12b3 100644 --- a/source/GameOverState.hx +++ b/source/GameOverState.hx @@ -60,6 +60,16 @@ class GameOverState extends FlxTransitionableState var gamepad:FlxGamepad = FlxG.gamepads.lastActive; + if(FlxG.save.data.InstantRespawn) + { + fading = true; + FlxG.sound.music.fadeOut(0.5, 0, function(twn:FlxTween) + { + FlxG.sound.music.stop(); + LoadingState.loadAndSwitchState(new PlayState()); + }); + } + if (gamepad != null) { if (gamepad.justPressed.ANY) diff --git a/source/GameOverSubstate.hx b/source/GameOverSubstate.hx index 8a840b3..3fce8cb 100644 --- a/source/GameOverSubstate.hx +++ b/source/GameOverSubstate.hx @@ -59,6 +59,11 @@ class GameOverSubstate extends MusicBeatSubstate endBullshit(); } + if(FlxG.save.data.InstantRespawn) + { + LoadingState.loadAndSwitchState(new PlayState()); + } + if (controls.BACK) { FlxG.sound.music.stop(); diff --git a/source/KadeEngineData.hx b/source/KadeEngineData.hx index 78d86e4..f485779 100644 --- a/source/KadeEngineData.hx +++ b/source/KadeEngineData.hx @@ -75,6 +75,9 @@ class KadeEngineData if (FlxG.save.data.resetButton == null) FlxG.save.data.resetButton = false; + + if (FlxG.save.data.InstantRespawn == null) + FlxG.save.data.InstantRespawn = false; if (FlxG.save.data.botplay == null) FlxG.save.data.botplay = false; diff --git a/source/Options.hx b/source/Options.hx index 10eb0b0..35805f3 100644 --- a/source/Options.hx +++ b/source/Options.hx @@ -284,6 +284,27 @@ class ResetButtonOption extends Option } } +class InstantRespawn extends Option +{ + public function new(desc:String) + { + super(); + description = desc; + } + + public override function press():Bool + { + FlxG.save.data.InstantRespawn = !FlxG.save.data.InstantRespawn; + display = updateDisplay(); + return true; + } + + private override function updateDisplay():String + { + return "Instant Respawn " + (!FlxG.save.data.InstantRespawn ? "off" : "on"); + } +} + class FlashingLightsOption extends Option { public function new(desc:String) diff --git a/source/OptionsMenu.hx b/source/OptionsMenu.hx index f953f01..ea02dff 100644 --- a/source/OptionsMenu.hx +++ b/source/OptionsMenu.hx @@ -36,6 +36,7 @@ class OptionsMenu extends MusicBeatState new ScrollSpeedOption("Change your scroll speed (1 = Chart dependent)"), new AccuracyDOption("Change how accuracy is calculated. (Accurate = Simple, Complex = Milisecond Based)"), new ResetButtonOption("Toggle pressing R to gameover."), + new InstantRespawn("Toggle if you instantly respawn after dying."), // new OffsetMenu("Get a note offset based off of your inputs!"), new CustomizeGameplay("Drag'n'Drop Gameplay Modules around to your preference") ]), From f2d0a5b439ad4c083343f0ce25242eb34d467e81 Mon Sep 17 00:00:00 2001 From: Xela10001 <47480171+Xela10001@users.noreply.github.com> Date: Sun, 8 Aug 2021 18:05:49 +0100 Subject: [PATCH 2/3] Midpoint-Based Movement Functionality Added Added a function called moveTextToMidpoint() which changes the position of the text based on what midpoint you want it to have. Extremely handy for keeping text centered. Also, changed resizeText() using this new function, making resizeText() much simpler. --- source/Alphabet.hx | 48 +++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/source/Alphabet.hx b/source/Alphabet.hx index dc3484a..b1f75cd 100644 --- a/source/Alphabet.hx +++ b/source/Alphabet.hx @@ -1,5 +1,6 @@ package; +import flixel.math.FlxPoint; import flixel.tweens.FlxEase; import flixel.tweens.FlxTween; import flixel.FlxG; @@ -285,32 +286,31 @@ class Alphabet extends FlxSpriteGroup // ThatGuy: Ooga booga function for resizing text, with the option of wanting it to have the same midPoint // Side note: Do not, EVER, do updateHitbox() unless you are retyping the whole thing. Don't know why, but the position gets retarded if you do that public function resizeText(xScale:Float, yScale:Float, xStaysCentered:Bool = true, yStaysCentered:Bool = false):Void { - var oldWidth:Float = this.width; - var oldHeight:Float = this.height; - //trace('old x before scaling: ' + this.x); - //trace('old midpoint before scaling: ' + this.getMidpoint().x); + var oldMidpoint:FlxPoint = this.getMidpoint(); reType(text, xScale, yScale); - //trace('old x after scaling: ' + this.x); - //trace('old midpoint after scaling: ' + this.getMidpoint().x); - //This works, commenting out all the tracing - if(xStaysCentered) { - /* - If oldX is the old position, that is the same for both sizes of text, e.g. oldX = 50 - And oldWidth is the old width of the text, e.g. oldWidth = 100 - And newWidth is the current width of the text, e.g. newWidth= 150 - And the midpoint, is always the same, e.g. midpoint = oldX + oldWidth/2 = 50 + 100/2 = 100 - and the newMidpoint, which is equal to midpoint, is newX + newWidth/2, then - newX = midpoint - newWidth/2 <=> newX = oldX + oldWidth/2 - newWidth/2, e.g., <=> newX = 50 + 100/2 - 150/2 <=> newX = 25 - */ - //Since this.x doesnt change with text scaling, in this equation, this.x can be used as both the old and the new x - this.x = this.x + oldWidth/2 - this.width/2; - //trace('new x after scaling: ' + this.x); - //trace('new midpoint after scaling: ' + this.getMidpoint().x); - } - if(yStaysCentered) { - // Same logic applies here - this.y = this.y + oldHeight/2 - this.height/2; + if(!(xStaysCentered && yStaysCentered)){ + if(xStaysCentered) { + //I can just use this juicy new function i made + moveTextToMidpoint(new FlxPoint(oldMidpoint.x, getMidpoint().y)); + } + if(yStaysCentered) { + moveTextToMidpoint(new FlxPoint(getMidpoint().x, oldMidpoint.y)); + } + } else { + moveTextToMidpoint(new FlxPoint(oldMidpoint.x, oldMidpoint.y)); } + + } + + // ThatGuy: Function used to keep text centered on one point instead of manually having to come up with offsets for each sentence + public function moveTextToMidpoint(midpoint:FlxPoint):Void { + /* + e.g. You want your midpoint at (100, 100) + and your text is 200 wide, 50 tall + then, x = 100 - 200/2, y = 100 - 50/2 + */ + this.x = midpoint.x - this.width / 2; + this.y = midpoint.y - this.height / 2; } } From ea1417d0377d1647382fdf066f5fa21675715ddf Mon Sep 17 00:00:00 2001 From: CyndaquilDAC <65635932+CyndaquilDAC@users.noreply.github.com> Date: Sun, 8 Aug 2021 14:21:49 -0500 Subject: [PATCH 3/3] cleaner dialogue code --- .../roses/{rosesDialogue.txt => dialogue.txt} | 4 +-- .../{senpaiDialogue.txt => dialogue.txt} | 4 +-- .../{thornsDialogue.txt => dialogue.txt} | 8 ++--- source/PlayState.hx | 29 +++---------------- 4 files changed, 12 insertions(+), 33 deletions(-) rename assets/preload/data/roses/{rosesDialogue.txt => dialogue.txt} (98%) rename assets/preload/data/senpai/{senpaiDialogue.txt => dialogue.txt} (98%) rename assets/preload/data/thorns/{thornsDialogue.txt => dialogue.txt} (98%) diff --git a/assets/preload/data/roses/rosesDialogue.txt b/assets/preload/data/roses/dialogue.txt similarity index 98% rename from assets/preload/data/roses/rosesDialogue.txt rename to assets/preload/data/roses/dialogue.txt index c519763..63a60f8 100644 --- a/assets/preload/data/roses/rosesDialogue.txt +++ b/assets/preload/data/roses/dialogue.txt @@ -1,3 +1,3 @@ -:dad:Not bad for an ugly worm. -:dad:But this time I'll rip your nuts off right after your girlfriend finishes gargling mine. +:dad:Not bad for an ugly worm. +:dad:But this time I'll rip your nuts off right after your girlfriend finishes gargling mine. :bf:Bop beep be be skdoo bep \ No newline at end of file diff --git a/assets/preload/data/senpai/senpaiDialogue.txt b/assets/preload/data/senpai/dialogue.txt similarity index 98% rename from assets/preload/data/senpai/senpaiDialogue.txt rename to assets/preload/data/senpai/dialogue.txt index aa30163..af03e37 100644 --- a/assets/preload/data/senpai/senpaiDialogue.txt +++ b/assets/preload/data/senpai/dialogue.txt @@ -1,3 +1,3 @@ -:dad:Ah, a new fair maiden has come in search of true love! -:dad:A serenade between gentlemen shall decide where her beautiful heart shall reside. +:dad:Ah, a new fair maiden has come in search of true love! +:dad:A serenade between gentlemen shall decide where her beautiful heart shall reside. :bf:Beep bo bop \ No newline at end of file diff --git a/assets/preload/data/thorns/thornsDialogue.txt b/assets/preload/data/thorns/dialogue.txt similarity index 98% rename from assets/preload/data/thorns/thornsDialogue.txt rename to assets/preload/data/thorns/dialogue.txt index 82a7ae9..b430202 100644 --- a/assets/preload/data/thorns/thornsDialogue.txt +++ b/assets/preload/data/thorns/dialogue.txt @@ -1,5 +1,5 @@ -:dad:Direct contact with real humans, after being trapped in here for so long... -:dad:and HER of all people. -:dad:I'll make her father pay for what he's done to me and all the others,,,, -:dad:I'll beat you and make you take my place. +:dad:Direct contact with real humans, after being trapped in here for so long... +:dad:and HER of all people. +:dad:I'll make her father pay for what he's done to me and all the others,,,, +:dad:I'll beat you and make you take my place. :dad:You don't mind your bodies being borrowed right? It's only fair... \ No newline at end of file diff --git a/source/PlayState.hx b/source/PlayState.hx index 17fd3ac..6089586 100644 --- a/source/PlayState.hx +++ b/source/PlayState.hx @@ -456,32 +456,11 @@ class PlayState extends MusicBeatState trace('INFORMATION ABOUT WHAT U PLAYIN WIT:\nFRAMES: ' + PlayStateChangeables.safeFrames + '\nZONE: ' + Conductor.safeZoneOffset + '\nTS: ' + Conductor.timeScale + '\nBotPlay : ' + PlayStateChangeables.botPlay); - // dialogue shit - switch (songLowercase) + switch(songLowercase) { - case 'tutorial': - dialogue = ["Hey you're pretty cute.", 'Use the arrow keys to keep up \nwith me singing.']; - case 'bopeebo': - dialogue = [ - 'HEY!', - "You think you can just sing\nwith my daughter like that?", - "If you want to date her...", - "You're going to have to go \nthrough ME first!" - ]; - case 'fresh': - dialogue = ["Not too shabby boy.", ""]; - case 'dadbattle': - dialogue = [ - "gah you think you're hot stuff?", - "If you can beat me here...", - "Only then I will even CONSIDER letting you\ndate my daughter!" - ]; - case 'senpai': - dialogue = CoolUtil.coolTextFile(Paths.txt('data/senpai/senpaiDialogue')); - case 'roses': - dialogue = CoolUtil.coolTextFile(Paths.txt('data/roses/rosesDialogue')); - case 'thorns': - dialogue = CoolUtil.coolTextFile(Paths.txt('data/thorns/thornsDialogue')); + //if the song has dialogue, so we don't accidentally try to load a nonexistant file and crash the game + case 'senpai' | 'roses' | 'thorns': + dialogue = CoolUtil.coolTextFile(Paths.txt('data/' + songLowercase + '/dialogue')); } // defaults if no stage was found in chart