diff --git a/.github/ISSUE_TEMPLATE/bug.md b/.github/ISSUE_TEMPLATE/bug.md index a87e759..5fefe0f 100644 --- a/.github/ISSUE_TEMPLATE/bug.md +++ b/.github/ISSUE_TEMPLATE/bug.md @@ -7,7 +7,7 @@ assignees: '' --- -#### Please check for duplicates or similar issues, as well performing simple troubleshooting steps (such as clearing cookies, clearing AppData, trying another browser) before submitting an issue. +#### Please check for duplicates or similar issues, as well performing simple troubleshooting steps (such as deleting the export folder if it's an issue with compiling, reinstalling Kade Engine) before submitting an issue. ### If you are playing a downloaded version of the game, what operating system are you using? Windows (`x86`), Windows (`x86_64`), Linux, or macOS? Specify below. diff --git a/.gitignore b/.gitignore index 415caf3..08da7b0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,2 @@ export/ .vscode/ -APIStuff.hx diff --git a/Project.xml b/Project.xml index 08b9a5a..0de6121 100644 --- a/Project.xml +++ b/Project.xml @@ -116,7 +116,7 @@ - + diff --git a/README.md b/README.md index 5cd5c57..5a01629 100644 --- a/README.md +++ b/README.md @@ -15,11 +15,20 @@ This is the repository for Friday Night Funkin' Kade Engine, a game originally made for Ludum Dare 47 "Stuck In a Loop". And a completely reworked engine. +### Links to the original game Play the Ludum Dare prototype here: https://ninja-muffin24.itch.io/friday-night-funkin Play the Newgrounds one here: https://www.newgrounds.com/portal/view/770371 Support the project on the itch.io page: https://ninja-muffin24.itch.io/funkin +### Links to Kade Engine Mod Page: https://gamebanana.com/gamefiles/16761 + +Latest GitHub release: https://github.com/KadeDev/Kade-Engine/releases/latest + +AppVeyor CI (Automatic builds of the latest commit): +- Windows: [AppVeyor Project](https://ci.appveyor.com/project/KadeDev/kade-engine-windows) | [Artifacts (downloads)](https://ci.appveyor.com/project/KadeDev/kade-engine-windows/build/artifacts) + +- Linux: [AppVeyor Project](https://ci.appveyor.com/project/KadeDev/kade-engine-linux) | [Artifacts (downloads)](https://ci.appveyor.com/project/KadeDev/kade-engine-linux/build/artifacts) ## What is Kade Engine? diff --git a/appveyor-linux.yml b/appveyor-linux.yml new file mode 100644 index 0000000..bc3bed6 --- /dev/null +++ b/appveyor-linux.yml @@ -0,0 +1,42 @@ +version: '{build}' +image: Ubuntu2004 +environment: + global: + HAXELIB_ROOT: /home/appveyor/haxelib + HAXE_INSTALLDIR: /home/appveyor/haxe + +install: + - cd /home/appveyor + - sudo add-apt-repository ppa:haxe/releases -y + - sudo apt update + - sudo apt install neko tar -y + - wget https://github.com/HaxeFoundation/haxe/releases/download/4.1.5/haxe-4.1.5-linux64.tar.gz + - mkdir $HAXE_INSTALLDIR + - tar -xf haxe-4.1.5-linux64.tar.gz -C $HAXE_INSTALLDIR + - export PATH=$PATH:$HAXE_INSTALLDIR/haxe_20201231082044_5e33a78aa + - mkdir $HAXELIB_ROOT && haxelib setup $HAXELIB_ROOT + - haxelib install lime 7.9.0 + - haxelib install openfl + - haxelib install flixel + - haxelib run lime setup flixel + - haxelib run lime setup + - haxelib install flixel-tools + - haxelib install flixel-addons + - haxelib install flixel-ui + - haxelib install hscript + - haxelib install newgrounds + - haxelib git faxe https://github.com/uhrobots/faxe + - haxelib git polymod https://github.com/larsiusprime/polymod.git + - haxelib git discord_rpc https://github.com/Aidan63/linc_discord-rpc + - haxelib list + - cd /home/appveyor/projects/kade-engine-linux + +build_script: + - haxelib run lime build linux + +after_build: + - tar -cvf funkin-ke.tar -C /home/appveyor/projects/kade-engine-linux/export/release/linux/bin . + +artifacts: +- path: funkin-ke.tar + name: Linux build \ No newline at end of file diff --git a/appveyor-windows.yml b/appveyor-windows.yml new file mode 100644 index 0000000..801fd23 --- /dev/null +++ b/appveyor-windows.yml @@ -0,0 +1,45 @@ +# Taken from https://github.com/andyli/HaxeCI/blob/master/appveyor.yml +version: "{build}" + +environment: + global: + HAXELIB_ROOT: C:\projects\haxelib + +install: + # http://help.appveyor.com/discussions/problems/5616-not-able-to-build-due-to-problem-in-chocolateyinstallps1 + - ps: Set-Service wuauserv -StartupType Manual + # Install the neko chocolatey package (https://chocolatey.org/packages/neko) + - cinst neko --version 2.3.0 -y + # Install the haxe chocolatey package (https://chocolatey.org/packages/haxe) + - cinst haxe --version 4.1.5 -y + - RefreshEnv + # Setup haxelib + - mkdir "%HAXELIB_ROOT%" + - haxelib setup "%HAXELIB_ROOT%" + # Install project dependencies + - haxelib install lime 7.9.0 + - haxelib install openfl + - haxelib install flixel + - haxelib run lime setup flixel + - haxelib run lime setup + - haxelib install flixel-tools + # haxelib run flixel-tools setup -y # Can't do this since it asks [y/n] even with -y argument! Stupid + - haxelib install flixel-addons + - haxelib install flixel-ui + - haxelib install hscript + - haxelib install newgrounds + - haxelib install flixel-addons + - haxelib git faxe https://github.com/uhrobots/faxe + - haxelib git polymod https://github.com/larsiusprime/polymod.git + - haxelib git discord_rpc https://github.com/Aidan63/linc_discord-rpc + - haxelib list + +# No tests idk lol +build_script: + - haxelib run lime build windows + # haxelib run lime build linux + +artifacts: + - path: export/release/windows/bin + name: Windows release + type: zip \ No newline at end of file diff --git a/source/APIStuff.hx b/source/APIStuff.hx new file mode 100644 index 0000000..f05fa06 --- /dev/null +++ b/source/APIStuff.hx @@ -0,0 +1,7 @@ +package; + +class APIStuff +{ + public static var API:String = ""; + public static var EncKey:String = ""; +} diff --git a/source/Conductor.hx b/source/Conductor.hx index 4248c9d..68634a3 100644 --- a/source/Conductor.hx +++ b/source/Conductor.hx @@ -1,6 +1,7 @@ package; import Song.SwagSong; +import flixel.FlxG; /** * ... @@ -24,7 +25,8 @@ class Conductor 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 safeZoneOffset:Float = Math.floor((safeFrames / 60) * 1000); // is calculated in create(), is safeFrames in milliseconds + public static var timeScale:Float = Conductor.safeZoneOffset / 166; public static var bpmChangeMap:Array = []; @@ -32,6 +34,13 @@ class Conductor { } + public static function recalculateTimings() + { + Conductor.safeFrames = FlxG.save.data.frames; + Conductor.safeZoneOffset = Math.floor((Conductor.safeFrames / 60) * 1000); + Conductor.timeScale = Conductor.safeZoneOffset / 166; + } + public static function mapBPMChanges(song:SwagSong) { bpmChangeMap = []; diff --git a/source/ConvertScore.hx b/source/ConvertScore.hx new file mode 100644 index 0000000..9eba969 --- /dev/null +++ b/source/ConvertScore.hx @@ -0,0 +1,21 @@ +class ConvertScore +{ + public static function convertScore(noteDiff:Float):Int + { + var daRating:String = Ratings.CalculateRating(noteDiff, 166); + + switch(daRating) + { + case 'shit': + return -300; + case 'bad': + return 0; + case 'good': + return 200; + case 'sick': + return 350; + } + return 0; + } + +} \ No newline at end of file diff --git a/source/Discord.hx b/source/Discord.hx index 5dc9c64..00018e7 100644 --- a/source/Discord.hx +++ b/source/Discord.hx @@ -1,5 +1,6 @@ package; +#if windows import Sys.sleep; import discord_rpc.DiscordRpc; @@ -84,4 +85,5 @@ class DiscordClient //trace('Discord RPC Updated. Arguments: $details, $state, $smallImageKey, $hasStartTimestamp, $endTimestamp'); } -} \ No newline at end of file +} +#end \ No newline at end of file diff --git a/source/FreeplayState.hx b/source/FreeplayState.hx index 145f2fc..b7efe64 100644 --- a/source/FreeplayState.hx +++ b/source/FreeplayState.hx @@ -11,7 +11,7 @@ import flixel.util.FlxColor; import lime.utils.Assets; -#if desktop +#if windows import Discord.DiscordClient; #end @@ -53,7 +53,7 @@ class FreeplayState extends MusicBeatState } */ - #if desktop + #if windows // Updating Discord Rich Presence DiscordClient.changePresence("In the Menus", null); #end diff --git a/source/GameplayCustomizeState.hx b/source/GameplayCustomizeState.hx index 355691e..b3991c8 100644 --- a/source/GameplayCustomizeState.hx +++ b/source/GameplayCustomizeState.hx @@ -2,7 +2,7 @@ import flixel.math.FlxMath; import flixel.FlxCamera; import flixel.math.FlxPoint; import flixel.FlxObject; -#if desktop +#if windows import Discord.DiscordClient; import sys.thread.Thread; #end @@ -33,7 +33,7 @@ class GameplayCustomizeState extends MusicBeatState private var camHUD:FlxCamera; public override function create() { - #if desktop + #if windows // Updating Discord Rich Presence DiscordClient.changePresence("Customizing Gameplay", null); #end diff --git a/source/KadeEngineData.hx b/source/KadeEngineData.hx index 458de55..8229c19 100644 --- a/source/KadeEngineData.hx +++ b/source/KadeEngineData.hx @@ -26,9 +26,6 @@ class KadeEngineData if (FlxG.save.data.songPosition == null) FlxG.save.data.songPosition = false; - if (FlxG.save.data.etternaMode == null) - FlxG.save.data.etternaMode = false; - if (FlxG.save.data.fps == null) FlxG.save.data.fps = false; @@ -54,6 +51,11 @@ class KadeEngineData if (FlxG.save.data.npsDisplay == null) FlxG.save.data.npsDisplay = false; + if (FlxG.save.data.frames == null) + FlxG.save.data.frames = 10; + + Conductor.recalculateTimings(); + (cast (Lib.current.getChildAt(0), Main)).setFPSCap(FlxG.save.data.fpsCap); } } diff --git a/source/MainMenuState.hx b/source/MainMenuState.hx index fb24034..0351715 100644 --- a/source/MainMenuState.hx +++ b/source/MainMenuState.hx @@ -14,7 +14,7 @@ import flixel.util.FlxColor; import io.newgrounds.NG; import lime.app.Application; -#if desktop +#if windows import Discord.DiscordClient; #end @@ -36,9 +36,9 @@ class MainMenuState extends MusicBeatState var newGaming2:FlxText; var newInput:Bool = true; - public static var nightly:String = ""; + public static var nightly:String = "-Nightly2"; - public static var kadeEngineVer:String = "1.4" + nightly; + public static var kadeEngineVer:String = "1.4.1" + nightly; public static var gameVer:String = "0.2.7.1"; var magenta:FlxSprite; @@ -46,7 +46,7 @@ class MainMenuState extends MusicBeatState override function create() { - #if desktop + #if windows // Updating Discord Rich Presence DiscordClient.changePresence("In the Menus", null); #end diff --git a/source/MusicBeatState.hx b/source/MusicBeatState.hx index 3900654..29260f8 100644 --- a/source/MusicBeatState.hx +++ b/source/MusicBeatState.hx @@ -1,6 +1,8 @@ package; +#if windows import Discord.DiscordClient; +#end import flixel.tweens.FlxTween; import flixel.util.FlxColor; import openfl.Lib; diff --git a/source/Note.hx b/source/Note.hx index fa88315..699b9bc 100644 --- a/source/Note.hx +++ b/source/Note.hx @@ -48,7 +48,7 @@ class Note extends FlxSprite x += 50; // MAKE SURE ITS DEFINITELY OFF SCREEN? y -= 2000; - this.strumTime = strumTime + FlxG.save.data.offset; + this.strumTime = strumTime; if (this.strumTime < 0 ) this.strumTime = 0; @@ -172,7 +172,7 @@ class Note extends FlxSprite prevNote.animation.play('redhold'); } - prevNote.scale.y *= Conductor.stepCrochet / 100 * 1.8 * PlayState.SONG.speed; + prevNote.scale.y *= Conductor.stepCrochet / 100 * 1.8 * FlxG.save.data.scrollSpeed; prevNote.updateHitbox(); // prevNote.setGraphicSize(); } diff --git a/source/Options.hx b/source/Options.hx index f4e6e20..85dd530 100644 --- a/source/Options.hx +++ b/source/Options.hx @@ -45,19 +45,28 @@ class Option } private var description:String = ""; private var display:String; + private var acceptValues:Bool = false; public final function getDisplay():String { return display; } + public final function getAccept():Bool + { + return acceptValues; + } + public final function getDescription():String { return description; } + // Returns whether the label is to be updated. public function press():Bool { return throw "stub!"; } private function updateDisplay():String { return throw "stub!"; } + public function left():Bool { return throw "stub!"; } + public function right():Bool { return throw "stub!"; } } class DFJKOption extends Option @@ -150,24 +159,63 @@ class SongPositionOption extends Option } } -class EtternaModeOption extends Option +class Judgement extends Option { + + public function new(desc:String) { super(); description = desc; + acceptValues = true; } public override function press():Bool { - FlxG.save.data.etternaMode = !FlxG.save.data.etternaMode; - display = updateDisplay(); return true; } private override function updateDisplay():String { - return "Etterna Mode " + (!FlxG.save.data.etternaMode ? "off" : "on"); + return "Safe Frames"; + } + + override function left():Bool { + + if (Conductor.safeFrames == 1) + return false; + + Conductor.safeFrames -= 1; + FlxG.save.data.frames = Conductor.safeFrames; + + Conductor.recalculateTimings(); + + OptionsMenu.versionShit.text = "Current Safe Frames: " + Conductor.safeFrames + " - Description - " + description + + " - SIK: " + OptionsMenu.truncateFloat(45 * Conductor.timeScale, 0) + + "ms GD: " + OptionsMenu.truncateFloat(90 * Conductor.timeScale, 0) + + "ms BD: " + OptionsMenu.truncateFloat(135 * Conductor.timeScale, 0) + + "ms SHT: " + OptionsMenu.truncateFloat(155 * Conductor.timeScale, 0) + + "ms TOTAL: " + OptionsMenu.truncateFloat(Conductor.safeZoneOffset,0) + "ms"; + return true; + } + + override function right():Bool { + + if (Conductor.safeFrames == 20) + return false; + + Conductor.safeFrames += 1; + FlxG.save.data.frames = Conductor.safeFrames; + + Conductor.recalculateTimings(); + + OptionsMenu.versionShit.text = "Current Safe Frames: " + Conductor.safeFrames + " - Description - " + description + + " - SIK: " + OptionsMenu.truncateFloat(45 * Conductor.timeScale, 0) + + "ms GD: " + OptionsMenu.truncateFloat(90 * Conductor.timeScale, 0) + + "ms BD: " + OptionsMenu.truncateFloat(135 * Conductor.timeScale, 0) + + "ms SHT: " + OptionsMenu.truncateFloat(155 * Conductor.timeScale, 0) + + "ms TOTAL: " + OptionsMenu.truncateFloat(Conductor.safeZoneOffset,0) + "ms"; + return true; } } @@ -199,6 +247,7 @@ class FPSCapOption extends Option { super(); description = desc; + acceptValues = true; } public override function press():Bool @@ -210,6 +259,28 @@ class FPSCapOption extends Option { return "FPS Cap"; } + + override function right():Bool { + if (FlxG.save.data.fpsCap > 290) + return false; + FlxG.save.data.fpsCap = FlxG.save.data.fpsCap + 10; + (cast (Lib.current.getChildAt(0), Main)).setFPSCap(FlxG.save.data.fpsCap); + + OptionsMenu.versionShit.text = "Current FPS Cap: " + FlxG.save.data.fpsCap + " - Description - " + description; + + return true; + } + + override function left():Bool { + if (FlxG.save.data.fpsCap < 60) + return false; + FlxG.save.data.fpsCap = FlxG.save.data.fpsCap - 10; + (cast (Lib.current.getChildAt(0), Main)).setFPSCap(FlxG.save.data.fpsCap); + + OptionsMenu.versionShit.text = "Current FPS Cap: " + FlxG.save.data.fpsCap + " - Description - " + description; + + return true; + } } @@ -219,6 +290,7 @@ class ScrollSpeedOption extends Option { super(); description = desc; + acceptValues = true; } public override function press():Bool @@ -230,6 +302,33 @@ class ScrollSpeedOption extends Option { return "Scroll Speed"; } + + override function right():Bool { + FlxG.save.data.scrollSpeed += 0.1; + + if (FlxG.save.data.scrollSpeed < 1) + FlxG.save.data.scrollSpeed = 1; + + if (FlxG.save.data.scrollSpeed > 10) + FlxG.save.data.scrollSpeed = 10; + + OptionsMenu.versionShit.text = "Current Scroll Speed: " + OptionsMenu.truncateFloat(FlxG.save.data.scrollSpeed,1) + " - Description - " + description; + return true; + } + + override function left():Bool { + FlxG.save.data.scrollSpeed -= 0.1; + + if (FlxG.save.data.scrollSpeed < 1) + FlxG.save.data.scrollSpeed = 1; + + if (FlxG.save.data.scrollSpeed > 10) + FlxG.save.data.scrollSpeed = 10; + + + OptionsMenu.versionShit.text = "Current Scroll Speed: " + OptionsMenu.truncateFloat(FlxG.save.data.scrollSpeed,1) + " - Description - " + description; + return true; + } } diff --git a/source/OptionsMenu.hx b/source/OptionsMenu.hx index 35af037..600a960 100644 --- a/source/OptionsMenu.hx +++ b/source/OptionsMenu.hx @@ -22,7 +22,10 @@ class OptionsMenu extends MusicBeatState var options:Array = [ new OptionCatagory("Gameplay", [ new DFJKOption(controls), - new FPSCapOption("Cap your FPS (Left for -10, Right for -10)"), + new Judgement("Customize your Hit Timings (LEFT or RIGHT)"), + #if !html + new FPSCapOption("Cap your FPS (Left for -10, Right for +10. SHIFT to go faster)"), + #end new ScrollSpeedOption("Change your scroll speed (Left for -0.1, right for +0.1. If its at 1, it will be chart dependent)"), new OffsetMenu("Get a note offset based off of your inputs!"), new CustomizeGameplay("Drag'n'Drop Gameplay Modules around to your preference") @@ -30,22 +33,24 @@ class OptionsMenu extends MusicBeatState new OptionCatagory("Appearence", [ new SongPositionOption("Show the songs current position (as a bar)"), new DownscrollOption("Change the layout of the strumline."), + #if !html new RainbowFPSOption("Make the FPS Counter Rainbow (Only works with the FPS Counter toggeled on)"), + #end new AccuracyOption("Display accuracy information."), new NPSDisplayOption("Shows your current Notes Per Second.") ]), + #if !mobile new OptionCatagory("Misc", [ - new EtternaModeOption("Harder Hit Windows and a different scoring system."), - #if !mobile + new FPSOption("Toggle the FPS Counter"), - #end new ReplayOption("View replays") ]) + #end ]; private var currentDescription:String = ""; private var grpControls:FlxTypedGroup; - var versionShit:FlxText; + public static var versionShit:FlxText; var currentSelectedCat:OptionCatagory; @@ -84,7 +89,7 @@ class OptionsMenu extends MusicBeatState var isCat:Bool = false; - function truncateFloat( number : Float, precision : Int): Float { + public static function truncateFloat( number : Float, precision : Int): Float { var num = number; num = num * Math.pow(10, precision); num = Math.round( num ) / Math.pow(10, precision); @@ -118,51 +123,36 @@ class OptionsMenu extends MusicBeatState if (isCat) { - switch(currentSelectedCat.getOptions()[curSelected].getDisplay()) + if (currentSelectedCat.getOptions()[curSelected].getAccept()) { - case 'FPS Cap': - var fps = (cast (Lib.current.getChildAt(0), Main)).getFPSCap(); - - if (FlxG.keys.pressed.RIGHT && fps < 285) // actual cap is 285 + if (FlxG.keys.pressed.SHIFT) { - (cast (Lib.current.getChildAt(0), Main)).setFPSCap(fps + 10); - FlxG.save.data.fpsCap = fps + 10; + if (FlxG.keys.pressed.RIGHT) + currentSelectedCat.getOptions()[curSelected].right(); + if (FlxG.keys.pressed.LEFT) + currentSelectedCat.getOptions()[curSelected].left(); } - - if (FlxG.keys.pressed.LEFT && fps > 60) - { - (cast (Lib.current.getChildAt(0), Main)).setFPSCap(fps - 10); - FlxG.save.data.fpsCap = fps - 10; - } - - versionShit.text = "Current FPS Cap: " + fps + " - Description - " + currentDescription; - - - case 'Scroll Speed': + else + { if (FlxG.keys.justPressed.RIGHT) - FlxG.save.data.scrollSpeed += 0.1; - + currentSelectedCat.getOptions()[curSelected].right(); if (FlxG.keys.justPressed.LEFT) - FlxG.save.data.scrollSpeed -= 0.1; - - // caps - - if (FlxG.save.data.scrollSpeed < 1) - FlxG.save.data.scrollSpeed = 1; - - if (FlxG.save.data.scrollSpeed > 10) - FlxG.save.data.scrollSpeed = 10; - - - versionShit.text = "Current Scroll Speed: " + truncateFloat(FlxG.save.data.scrollSpeed,1) + " - Description - " + currentDescription; - default: + currentSelectedCat.getOptions()[curSelected].left(); + } + } + else + { + if (FlxG.keys.pressed.SHIFT) if (FlxG.keys.pressed.RIGHT) - FlxG.save.data.offset += 0.01; - - if (FlxG.keys.pressed.LEFT) - FlxG.save.data.offset -= 0.01; - - versionShit.text = "Offset (Left, Right): " + truncateFloat(FlxG.save.data.offset,2) + " - Description - " + currentDescription; + FlxG.save.data.offset += 1; + else if (FlxG.keys.pressed.LEFT) + FlxG.save.data.offset -= 1; + else if (controls.RIGHT_P) + FlxG.save.data.offset += 0.1; + else if (controls.LEFT_P) + FlxG.save.data.offset -= 0.1; + + versionShit.text = "Offset (Left, Right, Shift to go faster): " + truncateFloat(FlxG.save.data.offset,2) + " - Description - " + currentDescription; } } else @@ -173,7 +163,7 @@ class OptionsMenu extends MusicBeatState if (FlxG.keys.pressed.LEFT) FlxG.save.data.offset-= 0.01; - versionShit.text = "Offset (Left, Right): " + truncateFloat(FlxG.save.data.offset,2) + " - Description - " + currentDescription; + versionShit.text = "Offset (Left, Right, Shift to go faster): " + truncateFloat(FlxG.save.data.offset,2) + " - Description - " + currentDescription; } diff --git a/source/PlayState.hx b/source/PlayState.hx index 762695d..aa54b97 100644 --- a/source/PlayState.hx +++ b/source/PlayState.hx @@ -40,7 +40,7 @@ import openfl.display.BlendMode; import openfl.display.StageQuality; import openfl.filters.ShaderFilter; -#if desktop +#if windows import Discord.DiscordClient; #end @@ -72,7 +72,7 @@ class PlayState extends MusicBeatState var songLength:Float = 0; - #if desktop + #if windows // Discord RPC variables var storyDifficultyText:String = ""; var iconRPC:String = ""; @@ -107,7 +107,9 @@ class PlayState extends MusicBeatState private var combo:Int = 0; public static var misses:Int = 0; private var accuracy:Float = 0.00; + private var accuracyDefault:Float = 0.00; private var totalNotesHit:Float = 0; + private var totalNotesHitDefault:Float = 0; private var totalPlayed:Int = 0; private var ss:Bool = false; @@ -154,10 +156,10 @@ class PlayState extends MusicBeatState var talking:Bool = true; var songScore:Int = 0; + var songScoreDef:Int = 0; var scoreTxt:FlxText; var replayTxt:FlxText; - public static var campaignScore:Int = 0; var defaultCamZoom:Float = 1.05; @@ -172,16 +174,16 @@ class PlayState extends MusicBeatState public static var timeCurrently:Float = 0; public static var timeCurrentlyR:Float = 0; + + // Will fire once to prevent debug spam messages and broken animations + private var triggeredAlready:Bool = false; + + // Will decide if she's even allowed to headbang at all depending on the song + private var allowedToHeadbang:Bool = false; override public function create() { - if (FlxG.save.data.etternaMode) - Conductor.safeFrames = 5; // 116ms hit window (j3-4) - else - Conductor.safeFrames = 10; // 166ms hit window (j1) - - if (FlxG.sound.music != null) FlxG.sound.music.stop(); @@ -195,7 +197,7 @@ class PlayState extends MusicBeatState repPresses = 0; repReleases = 0; - #if desktop + #if windows // Making difficulty text for Discord Rich Presence. switch (storyDifficulty) { @@ -257,6 +259,8 @@ class PlayState extends MusicBeatState Conductor.mapBPMChanges(SONG); Conductor.changeBPM(SONG.bpm); + trace('INFORMATION ABOUT WHAT U PLAYIN WIT:\nFRAMES: ' + Conductor.safeFrames + '\nZONE: ' + Conductor.safeZoneOffset + '\nTS: ' + Conductor.timeScale); + switch (SONG.song.toLowerCase()) { case 'tutorial': @@ -1150,42 +1154,46 @@ class PlayState extends MusicBeatState songLength = FlxG.sound.music.length; if (FlxG.save.data.songPosition) - { - remove(songPosBG); - remove(songPosBar); - remove(songName); + { + remove(songPosBG); + remove(songPosBar); + remove(songName); - songPosBG = new FlxSprite(0, 10).loadGraphic(Paths.image('healthBar')); - if (FlxG.save.data.downscroll) - songPosBG.y = FlxG.height * 0.9 + 45; - songPosBG.screenCenter(X); - songPosBG.scrollFactor.set(); - add(songPosBG); + songPosBG = new FlxSprite(0, 10).loadGraphic(Paths.image('healthBar')); + if (FlxG.save.data.downscroll) + songPosBG.y = FlxG.height * 0.9 + 45; + songPosBG.screenCenter(X); + songPosBG.scrollFactor.set(); + add(songPosBG); - songPosBar = new FlxBar(songPosBG.x + 4, songPosBG.y + 4, LEFT_TO_RIGHT, Std.int(songPosBG.width - 8), Std.int(songPosBG.height - 8), this, - 'songPositionBar', 0, songLength - 1000); - songPosBar.numDivisions = 1000; - songPosBar.scrollFactor.set(); - songPosBar.createFilledBar(FlxColor.GRAY, FlxColor.LIME); - add(songPosBar); - - var songName = new FlxText(songPosBG.x + (songPosBG.width / 2) - 20,songPosBG.y,0,SONG.song, 16); - if (FlxG.save.data.downscroll) - songName.y -= 3; - songName.setFormat(Paths.font("vcr.ttf"), 16, FlxColor.WHITE, RIGHT, FlxTextBorderStyle.OUTLINE,FlxColor.BLACK); - songName.scrollFactor.set(); - add(songName); + songPosBar = new FlxBar(songPosBG.x + 4, songPosBG.y + 4, LEFT_TO_RIGHT, Std.int(songPosBG.width - 8), Std.int(songPosBG.height - 8), this, + 'songPositionBar', 0, songLength - 1000); + songPosBar.numDivisions = 1000; + songPosBar.scrollFactor.set(); + songPosBar.createFilledBar(FlxColor.GRAY, FlxColor.LIME); + add(songPosBar); - songPosBG.cameras = [camHUD]; - songPosBar.cameras = [camHUD]; - songName.cameras = [camHUD]; - } + var songName = new FlxText(songPosBG.x + (songPosBG.width / 2) - 20,songPosBG.y,0,SONG.song, 16); + if (FlxG.save.data.downscroll) + songName.y -= 3; + songName.setFormat(Paths.font("vcr.ttf"), 16, FlxColor.WHITE, RIGHT, FlxTextBorderStyle.OUTLINE,FlxColor.BLACK); + songName.scrollFactor.set(); + add(songName); - #if desktop + songPosBG.cameras = [camHUD]; + songPosBar.cameras = [camHUD]; + songName.cameras = [camHUD]; + } + + // Song check real quick + switch(curSong) + { + case 'Bopeebo' | 'Philly' | 'Blammed' | 'Cocoa' | 'Eggnog': allowedToHeadbang = true; + default: allowedToHeadbang = false; + } + + #if windows // Updating Discord Rich Presence (with Time Left) - - - DiscordClient.changePresence(detailsText + " " + SONG.song + " (" + storyDifficultyText + ") " + generateRanking(), "\nAcc: " + truncateFloat(accuracy, 2) + "% | Score: " + songScore + " | Misses: " + misses , iconRPC); #end } @@ -1225,7 +1233,9 @@ class PlayState extends MusicBeatState for (songNotes in section.sectionNotes) { - var daStrumTime:Float = songNotes[0]; + var daStrumTime:Float = songNotes[0] + FlxG.save.data.offset; + if (daStrumTime < 0) + daStrumTime = 0; var daNoteData:Int = Std.int(songNotes[1] % 4); var gottaHitNote:Bool = section.mustHitSection; @@ -1411,7 +1421,7 @@ class PlayState extends MusicBeatState vocals.pause(); } - #if desktop + #if windows DiscordClient.changePresence("PAUSED on " + SONG.song + " (" + storyDifficultyText + ") " + generateRanking(), "Acc: " + truncateFloat(accuracy, 2) + "% | Score: " + songScore + " | Misses: " + misses , iconRPC); #end if (!startTimer.finished) @@ -1434,7 +1444,7 @@ class PlayState extends MusicBeatState startTimer.active = true; paused = false; - #if desktop + #if windows if (startTimer.finished) { DiscordClient.changePresence(detailsText + " " + SONG.song + " (" + storyDifficultyText + ") " + generateRanking(), "\nAcc: " + truncateFloat(accuracy, 2) + "% | Score: " + songScore + " | Misses: " + misses, iconRPC, true, songLength - Conductor.songPosition); @@ -1459,7 +1469,7 @@ class PlayState extends MusicBeatState vocals.time = Conductor.songPosition; vocals.play(); - #if desktop + #if windows DiscordClient.changePresence(detailsText + " " + SONG.song + " (" + storyDifficultyText + ") " + generateRanking(), "\nAcc: " + truncateFloat(accuracy, 2) + "% | Score: " + songScore + " | Misses: " + misses , iconRPC); #end } @@ -1615,7 +1625,7 @@ class PlayState extends MusicBeatState { if (FlxG.save.data.accuracyDisplay) { - scoreTxt.text = (FlxG.save.data.npsDisplay ? "NPS: " + nps + " | " : "") + "Score:" + (FlxG.save.data.etternaMode ? Math.max(0,etternaModeScore) + " (" + songScore + ")" : "" + songScore) + " | Combo Breaks:" + misses + " | Accuracy:" + truncateFloat(accuracy, 2) + "% | " + generateRanking(); + scoreTxt.text = (FlxG.save.data.npsDisplay ? "NPS: " + nps + " | " : "") + "Score:" + (Conductor.safeFrames != 10 ? songScore + " (" + songScoreDef + ")" : "" + songScore) + " | Combo Breaks:" + misses + " | Accuracy:" + truncateFloat(accuracy, 2) + "% | " + generateRanking(); } else { @@ -1645,7 +1655,7 @@ class PlayState extends MusicBeatState if (FlxG.keys.justPressed.SEVEN) { - #if desktop + #if windows DiscordClient.changePresence("Chart Editor", null, null, true); #end FlxG.switchState(new ChartingState()); @@ -1725,11 +1735,102 @@ class PlayState extends MusicBeatState if (generatedMusic && PlayState.SONG.notes[Std.int(curStep / 16)] != null) { - if (curBeat % 4 == 0) + // Make sure Girlfriend cheers only for certain songs + if(allowedToHeadbang) { - // trace(PlayState.SONG.notes[Std.int(curStep / 16)].mustHitSection); + // Don't animate GF if something else is already animating her (eg. train passing) + if(gf.animation.curAnim.name == 'danceLeft' || gf.animation.curAnim.name == 'danceRight' || gf.animation.curAnim.name == 'idle') + { + // Per song treatment since some songs will only have the 'Hey' at certain times + switch(curSong) + { + case 'Philly': + { + // General duration of the song + if(curBeat < 250) + { + // Beats to skip or to stop GF from cheering + if(curBeat != 184 && curBeat != 216) + { + if(curBeat % 16 == 8) + { + // Just a garantee that it'll trigger just once + if(!triggeredAlready) + { + gf.playAnim('cheer'); + triggeredAlready = true; + } + }else triggeredAlready = false; + } + } + } + case 'Bopeebo': + { + // Where it starts || where it ends + if(curBeat > 5 && curBeat < 130) + { + if(curBeat % 8 == 7) + { + if(!triggeredAlready) + { + gf.playAnim('cheer'); + triggeredAlready = true; + } + }else triggeredAlready = false; + } + } + case 'Blammed': + { + if(curBeat > 30 && curBeat < 190) + { + if(curBeat < 90 || curBeat > 128) + { + if(curBeat % 4 == 2) + { + if(!triggeredAlready) + { + gf.playAnim('cheer'); + triggeredAlready = true; + } + }else triggeredAlready = false; + } + } + } + case 'Cocoa': + { + if(curBeat < 170) + { + if(curBeat < 65 || curBeat > 130 && curBeat < 145) + { + if(curBeat % 16 == 15) + { + if(!triggeredAlready) + { + gf.playAnim('cheer'); + triggeredAlready = true; + } + }else triggeredAlready = false; + } + } + } + case 'Eggnog': + { + if(curBeat > 10 && curBeat != 111 && curBeat < 220) + { + if(curBeat % 8 == 7) + { + if(!triggeredAlready) + { + gf.playAnim('cheer'); + triggeredAlready = true; + } + }else triggeredAlready = false; + } + } + } + } } - + 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); @@ -1839,7 +1940,7 @@ class PlayState extends MusicBeatState openSubState(new GameOverSubstate(boyfriend.getScreenPosition().x, boyfriend.getScreenPosition().y)); - #if desktop + #if windows // Game Over doesn't get his own variable because it's only used here DiscordClient.changePresence("GAME OVER -- " + SONG.song + " (" + storyDifficultyText + ") " + generateRanking(),"\nAcc: " + truncateFloat(accuracy, 2) + "% | Score: " + songScore + " | Misses: " + misses , iconRPC); #end @@ -2058,8 +2159,8 @@ class PlayState extends MusicBeatState private function popUpScore(daNote:Note):Void { - var noteDiff:Float = Math.abs(daNote.strumTime - Conductor.songPosition); - var wife:Float = EtternaFunctions.wife3(noteDiff, FlxG.save.data.etternaMode ? 1 : 1.7); + var noteDiff:Float = Math.abs(Conductor.songPosition - daNote.strumTime); + var wife:Float = EtternaFunctions.wife3(noteDiff, Conductor.timeScale); // boyfriend.playAnim('hey'); vocals.volume = 1; @@ -2107,9 +2208,6 @@ class PlayState extends MusicBeatState sicks++; } - if (FlxG.save.data.etternaMode) - etternaModeScore += Math.round(score / wife); - // trace('Wife accuracy loss: ' + wife + ' | Rating: ' + daRating + ' | Score: ' + score + ' | Weight: ' + (1 - wife)); if (daRating != 'shit' || daRating != 'bad') @@ -2117,6 +2215,7 @@ class PlayState extends MusicBeatState songScore += Math.round(score); + songScoreDef += Math.round(ConvertScore.convertScore(noteDiff)); /* if (combo > 60) daRating = 'sick'; @@ -2198,6 +2297,8 @@ class PlayState extends MusicBeatState add(currentTimingShown); + + var comboSpr:FlxSprite = new FlxSprite().loadGraphic(Paths.image(pixelShitPart1 + 'combo' + pixelShitPart2)); comboSpr.screenCenter(); comboSpr.x = rating.x; @@ -2463,14 +2564,7 @@ class PlayState extends MusicBeatState { var noteDiff:Float = Math.abs(daNote.strumTime - Conductor.songPosition); - if (noteDiff > Conductor.safeZoneOffset * 0.70 || noteDiff < Conductor.safeZoneOffset * -0.70) - daNote.rating = "shit"; - else if (noteDiff > Conductor.safeZoneOffset * 0.50 || noteDiff < Conductor.safeZoneOffset * -0.50) - daNote.rating = "bad"; - else if (noteDiff > Conductor.safeZoneOffset * 0.45 || noteDiff < Conductor.safeZoneOffset * -0.45) - daNote.rating = "good"; - else if (noteDiff < Conductor.safeZoneOffset * 0.44 && noteDiff > Conductor.safeZoneOffset * -0.44) - daNote.rating = "sick"; + daNote.rating = Ratings.CalculateRating(noteDiff); if (NearlyEquals(daNote.strumTime,rep.replay.keyPresses[repPresses].time, 30)) { @@ -2520,14 +2614,7 @@ class PlayState extends MusicBeatState { var noteDiff:Float = Math.abs(daNote.strumTime - Conductor.songPosition); - if (noteDiff > Conductor.safeZoneOffset * 0.70 || noteDiff < Conductor.safeZoneOffset * -0.70) - daNote.rating = "shit"; - else if (noteDiff > Conductor.safeZoneOffset * 0.50 || noteDiff < Conductor.safeZoneOffset * -0.50) - daNote.rating = "bad"; - else if (noteDiff > Conductor.safeZoneOffset * 0.45 || noteDiff < Conductor.safeZoneOffset * -0.45) - daNote.rating = "good"; - else if (noteDiff < Conductor.safeZoneOffset * 0.44 && noteDiff > Conductor.safeZoneOffset * -0.44) - daNote.rating = "sick"; + daNote.rating = Ratings.CalculateRating(noteDiff); goodNoteHit(daNote); trace('force note hit'); @@ -2776,12 +2863,9 @@ class PlayState extends MusicBeatState */ function updateAccuracy() { - if (misses > 0 || accuracy < 96) - fc = false; - else - fc = true; totalPlayed += 1; accuracy = Math.max(0,totalNotesHit / totalPlayed * 100); + accuracyDefault = Math.max(0, totalNotesHitDefault / totalPlayed * 100); } @@ -2870,14 +2954,7 @@ class PlayState extends MusicBeatState var noteDiff:Float = Math.abs(note.strumTime - Conductor.songPosition); - if (noteDiff > Conductor.safeZoneOffset * 0.70 || noteDiff < Conductor.safeZoneOffset * -0.70) - note.rating = "shit"; - else if (noteDiff > Conductor.safeZoneOffset * 0.50 || noteDiff < Conductor.safeZoneOffset * -0.50) - note.rating = "bad"; - else if (noteDiff > Conductor.safeZoneOffset * 0.45 || noteDiff < Conductor.safeZoneOffset * -0.45) - note.rating = "good"; - else if (noteDiff < Conductor.safeZoneOffset * 0.44 && noteDiff > Conductor.safeZoneOffset * -0.44) - note.rating = "sick"; + note.rating = Ratings.CalculateRating(noteDiff); if (!note.isSustainNote) notesHitArray.push(Date.now()); @@ -3034,7 +3111,7 @@ class PlayState extends MusicBeatState // yes this updates every step. // yes this is bad // but i'm doing it to update misses and accuracy - #if desktop + #if windows // Song duration in a float, useful for the time left feature songLength = FlxG.sound.music.length; diff --git a/source/Ratings.hx b/source/Ratings.hx new file mode 100644 index 0000000..46e9ffb --- /dev/null +++ b/source/Ratings.hx @@ -0,0 +1,30 @@ +class Ratings +{ + public static function CalculateRating(noteDiff:Float, ?customSafeZone:Float):String + { + + var customTimeScale = Conductor.timeScale; + + if (customSafeZone != null) + customTimeScale = customSafeZone / 166; + + // trace(customTimeScale + ' vs ' + Conductor.timeScale); + + // I HATE THIS IF CONDITION + // IF LEMON SEES THIS I'M SORRY :( + + if (noteDiff > 135 * customTimeScale) // way early + return "shit"; + else if (noteDiff > 90 * customTimeScale) // early + return "bad"; + else if (noteDiff > 45 * customTimeScale) // your kinda there + return "good"; + else if (noteDiff < -45 * customTimeScale) // little late + return "good"; + else if (noteDiff < -90 * customTimeScale) // late + return "bad"; + else if (noteDiff < -135 * customTimeScale) // late as fuck + return "shit"; + return "sick"; + } +} \ No newline at end of file diff --git a/source/StoryMenuState.hx b/source/StoryMenuState.hx index c2e1cb7..a7677a5 100644 --- a/source/StoryMenuState.hx +++ b/source/StoryMenuState.hx @@ -13,7 +13,7 @@ import flixel.util.FlxColor; import flixel.util.FlxTimer; import lime.net.curl.CURLCode; -#if desktop +#if windows import Discord.DiscordClient; #end @@ -74,7 +74,7 @@ class StoryMenuState extends MusicBeatState override function create() { - #if desktop + #if windows // Updating Discord Rich Presence DiscordClient.changePresence("In the Menus", null); #end diff --git a/source/TitleState.hx b/source/TitleState.hx index ec98454..e38e58e 100644 --- a/source/TitleState.hx +++ b/source/TitleState.hx @@ -24,8 +24,11 @@ import io.newgrounds.NG; import lime.app.Application; import openfl.Assets; -#if desktop +#if windows import Discord.DiscordClient; +#end + +#if desktop import sys.thread.Thread; #end @@ -59,7 +62,7 @@ class TitleState extends MusicBeatState PlayerSettings.init(); - #if desktop + #if windows DiscordClient.initialize(); Application.current.onExit.add (function (exitCode) {