From 6ce80b1c5badc5943d6c060d20534bcd47523c2c Mon Sep 17 00:00:00 2001 From: KadeDev Date: Tue, 9 Mar 2021 11:51:15 -0800 Subject: [PATCH] Inital Kade Engine Commit --- source/Controls.hx | 21 +- source/CoolUtil.hx | 12 + source/FreeplayState.hx | 13 +- source/LoadReplayState.hx | 201 +++++++ source/Main.hx | 2 +- source/MainMenuState.hx | 18 +- source/OptionsMenu.hx | 137 +++-- source/PlayState.hx | 1101 ++++++++++++++++++++++--------------- source/Replay.hx | 101 ++++ source/TitleState.hx | 7 +- 10 files changed, 1088 insertions(+), 525 deletions(-) create mode 100644 source/LoadReplayState.hx create mode 100644 source/Replay.hx diff --git a/source/Controls.hx b/source/Controls.hx index 7d1e2c4..4977667 100644 --- a/source/Controls.hx +++ b/source/Controls.hx @@ -498,22 +498,21 @@ class Controls extends FlxActionSet switch (scheme) { case Solo: - inline bindKeys(Control.UP, [W, FlxKey.UP]); - inline bindKeys(Control.DOWN, [S, FlxKey.DOWN]); - inline bindKeys(Control.LEFT, [A, FlxKey.LEFT]); - inline bindKeys(Control.RIGHT, [D, FlxKey.RIGHT]); + inline bindKeys(Control.UP, [J, FlxKey.UP]); + inline bindKeys(Control.DOWN, [F, FlxKey.DOWN]); + inline bindKeys(Control.LEFT, [D, FlxKey.LEFT]); + inline bindKeys(Control.RIGHT, [K, FlxKey.RIGHT]); inline bindKeys(Control.ACCEPT, [Z, SPACE, ENTER]); inline bindKeys(Control.BACK, [BACKSPACE, ESCAPE]); inline bindKeys(Control.PAUSE, [P, ENTER, ESCAPE]); inline bindKeys(Control.RESET, [R]); case Duo(true): - inline bindKeys(Control.UP, [W]); - inline bindKeys(Control.DOWN, [S]); - inline bindKeys(Control.LEFT, [A]); - inline bindKeys(Control.RIGHT, [D]); - inline bindKeys(Control.ACCEPT, [G, Z]); - inline bindKeys(Control.BACK, [H, X]); - inline bindKeys(Control.PAUSE, [ONE]); + inline bindKeys(Control.UP, [W, FlxKey.UP]); + inline bindKeys(Control.DOWN, [S, FlxKey.DOWN]); + inline bindKeys(Control.LEFT, [A, FlxKey.LEFT]); + inline bindKeys(Control.RIGHT, [D, FlxKey.RIGHT]); + inline bindKeys(Control.ACCEPT, [G, Z, SPACE, ENTER]); + inline bindKeys(Control.BACK, [BACKSPACE, ESCAPE]); inline bindKeys(Control.RESET, [R]); case Duo(false): inline bindKeys(Control.UP, [FlxKey.UP]); diff --git a/source/CoolUtil.hx b/source/CoolUtil.hx index 8c24449..92cc2c0 100644 --- a/source/CoolUtil.hx +++ b/source/CoolUtil.hx @@ -24,6 +24,18 @@ class CoolUtil return daList; } + + public static function coolStringFile(path:String):Array + { + var daList:Array = path.trim().split('\n'); + + for (i in 0...daList.length) + { + daList[i] = daList[i].trim(); + } + + return daList; + } public static function numberArray(max:Int, ?min = 0):Array { diff --git a/source/FreeplayState.hx b/source/FreeplayState.hx index 6dec6f1..ddd8d16 100644 --- a/source/FreeplayState.hx +++ b/source/FreeplayState.hx @@ -53,22 +53,13 @@ class FreeplayState extends MusicBeatState isDebug = true; #end - if (StoryMenuState.weekUnlocked[2] || isDebug) addWeek(['Bopeebo', 'Fresh', 'Dadbattle'], 1, ['dad']); - - if (StoryMenuState.weekUnlocked[2] || isDebug) addWeek(['Spookeez', 'South', 'Monster'], 2, ['spooky']); - - if (StoryMenuState.weekUnlocked[3] || isDebug) addWeek(['Pico', 'Philly', 'Blammed'], 3, ['pico']); - if (StoryMenuState.weekUnlocked[4] || isDebug) addWeek(['Satin-Panties', 'High', 'Milf'], 4, ['mom']); - - if (StoryMenuState.weekUnlocked[5] || isDebug) addWeek(['Cocoa', 'Eggnog', 'Winter-Horrorland'], 5, ['parents-christmas', 'parents-christmas', 'monster-christmas']); - - if (StoryMenuState.weekUnlocked[6] || isDebug) + addWeek(['Senpai', 'Roses', 'Thorns'], 6, ['senpai', 'senpai', 'spirit']); // LOAD MUSIC @@ -250,7 +241,7 @@ class FreeplayState extends MusicBeatState function changeSelection(change:Int = 0) { #if !switch - NGio.logEvent('Fresh'); + // NGio.logEvent('Fresh'); #end // NGio.logEvent('Fresh'); diff --git a/source/LoadReplayState.hx b/source/LoadReplayState.hx new file mode 100644 index 0000000..e4bb136 --- /dev/null +++ b/source/LoadReplayState.hx @@ -0,0 +1,201 @@ +package; + +import Controls.KeyboardScheme; +import Controls.Control; +import flash.text.TextField; +import flixel.FlxG; +import flixel.FlxSprite; +import flixel.addons.display.FlxGridOverlay; +import flixel.group.FlxGroup.FlxTypedGroup; +import flixel.input.keyboard.FlxKey; +import flixel.math.FlxMath; +import flixel.text.FlxText; +import flixel.util.FlxColor; +import lime.utils.Assets; +#if sys +import sys.io.File; +#end + +class LoadReplayState extends MusicBeatState +{ + var selector:FlxText; + var curSelected:Int = 0; + + var songs:Array = []; + + var controlsStrings:Array = []; + var actualNames:Array = []; + + private var grpControls:FlxTypedGroup; + var versionShit:FlxText; + var poggerDetails:FlxText; + override function create() + { + var menuBG:FlxSprite = new FlxSprite().loadGraphic(Paths.image('menuDesat')); + #if sys + controlsStrings = sys.FileSystem.readDirectory(Sys.getCwd() + "\\assets\\replays\\"); + #end + trace(controlsStrings); + + controlsStrings.sort(Reflect.compare); + + addWeek(['Bopeebo', 'Fresh', 'Dadbattle'], 1, ['dad']); + addWeek(['Spookeez', 'South', 'Monster'], 2, ['spooky']); + addWeek(['Pico', 'Philly', 'Blammed'], 3, ['pico']); + + addWeek(['Satin-Panties', 'High', 'Milf'], 4, ['mom']); + addWeek(['Cocoa', 'Eggnog', 'Winter-Horrorland'], 5, ['parents-christmas', 'parents-christmas', 'monster-christmas']); + + addWeek(['Senpai', 'Roses', 'Thorns'], 6, ['senpai', 'senpai', 'spirit']); + + + for(i in 0...controlsStrings.length) + { + var string:String = controlsStrings[i]; + actualNames[i] = string; + var rep:Replay = Replay.LoadReplay(string); + controlsStrings[i] = string.split("time")[0] + " " + (rep.replay.songDiff == 2 ? "HARD" : rep.replay.songDiff == 1 ? "EASY" : "NORMAL"); + } + + if (controlsStrings.length == 0) + controlsStrings.push("No Replays..."); + + menuBG.color = 0xFFea71fd; + menuBG.setGraphicSize(Std.int(menuBG.width * 1.1)); + menuBG.updateHitbox(); + menuBG.screenCenter(); + menuBG.antialiasing = true; + add(menuBG); + + grpControls = new FlxTypedGroup(); + add(grpControls); + + for (i in 0...controlsStrings.length) + { + var controlLabel:Alphabet = new Alphabet(0, (70 * i) + 30, controlsStrings[i], true, false); + controlLabel.isMenuItem = true; + controlLabel.targetY = i; + grpControls.add(controlLabel); + // DONT PUT X IN THE FIRST PARAMETER OF new ALPHABET() !! + } + + + versionShit = new FlxText(5, FlxG.height - 34, 0, "Replay Loader (ESCAPE TO GO BACK)\nNOTICE!!!! Replays are in a beta stage, and they are probably not 100% correct. expect misses and other stuff that isn't there!", 12); + versionShit.scrollFactor.set(); + versionShit.setFormat("VCR OSD Mono", 16, FlxColor.WHITE, LEFT, FlxTextBorderStyle.OUTLINE, FlxColor.BLACK); + add(versionShit); + + + poggerDetails = new FlxText(5, 34, 0, "Replay Details - \nnone", 12); + poggerDetails.scrollFactor.set(); + poggerDetails.setFormat("VCR OSD Mono", 16, FlxColor.WHITE, LEFT, FlxTextBorderStyle.OUTLINE, FlxColor.BLACK); + add(poggerDetails); + + changeSelection(0); + + super.create(); + } + + public function getWeekNumbFromSong(songName:String):Int + { + var week:Int = 0; + for (i in 0...songs.length) + { + var pog:FreeplayState.SongMetadata = songs[i]; + if (pog.songName.toLowerCase() == songName) + week = pog.week; + } + return week; + } + + public function addSong(songName:String, weekNum:Int, songCharacter:String) + { + songs.push(new FreeplayState.SongMetadata(songName, weekNum, songCharacter)); + } + + public function addWeek(songs:Array, weekNum:Int, ?songCharacters:Array) + { + if (songCharacters == null) + songCharacters = ['bf']; + + var num:Int = 0; + for (song in songs) + { + addSong(song, weekNum, songCharacters[num]); + + if (songCharacters.length != 1) + num++; + } + } + + + override function update(elapsed:Float) + { + super.update(elapsed); + + if (controls.BACK) + FlxG.switchState(new OptionsMenu()); + if (controls.UP_P) + changeSelection(-1); + if (controls.DOWN_P) + changeSelection(1); + + + if (controls.ACCEPT && grpControls.members[curSelected].text != "No Replays...") + { + trace('loading ' + actualNames[curSelected]); + PlayState.rep = Replay.LoadReplay(actualNames[curSelected]); + + PlayState.loadRep = true; + + var poop:String = Highscore.formatSong(PlayState.rep.replay.songName.toLowerCase(), PlayState.rep.replay.songDiff); + + PlayState.SONG = Song.loadFromJson(poop, PlayState.rep.replay.songName.toLowerCase()); + PlayState.isStoryMode = false; + PlayState.storyDifficulty = PlayState.rep.replay.songDiff; + PlayState.storyWeek = getWeekNumbFromSong(PlayState.rep.replay.songName); + LoadingState.loadAndSwitchState(new PlayState()); + } + } + + var isSettingControl:Bool = false; + + function changeSelection(change:Int = 0) + { + #if !switch + // NGio.logEvent('Fresh'); + #end + + FlxG.sound.play(Paths.sound('scrollMenu'), 0.4); + + curSelected += change; + + if (curSelected < 0) + curSelected = grpControls.length - 1; + if (curSelected >= grpControls.length) + curSelected = 0; + + var rep:Replay = Replay.LoadReplay(actualNames[curSelected]); + + poggerDetails.text = "Replay Details - \nDate Created: " + rep.replay.timestamp + "\nSong: " + rep.replay.songName + "\nReplay Version: " + (rep.replay.replayGameVer != Replay.version ? "OUTDATED" : "Latest"); + + // selector.y = (70 * curSelected) + 30; + + var bullShit:Int = 0; + + for (item in grpControls.members) + { + item.targetY = bullShit - curSelected; + bullShit++; + + item.alpha = 0.6; + // item.setGraphicSize(Std.int(item.width * 0.8)); + + if (item.targetY == 0) + { + item.alpha = 1; + // item.setGraphicSize(Std.int(item.width)); + } + } + } +} diff --git a/source/Main.hx b/source/Main.hx index 7f287f8..8c7c9ac 100644 --- a/source/Main.hx +++ b/source/Main.hx @@ -14,7 +14,7 @@ class Main extends Sprite 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 zoom:Float = -1; // If -1, zoom is automatically calculated to fit the window dimensions. - var framerate:Int = 60; // How many frames per second the game should run at. + var framerate:Int = 120; // How many frames per second the game should run at. var skipSplash:Bool = true; // Whether to skip the flixel splash screen that appears in release mode. var startFullscreen:Bool = false; // Whether to start the game in fullscreen on desktop targets diff --git a/source/MainMenuState.hx b/source/MainMenuState.hx index 4b3a8f1..8bc8726 100644 --- a/source/MainMenuState.hx +++ b/source/MainMenuState.hx @@ -3,7 +3,6 @@ package; import flixel.FlxG; import flixel.FlxObject; import flixel.FlxSprite; -import flixel.addons.transition.FlxTransitionableState; import flixel.effects.FlxFlicker; import flixel.graphics.frames.FlxAtlasFrames; import flixel.group.FlxGroup.FlxTypedGroup; @@ -28,14 +27,18 @@ class MainMenuState extends MusicBeatState var optionShit:Array = ['story mode', 'freeplay']; #end + var newGaming:FlxText; + var newGaming2:FlxText; + var newInput:Bool = true; + + public static var kadeEngineVer:String = "1.0"; + public static var gameVer:String = "0.2.7.1"; + var magenta:FlxSprite; var camFollow:FlxObject; override function create() { - transIn = FlxTransitionableState.defaultTransIn; - transOut = FlxTransitionableState.defaultTransOut; - if (!FlxG.sound.music.playing) { FlxG.sound.playMusic(Paths.music('freakyMenu')); @@ -88,13 +91,14 @@ class MainMenuState extends MusicBeatState FlxG.camera.follow(camFollow, null, 0.06); - var versionShit:FlxText = new FlxText(5, FlxG.height - 18, 0, "v" + Application.current.meta.get('version'), 12); + var versionShit:FlxText = new FlxText(5, FlxG.height - 18, 0, gameVer + " FNF - " + kadeEngineVer + " Kade Engine", 12); versionShit.scrollFactor.set(); versionShit.setFormat("VCR OSD Mono", 16, FlxColor.WHITE, LEFT, FlxTextBorderStyle.OUTLINE, FlxColor.BLACK); add(versionShit); // NG.core.calls.event.logEvent('swag').send(); + changeItem(); super.create(); @@ -149,7 +153,7 @@ class MainMenuState extends MusicBeatState { if (curSelected != spr.ID) { - FlxTween.tween(spr, {alpha: 0}, 0.4, { + FlxTween.tween(spr, {alpha: 0}, 1.3, { ease: FlxEase.quadOut, onComplete: function(twn:FlxTween) { @@ -174,8 +178,6 @@ class MainMenuState extends MusicBeatState trace("Freeplay Menu Selected"); case 'options': - FlxTransitionableState.skipNextTransIn = true; - FlxTransitionableState.skipNextTransOut = true; FlxG.switchState(new OptionsMenu()); } }); diff --git a/source/OptionsMenu.hx b/source/OptionsMenu.hx index 0c5b284..1678f41 100644 --- a/source/OptionsMenu.hx +++ b/source/OptionsMenu.hx @@ -1,5 +1,6 @@ package; +import Controls.KeyboardScheme; import Controls.Control; import flash.text.TextField; import flixel.FlxG; @@ -20,11 +21,23 @@ class OptionsMenu extends MusicBeatState var controlsStrings:Array = []; private var grpControls:FlxTypedGroup; - + var versionShit:FlxText; override function create() { + if (FlxG.save.data.newInput == null) + FlxG.save.data.newInput = true; + + if (FlxG.save.data.downscroll == null) + FlxG.save.data.downscroll = false; + + if (FlxG.save.data.dfjk == null) + FlxG.save.data.dfjk = false; + var menuBG:FlxSprite = new FlxSprite().loadGraphic(Paths.image('menuDesat')); - controlsStrings = CoolUtil.coolTextFile(Paths.txt('controls')); + controlsStrings = CoolUtil.coolStringFile((FlxG.save.data.dfjk ? 'DFJK' : 'WASD') + "\n" + (FlxG.save.data.newInput ? "New input" : "Old Input") + "\n" + (FlxG.save.data.downscroll ? 'Downscroll' : 'Upscroll') + "\nLoad replays"); + + trace(controlsStrings); + menuBG.color = 0xFFea71fd; menuBG.setGraphicSize(Std.int(menuBG.width * 1.1)); menuBG.updateHitbox(); @@ -32,77 +45,95 @@ class OptionsMenu extends MusicBeatState menuBG.antialiasing = true; add(menuBG); - /* - grpControls = new FlxTypedGroup(); - add(grpControls); + grpControls = new FlxTypedGroup(); + add(grpControls); - for (i in 0...controlsStrings.length) - { - if (controlsStrings[i].indexOf('set') != -1) - { - var controlLabel:Alphabet = new Alphabet(0, (70 * i) + 30, controlsStrings[i].substring(3) + ': ' + controlsStrings[i + 1], true, false); - controlLabel.isMenuItem = true; - controlLabel.targetY = i; - grpControls.add(controlLabel); - } - // DONT PUT X IN THE FIRST PARAMETER OF new ALPHABET() !! - } - */ + for (i in 0...controlsStrings.length) + { + var controlLabel:Alphabet = new Alphabet(0, (70 * i) + 30, controlsStrings[i], true, false); + controlLabel.isMenuItem = true; + controlLabel.targetY = i; + grpControls.add(controlLabel); + // DONT PUT X IN THE FIRST PARAMETER OF new ALPHABET() !! + } + + + versionShit = new FlxText(5, FlxG.height - 18, 0, "Offset (Left, Right): " + FlxG.save.data.offset, 12); + versionShit.scrollFactor.set(); + versionShit.setFormat("VCR OSD Mono", 16, FlxColor.WHITE, LEFT, FlxTextBorderStyle.OUTLINE, FlxColor.BLACK); + add(versionShit); super.create(); - - openSubState(new OptionsSubState()); } override function update(elapsed:Float) { super.update(elapsed); - /* + if (controls.BACK) + FlxG.switchState(new MainMenuState()); + if (controls.UP_P) + changeSelection(-1); + if (controls.DOWN_P) + changeSelection(1); + + if (controls.RIGHT_R) + { + FlxG.save.data.offset++; + versionShit.text = "Offset (Left, Right): " + FlxG.save.data.offset; + } + + if (controls.LEFT_R) + { + FlxG.save.data.offset--; + versionShit.text = "Offset (Left, Right): " + FlxG.save.data.offset; + } + + if (controls.ACCEPT) { - changeBinding(); + if (curSelected != 3) + grpControls.remove(grpControls.members[curSelected]); + switch(curSelected) + { + case 0: + FlxG.save.data.dfjk = !FlxG.save.data.dfjk; + var ctrl:Alphabet = new Alphabet(0, (70 * curSelected) + 30, (FlxG.save.data.dfjk ? 'DFJK' : 'WASD'), true, false); + ctrl.isMenuItem = true; + ctrl.targetY = curSelected; + grpControls.add(ctrl); + if (FlxG.save.data.dfjk) + controls.setKeyboardScheme(KeyboardScheme.Solo, true); + else + controls.setKeyboardScheme(KeyboardScheme.Duo(true), true); + + case 1: + FlxG.save.data.newInput = !FlxG.save.data.newInput; + var ctrl:Alphabet = new Alphabet(0, (70 * curSelected) + 30, (FlxG.save.data.newInput ? "New input" : "Old Input"), true, false); + ctrl.isMenuItem = true; + ctrl.targetY = curSelected - 1; + grpControls.add(ctrl); + case 2: + FlxG.save.data.downscroll = !FlxG.save.data.downscroll; + var ctrl:Alphabet = new Alphabet(0, (70 * curSelected) + 30, (FlxG.save.data.downscroll ? 'Downscroll' : 'Upscroll'), true, false); + ctrl.isMenuItem = true; + ctrl.targetY = curSelected - 2; + grpControls.add(ctrl); + case 3: + trace('switch'); + FlxG.switchState(new LoadReplayState()); + } } - - if (isSettingControl) - waitingInput(); - else - { - if (controls.BACK) - FlxG.switchState(new MainMenuState()); - if (controls.UP_P) - changeSelection(-1); - if (controls.DOWN_P) - changeSelection(1); - } - */ - } - - function waitingInput():Void - { - if (FlxG.keys.getIsDown().length > 0) - { - PlayerSettings.player1.controls.replaceBinding(Control.LEFT, Keys, FlxG.keys.getIsDown()[0].ID, null); - } - // PlayerSettings.player1.controls.replaceBinding(Control) } var isSettingControl:Bool = false; - function changeBinding():Void - { - if (!isSettingControl) - { - isSettingControl = true; - } - } - function changeSelection(change:Int = 0) { #if !switch - NGio.logEvent('Fresh'); + // NGio.logEvent('Fresh'); #end - + FlxG.sound.play(Paths.sound('scrollMenu'), 0.4); curSelected += change; diff --git a/source/PlayState.hx b/source/PlayState.hx index aabb992..919a502 100644 --- a/source/PlayState.hx +++ b/source/PlayState.hx @@ -49,6 +49,14 @@ class PlayState extends MusicBeatState public static var storyWeek:Int = 0; public static var storyPlaylist:Array = []; public static var storyDifficulty:Int = 1; + public static var weekSong:Int = 0; + public static var shits:Int = 0; + public static var bads:Int = 0; + public static var goods:Int = 0; + public static var sicks:Int = 0; + + public static var rep:Replay; + public static var loadRep:Bool = false; var halloweenLevel:Bool = false; @@ -77,6 +85,12 @@ class PlayState extends MusicBeatState private var gfSpeed:Int = 1; private var health:Float = 1; private var combo:Int = 0; + public static var misses:Int = 0; + private var accuracy:Float = 0.00; + private var totalNotesHit:Float = 0; + private var totalPlayed:Int = 0; + private var ss:Bool = false; + private var healthBarBG:FlxSprite; private var healthBar:FlxBar; @@ -106,28 +120,44 @@ class PlayState extends MusicBeatState var bottomBoppers:FlxSprite; var santa:FlxSprite; + var fc:Bool = true; + var bgGirls:BackgroundGirls; var wiggleShit:WiggleEffect = new WiggleEffect(); var talking:Bool = true; var songScore:Int = 0; var scoreTxt:FlxText; + var replayTxt:FlxText; + public static var campaignScore:Int = 0; var defaultCamZoom:Float = 1.05; - // how big to stretch the pixel art assets public static var daPixelZoom:Float = 6; + public static var theFunne:Bool = true; + var funneEffect:FlxSprite; var inCutscene:Bool = false; + public static var repPresses:Int = 0; + public static var repReleases:Int = 0; + + public static var timeCurrently:Float = 0; + public static var timeCurrentlyR:Float = 0; override public function create() { + theFunne = FlxG.save.data.newInput; if (FlxG.sound.music != null) FlxG.sound.music.stop(); + sicks = 0; + bads = 0; + shits = 0; + goods = 0; + // var gameCam:FlxCamera = FlxG.camera; camGame = new FlxCamera(); camHUD = new FlxCamera(); @@ -575,6 +605,8 @@ class PlayState extends MusicBeatState camPos.set(dad.getGraphicMidpoint().x + 300, dad.getGraphicMidpoint().y); } + + boyfriend = new Boyfriend(770, 450, SONG.player1); // REPOSITIONING PER STAGE @@ -677,11 +709,25 @@ class PlayState extends MusicBeatState // healthBar add(healthBar); - scoreTxt = new FlxText(healthBarBG.x + healthBarBG.width - 190, healthBarBG.y + 30, 0, "", 20); - scoreTxt.setFormat(Paths.font("vcr.ttf"), 16, FlxColor.WHITE, RIGHT); + // Add Kade Engine watermark + var kadeEngineWatermark = new FlxText(4,FlxG.height - 4,0,SONG.song + " " + (storyDifficulty == 2 ? "Hard" : storyDifficulty == 1 ? "Normal" : "Easy") + " - KE " + MainMenuState.kadeEngineVer, 16); + kadeEngineWatermark.setFormat(Paths.font("vcr.ttf"), 16, FlxColor.WHITE, RIGHT, FlxTextBorderStyle.OUTLINE,FlxColor.BLACK); + kadeEngineWatermark.scrollFactor.set(); + add(kadeEngineWatermark); + + scoreTxt = new FlxText(healthBarBG.x + healthBarBG.width / 2 - 150, healthBarBG.y + 50, 0, "", 20); + scoreTxt.setFormat(Paths.font("vcr.ttf"), 16, FlxColor.WHITE, RIGHT, FlxTextBorderStyle.OUTLINE,FlxColor.BLACK); scoreTxt.scrollFactor.set(); add(scoreTxt); + replayTxt = new FlxText(healthBarBG.x + healthBarBG.width / 2 - 75, healthBarBG.y + (FlxG.save.data.downscroll ? 100 : -100), 0, "REPLAY", 20); + replayTxt.setFormat(Paths.font("vcr.ttf"), 42, FlxColor.WHITE, RIGHT, FlxTextBorderStyle.OUTLINE,FlxColor.BLACK); + replayTxt.scrollFactor.set(); + if (loadRep) + { + add(replayTxt); + } + iconP1 = new HealthIcon(SONG.player1, true); iconP1.y = healthBar.y - (iconP1.height / 2); add(iconP1); @@ -758,6 +804,9 @@ class PlayState extends MusicBeatState } } + if (!loadRep) + rep = new Replay("na"); + super.create(); } @@ -1236,6 +1285,13 @@ class PlayState extends MusicBeatState var startedCountdown:Bool = false; var canPause:Bool = true; + function truncateFloat( number : Float, precision : Int): Float { + var num = number; + num = num * Math.pow(10, precision); + num = Math.round( num ) / Math.pow(10, precision); + return num; + } + override public function update(elapsed:Float) { #if !debug @@ -1268,7 +1324,7 @@ class PlayState extends MusicBeatState super.update(elapsed); - scoreTxt.text = "Score:" + songScore; + scoreTxt.text = "Score:" + songScore + " | Misses:" + misses + " | Accuracy:" + truncateFloat(accuracy, 2) + "% " + (fc ? "| FC" : misses == 0 ? "| A" : accuracy <= 75 ? "| BAD" : ""); if (FlxG.keys.justPressed.ENTER && startedCountdown && canPause) { @@ -1499,89 +1555,89 @@ class PlayState extends MusicBeatState } if (generatedMusic) - { - notes.forEachAlive(function(daNote:Note) { - if (daNote.y > FlxG.height) - { - daNote.active = false; - daNote.visible = false; - } - else - { - daNote.visible = true; - daNote.active = true; - } - - daNote.y = (strumLine.y - (Conductor.songPosition - daNote.strumTime) * (0.45 * FlxMath.roundDecimal(SONG.speed, 2))); - - // i am so fucking sorry for this if condition - if (daNote.isSustainNote - && daNote.y + daNote.offset.y <= strumLine.y + Note.swagWidth / 2 - && (!daNote.mustPress || (daNote.wasGoodHit || (daNote.prevNote.wasGoodHit && !daNote.canBeHit)))) - { - var swagRect = new FlxRect(0, strumLine.y + Note.swagWidth / 2 - daNote.y, daNote.width * 2, daNote.height * 2); - swagRect.y /= daNote.scale.y; - swagRect.height -= swagRect.y; - - daNote.clipRect = swagRect; - } - - if (!daNote.mustPress && daNote.wasGoodHit) - { - if (SONG.song != 'Tutorial') - camZooming = true; - - var altAnim:String = ""; - - if (SONG.notes[Math.floor(curStep / 16)] != null) + notes.forEachAlive(function(daNote:Note) + { + if (daNote.y > FlxG.height) { - if (SONG.notes[Math.floor(curStep / 16)].altAnim) - altAnim = '-alt'; + daNote.active = false; + daNote.visible = false; } - - switch (Math.abs(daNote.noteData)) + else { - case 0: - dad.playAnim('singLEFT' + altAnim, true); - case 1: - dad.playAnim('singDOWN' + altAnim, true); - case 2: - dad.playAnim('singUP' + altAnim, true); - case 3: - dad.playAnim('singRIGHT' + altAnim, true); + daNote.visible = true; + daNote.active = true; } - - dad.holdTimer = 0; - - if (SONG.needsVoices) - vocals.volume = 1; - - daNote.kill(); - notes.remove(daNote, true); - daNote.destroy(); - } - - // WIP interpolation shit? Need to fix the pause issue - // daNote.y = (strumLine.y - (songTime - daNote.strumTime) * (0.45 * PlayState.SONG.speed)); - - if (daNote.y < -daNote.height) - { - if (daNote.tooLate || !daNote.wasGoodHit) + + if (!daNote.mustPress && daNote.wasGoodHit) { - health -= 0.0475; - vocals.volume = 0; + if (SONG.song != 'Tutorial') + camZooming = true; + + var altAnim:String = ""; + + if (SONG.notes[Math.floor(curStep / 16)] != null) + { + if (SONG.notes[Math.floor(curStep / 16)].altAnim) + altAnim = '-alt'; + } + + switch (Math.abs(daNote.noteData)) + { + case 2: + dad.playAnim('singUP' + altAnim, true); + case 3: + dad.playAnim('singRIGHT' + altAnim, true); + case 1: + dad.playAnim('singDOWN' + altAnim, true); + case 0: + dad.playAnim('singLEFT' + altAnim, true); + } + + dad.holdTimer = 0; + + if (SONG.needsVoices) + vocals.volume = 1; + + daNote.kill(); + notes.remove(daNote, true); + daNote.destroy(); } + + if (FlxG.save.data.downscroll) + daNote.y = (strumLine.y - (Conductor.songPosition - daNote.strumTime) * (-0.45 * FlxMath.roundDecimal(SONG.speed, 2))); + else + daNote.y = (strumLine.y - (Conductor.songPosition - daNote.strumTime) * (0.45 * FlxMath.roundDecimal(SONG.speed, 2))); + //trace(daNote.y); + // WIP interpolation shit? Need to fix the pause issue + // daNote.y = (strumLine.y - (songTime - daNote.strumTime) * (0.45 * PlayState.SONG.speed)); + + if (daNote.y < -daNote.height && !FlxG.save.data.downscroll || daNote.y >= strumLine.y + 106 && FlxG.save.data.downscroll) + { + if (daNote.isSustainNote && daNote.wasGoodHit) + { + daNote.kill(); + notes.remove(daNote, true); + daNote.destroy(); + } + else + { + health -= 0.075; + vocals.volume = 0; + if (theFunne) + noteMiss(daNote.noteData); + } + + daNote.active = false; + daNote.visible = false; + + daNote.kill(); + notes.remove(daNote, true); + daNote.destroy(); + } + }); + } - daNote.active = false; - daNote.visible = false; - - daNote.kill(); - notes.remove(daNote, true); - daNote.destroy(); - } - }); - } if (!inCutscene) keyShit(); @@ -1594,6 +1650,9 @@ class PlayState extends MusicBeatState function endSong():Void { + if (!loadRep) + rep.SaveReplay(); + canPause = false; FlxG.sound.music.volume = 0; vocals.volume = 0; @@ -1675,158 +1734,198 @@ class PlayState extends MusicBeatState var endingSong:Bool = false; private function popUpScore(strumtime:Float):Void - { - var noteDiff:Float = Math.abs(strumtime - Conductor.songPosition); - // boyfriend.playAnim('hey'); - vocals.volume = 1; - - var placement:String = Std.string(combo); - - var coolText:FlxText = new FlxText(0, 0, 0, placement, 32); - coolText.screenCenter(); - coolText.x = FlxG.width * 0.55; - // - - var rating:FlxSprite = new FlxSprite(); - var score:Int = 350; - - var daRating:String = "sick"; - - if (noteDiff > Conductor.safeZoneOffset * 0.9) { - daRating = 'shit'; - score = 50; - } - else if (noteDiff > Conductor.safeZoneOffset * 0.75) - { - daRating = 'bad'; - score = 100; - } - else if (noteDiff > Conductor.safeZoneOffset * 0.2) - { - daRating = 'good'; - score = 200; - } - - songScore += score; - - /* if (combo > 60) - daRating = 'sick'; - else if (combo > 12) - daRating = 'good' - else if (combo > 4) - daRating = 'bad'; - */ - - var pixelShitPart1:String = ""; - var pixelShitPart2:String = ''; - - if (curStage.startsWith('school')) - { - pixelShitPart1 = 'weeb/pixelUI/'; - pixelShitPart2 = '-pixel'; - } - - rating.loadGraphic(Paths.image(pixelShitPart1 + daRating + pixelShitPart2)); - rating.screenCenter(); - rating.x = coolText.x - 40; - rating.y -= 60; - rating.acceleration.y = 550; - rating.velocity.y -= FlxG.random.int(140, 175); - rating.velocity.x -= FlxG.random.int(0, 10); - - var comboSpr:FlxSprite = new FlxSprite().loadGraphic(Paths.image(pixelShitPart1 + 'combo' + pixelShitPart2)); - comboSpr.screenCenter(); - comboSpr.x = coolText.x; - comboSpr.acceleration.y = 600; - comboSpr.velocity.y -= 150; - - comboSpr.velocity.x += FlxG.random.int(1, 10); - add(rating); - - if (!curStage.startsWith('school')) - { - rating.setGraphicSize(Std.int(rating.width * 0.7)); - rating.antialiasing = true; - comboSpr.setGraphicSize(Std.int(comboSpr.width * 0.7)); - comboSpr.antialiasing = true; - } - else - { - rating.setGraphicSize(Std.int(rating.width * daPixelZoom * 0.7)); - comboSpr.setGraphicSize(Std.int(comboSpr.width * daPixelZoom * 0.7)); - } - - comboSpr.updateHitbox(); - rating.updateHitbox(); - - var seperatedScore:Array = []; - - seperatedScore.push(Math.floor(combo / 100)); - seperatedScore.push(Math.floor((combo - (seperatedScore[0] * 100)) / 10)); - seperatedScore.push(combo % 10); - - var daLoop:Int = 0; - for (i in seperatedScore) - { - var numScore:FlxSprite = new FlxSprite().loadGraphic(Paths.image(pixelShitPart1 + 'num' + Std.int(i) + pixelShitPart2)); - numScore.screenCenter(); - numScore.x = coolText.x + (43 * daLoop) - 90; - numScore.y += 80; - + var noteDiff:Float = Math.abs(strumtime - Conductor.songPosition); + // boyfriend.playAnim('hey'); + vocals.volume = 1; + + var placement:String = Std.string(combo); + + var coolText:FlxText = new FlxText(0, 0, 0, placement, 32); + coolText.screenCenter(); + coolText.x = FlxG.width * 0.55; + // + + var rating:FlxSprite = new FlxSprite(); + var score:Int = 350; + + var daRating:String = "sick"; + + if (noteDiff > Conductor.safeZoneOffset * 2) + { + daRating = 'shit'; + totalNotesHit -= 2; + noteMiss(0); + score = -3000; + ss = false; + shits++; + } + else if (noteDiff < Conductor.safeZoneOffset * -2) + { + daRating = 'shit'; + totalNotesHit -= 2; + noteMiss(0); + score = -3000; + ss = false; + shits++; + } + else if (noteDiff > Conductor.safeZoneOffset * 0.45) + { + daRating = 'bad'; + score = -1000; + totalNotesHit += 0.2; + ss = false; + bads++; + } + else if (noteDiff > Conductor.safeZoneOffset * 0.25) + { + daRating = 'good'; + totalNotesHit += 0.65; + score = 200; + ss = false; + goods++; + } + if (daRating == 'sick') + { + totalNotesHit += 1; + sicks++; + } + + + if (daRating != 'shit' || daRating != 'bad') + { + + + songScore += score; + + /* if (combo > 60) + daRating = 'sick'; + else if (combo > 12) + daRating = 'good' + else if (combo > 4) + daRating = 'bad'; + */ + + var pixelShitPart1:String = ""; + var pixelShitPart2:String = ''; + + if (curStage.startsWith('school')) + { + pixelShitPart1 = 'weeb/pixelUI/'; + pixelShitPart2 = '-pixel'; + } + + rating.loadGraphic(Paths.image(pixelShitPart1 + daRating + pixelShitPart2)); + rating.screenCenter(); + rating.x = coolText.x - 40; + rating.y -= 60; + rating.acceleration.y = 550; + rating.velocity.y -= FlxG.random.int(140, 175); + rating.velocity.x -= FlxG.random.int(0, 10); + + var comboSpr:FlxSprite = new FlxSprite().loadGraphic(Paths.image(pixelShitPart1 + 'combo' + pixelShitPart2)); + comboSpr.screenCenter(); + comboSpr.x = coolText.x; + comboSpr.acceleration.y = 600; + comboSpr.velocity.y -= 150; + + comboSpr.velocity.x += FlxG.random.int(1, 10); + add(rating); + if (!curStage.startsWith('school')) { - numScore.antialiasing = true; - numScore.setGraphicSize(Std.int(numScore.width * 0.5)); + rating.setGraphicSize(Std.int(rating.width * 0.7)); + rating.antialiasing = true; + comboSpr.setGraphicSize(Std.int(comboSpr.width * 0.7)); + comboSpr.antialiasing = true; } else { - numScore.setGraphicSize(Std.int(numScore.width * daPixelZoom)); + rating.setGraphicSize(Std.int(rating.width * daPixelZoom * 0.7)); + comboSpr.setGraphicSize(Std.int(comboSpr.width * daPixelZoom * 0.7)); } - numScore.updateHitbox(); - - numScore.acceleration.y = FlxG.random.int(200, 300); - numScore.velocity.y -= FlxG.random.int(140, 160); - numScore.velocity.x = FlxG.random.float(-5, 5); - - if (combo >= 10 || combo == 0) - add(numScore); - - FlxTween.tween(numScore, {alpha: 0}, 0.2, { + + comboSpr.updateHitbox(); + rating.updateHitbox(); + + var seperatedScore:Array = []; + + seperatedScore.push(Math.floor(combo / 100)); + seperatedScore.push(Math.floor((combo - (seperatedScore[0] * 100)) / 10)); + seperatedScore.push(combo % 10); + + var daLoop:Int = 0; + for (i in seperatedScore) + { + var numScore:FlxSprite = new FlxSprite().loadGraphic(Paths.image(pixelShitPart1 + 'num' + Std.int(i) + pixelShitPart2)); + numScore.screenCenter(); + numScore.x = coolText.x + (43 * daLoop) - 90; + numScore.y += 80; + + if (!curStage.startsWith('school')) + { + numScore.antialiasing = true; + numScore.setGraphicSize(Std.int(numScore.width * 0.5)); + } + else + { + numScore.setGraphicSize(Std.int(numScore.width * daPixelZoom)); + } + numScore.updateHitbox(); + + numScore.acceleration.y = FlxG.random.int(200, 300); + numScore.velocity.y -= FlxG.random.int(140, 160); + numScore.velocity.x = FlxG.random.float(-5, 5); + + if (combo >= 10 || combo == 0) + add(numScore); + + FlxTween.tween(numScore, {alpha: 0}, 0.2, { + onComplete: function(tween:FlxTween) + { + numScore.destroy(); + }, + startDelay: Conductor.crochet * 0.002 + }); + + daLoop++; + } + /* + trace(combo); + trace(seperatedScore); + */ + + coolText.text = Std.string(seperatedScore); + // add(coolText); + + FlxTween.tween(rating, {alpha: 0}, 0.2, { + startDelay: Conductor.crochet * 0.001 + }); + + FlxTween.tween(comboSpr, {alpha: 0}, 0.2, { onComplete: function(tween:FlxTween) { - numScore.destroy(); + coolText.destroy(); + comboSpr.destroy(); + + rating.destroy(); }, - startDelay: Conductor.crochet * 0.002 + startDelay: Conductor.crochet * 0.001 }); - - daLoop++; + + curSection += 1; + } } - /* - trace(combo); - trace(seperatedScore); - */ - coolText.text = Std.string(seperatedScore); - // add(coolText); + public function NearlyEquals(value1:Float, value2:Float, unimportantDifference:Float = 10):Bool + { + return Math.abs(FlxMath.roundDecimal(value1, 1) - FlxMath.roundDecimal(value2, 1)) < unimportantDifference; + } - FlxTween.tween(rating, {alpha: 0}, 0.2, { - startDelay: Conductor.crochet * 0.001 - }); - - FlxTween.tween(comboSpr, {alpha: 0}, 0.2, { - onComplete: function(tween:FlxTween) - { - coolText.destroy(); - comboSpr.destroy(); - - rating.destroy(); - }, - startDelay: Conductor.crochet * 0.001 - }); - - curSection += 1; - } + var upHold:Bool = false; + var downHold:Bool = false; + var rightHold:Bool = false; + var leftHold:Bool = false; private function keyShit():Void { @@ -1846,180 +1945,284 @@ class PlayState extends MusicBeatState var downR = controls.DOWN_R; var leftR = controls.LEFT_R; + if (loadRep) // replay code + { + // disable input + up = false; + down = false; + right = false; + left = false; + + // new input + + + //if (rep.replay.keys[repPresses].time == Conductor.songPosition) + // trace('DO IT!!!!!'); + + //timeCurrently = Math.abs(rep.replay.keyPresses[repPresses].time - Conductor.songPosition); + //timeCurrentlyR = Math.abs(rep.replay.keyReleases[repReleases].time - Conductor.songPosition); + + + if (repPresses < rep.replay.keyPresses.length && repReleases < rep.replay.keyReleases.length) + { + upP = NearlyEquals(rep.replay.keyPresses[repPresses].time, Conductor.songPosition) && rep.replay.keyPresses[repPresses].key == "up"; + rightP = NearlyEquals(rep.replay.keyPresses[repPresses].time, Conductor.songPosition) && rep.replay.keyPresses[repPresses].key == "right"; + downP = NearlyEquals(rep.replay.keyPresses[repPresses].time, Conductor.songPosition) && rep.replay.keyPresses[repPresses].key == "down"; + leftP = NearlyEquals(rep.replay.keyPresses[repPresses].time, Conductor.songPosition) && rep.replay.keyPresses[repPresses].key == "left"; + + upR = NearlyEquals(rep.replay.keyReleases[repReleases].time, Conductor.songPosition) && rep.replay.keyReleases[repReleases].key == "up"; + rightR = NearlyEquals(rep.replay.keyReleases[repReleases].time, Conductor.songPosition) && rep.replay.keyReleases[repReleases].key == "right"; + downR = NearlyEquals(rep.replay.keyReleases[repReleases].time, Conductor.songPosition) && rep.replay.keyReleases[repReleases].key == "down"; + leftR = NearlyEquals(rep.replay.keyReleases[repReleases].time, Conductor.songPosition) && rep.replay.keyReleases[repReleases].key == "left"; + + upHold = upP ? true : upR ? false : true; + rightHold = rightP ? true : rightR ? false : true; + downHold = downP ? true : downR ? false : true; + leftHold = leftP ? true : leftR ? false : true; + } + } + else if (!loadRep) // record replay code + { + if (upP) + rep.replay.keyPresses.push({time: Conductor.songPosition, key: "up"}); + if (rightP) + rep.replay.keyPresses.push({time: Conductor.songPosition, key: "right"}); + if (downP) + rep.replay.keyPresses.push({time: Conductor.songPosition, key: "down"}); + if (leftP) + rep.replay.keyPresses.push({time: Conductor.songPosition, key: "left"}); + + if (upR) + rep.replay.keyReleases.push({time: Conductor.songPosition, key: "up"}); + if (rightR) + rep.replay.keyReleases.push({time: Conductor.songPosition, key: "right"}); + if (downR) + rep.replay.keyReleases.push({time: Conductor.songPosition, key: "down"}); + if (leftR) + rep.replay.keyReleases.push({time: Conductor.songPosition, key: "left"}); + } var controlArray:Array = [leftP, downP, upP, rightP]; // FlxG.watch.addQuick('asdfa', upP); if ((upP || rightP || downP || leftP) && !boyfriend.stunned && generatedMusic) - { - boyfriend.holdTimer = 0; - - var possibleNotes:Array = []; - - var ignoreList:Array = []; - - notes.forEachAlive(function(daNote:Note) { - if (daNote.canBeHit && daNote.mustPress && !daNote.tooLate && !daNote.wasGoodHit) + repPresses++; + boyfriend.holdTimer = 0; + + var possibleNotes:Array = []; + + var ignoreList:Array = []; + + notes.forEachAlive(function(daNote:Note) { - // the sorting probably doesn't need to be in here? who cares lol - possibleNotes.push(daNote); - possibleNotes.sort((a, b) -> Std.int(a.strumTime - b.strumTime)); - - ignoreList.push(daNote.noteData); - } - }); - - if (possibleNotes.length > 0) - { - var daNote = possibleNotes[0]; - - if (perfectMode) - noteCheck(true, daNote); - - // Jump notes - if (possibleNotes.length >= 2) - { - if (possibleNotes[0].strumTime == possibleNotes[1].strumTime) + if (daNote.canBeHit && daNote.mustPress && !daNote.tooLate) { - for (coolNote in possibleNotes) + // the sorting probably doesn't need to be in here? who cares lol + possibleNotes.push(daNote); + possibleNotes.sort((a, b) -> Std.int(a.strumTime - b.strumTime)); + + ignoreList.push(daNote.noteData); + } + }); + + + if (possibleNotes.length > 0) + { + var daNote = possibleNotes[0]; + + if (perfectMode) + noteCheck(true, daNote); + + // Jump notes + if (possibleNotes.length >= 2) + { + if (possibleNotes[0].strumTime == possibleNotes[1].strumTime) { - if (controlArray[coolNote.noteData]) - goodNoteHit(coolNote); - else + for (coolNote in possibleNotes) { - var inIgnoreList:Bool = false; - for (shit in 0...ignoreList.length) + if (controlArray[coolNote.noteData]) + goodNoteHit(coolNote); + else { - if (controlArray[ignoreList[shit]]) - inIgnoreList = true; + var inIgnoreList:Bool = false; + for (shit in 0...ignoreList.length) + { + if (controlArray[ignoreList[shit]]) + inIgnoreList = true; + } + if (!inIgnoreList && !theFunne) + badNoteCheck(); } - if (!inIgnoreList) - badNoteCheck(); + } + } + else if (possibleNotes[0].noteData == possibleNotes[1].noteData) + { + if (loadRep) + { + if (NearlyEquals(daNote.strumTime,rep.replay.keyPresses[repPresses].time, 30)) + { + goodNoteHit(daNote); + trace('force note hit'); + } + else + noteCheck(controlArray[daNote.noteData], daNote); + } + else + noteCheck(controlArray[daNote.noteData], daNote); + } + else + { + for (coolNote in possibleNotes) + { + if (loadRep) + { + if (NearlyEquals(coolNote.strumTime,rep.replay.keyPresses[repPresses].time, 30)) + { + goodNoteHit(coolNote); + trace('force note hit'); + } + else + noteCheck(controlArray[daNote.noteData], daNote); + } + else + noteCheck(controlArray[coolNote.noteData], coolNote); } } } - else if (possibleNotes[0].noteData == possibleNotes[1].noteData) - { - noteCheck(controlArray[daNote.noteData], daNote); - } - else - { - for (coolNote in possibleNotes) + else // regular notes? + { + if (loadRep) { - noteCheck(controlArray[coolNote.noteData], coolNote); + if (NearlyEquals(daNote.strumTime,rep.replay.keyPresses[repPresses].time, 30)) + { + goodNoteHit(daNote); + trace('force note hit'); + } + else + noteCheck(controlArray[daNote.noteData], daNote); + } + else + noteCheck(controlArray[daNote.noteData], daNote); + } + /* + if (controlArray[daNote.noteData]) + goodNoteHit(daNote); + */ + // trace(daNote.noteData); + /* + switch (daNote.noteData) + { + case 2: // NOTES YOU JUST PRESSED + if (upP || rightP || downP || leftP) + noteCheck(upP, daNote); + case 3: + if (upP || rightP || downP || leftP) + noteCheck(rightP, daNote); + case 1: + if (upP || rightP || downP || leftP) + noteCheck(downP, daNote); + case 0: + if (upP || rightP || downP || leftP) + noteCheck(leftP, daNote); + } + */ + if (daNote.wasGoodHit) + { + daNote.kill(); + notes.remove(daNote, true); + daNote.destroy(); + } + } + else if (!theFunne) + { + badNoteCheck(); + } + } + + if ((up || right || down || left) && generatedMusic || (upHold || downHold || leftHold || rightHold) && loadRep && generatedMusic) + { + notes.forEachAlive(function(daNote:Note) + { + if (daNote.canBeHit && daNote.mustPress && daNote.isSustainNote) + { + switch (daNote.noteData) + { + // NOTES YOU ARE HOLDING + case 2: + if (up || upHold) + goodNoteHit(daNote); + case 3: + if (right || rightHold) + goodNoteHit(daNote); + case 1: + if (down || downHold) + goodNoteHit(daNote); + case 0: + if (left || leftHold) + goodNoteHit(daNote); } } - } - else // regular notes? + }); + } + + if (boyfriend.holdTimer > Conductor.stepCrochet * 4 * 0.001 && !up && !down && !right && !left) + { + if (boyfriend.animation.curAnim.name.startsWith('sing') && !boyfriend.animation.curAnim.name.endsWith('miss')) { - noteCheck(controlArray[daNote.noteData], daNote); + boyfriend.playAnim('idle'); + } + } + + playerStrums.forEach(function(spr:FlxSprite) + { + switch (spr.ID) + { + case 2: + if (upP && spr.animation.curAnim.name != 'confirm') + { + spr.animation.play('pressed'); + trace('play'); + } + if (upR) + { + spr.animation.play('static'); + repReleases++; + } + case 3: + if (rightP && spr.animation.curAnim.name != 'confirm') + spr.animation.play('pressed'); + if (rightR) + { + spr.animation.play('static'); + repReleases++; + } + case 1: + if (downP && spr.animation.curAnim.name != 'confirm') + spr.animation.play('pressed'); + if (downR) + { + spr.animation.play('static'); + repReleases++; + } + case 0: + if (leftP && spr.animation.curAnim.name != 'confirm') + spr.animation.play('pressed'); + if (leftR) + { + spr.animation.play('static'); + repReleases++; + } } - /* - if (controlArray[daNote.noteData]) - goodNoteHit(daNote); - */ - // trace(daNote.noteData); - /* - switch (daNote.noteData) - { - case 2: // NOTES YOU JUST PRESSED - if (upP || rightP || downP || leftP) - noteCheck(upP, daNote); - case 3: - if (upP || rightP || downP || leftP) - noteCheck(rightP, daNote); - case 1: - if (upP || rightP || downP || leftP) - noteCheck(downP, daNote); - case 0: - if (upP || rightP || downP || leftP) - noteCheck(leftP, daNote); - } - //this is already done in noteCheck / goodNoteHit - if (daNote.wasGoodHit) + if (spr.animation.curAnim.name == 'confirm' && !curStage.startsWith('school')) { - daNote.kill(); - notes.remove(daNote, true); - daNote.destroy(); - } - */ - } - else - { - badNoteCheck(); - } - } - - if ((up || right || down || left) && !boyfriend.stunned && generatedMusic) - { - notes.forEachAlive(function(daNote:Note) - { - if (daNote.canBeHit && daNote.mustPress && daNote.isSustainNote) - { - switch (daNote.noteData) - { - // NOTES YOU ARE HOLDING - case 0: - if (left) - goodNoteHit(daNote); - case 1: - if (down) - goodNoteHit(daNote); - case 2: - if (up) - goodNoteHit(daNote); - case 3: - if (right) - goodNoteHit(daNote); - } + spr.centerOffsets(); + spr.offset.x -= 13; + spr.offset.y -= 13; } + else + spr.centerOffsets(); }); - } - - if (boyfriend.holdTimer > Conductor.stepCrochet * 4 * 0.001 && !up && !down && !right && !left) - { - if (boyfriend.animation.curAnim.name.startsWith('sing') && !boyfriend.animation.curAnim.name.endsWith('miss')) - { - boyfriend.playAnim('idle'); - } - } - - playerStrums.forEach(function(spr:FlxSprite) - { - switch (spr.ID) - { - case 0: - if (leftP && spr.animation.curAnim.name != 'confirm') - spr.animation.play('pressed'); - if (leftR) - spr.animation.play('static'); - case 1: - if (downP && spr.animation.curAnim.name != 'confirm') - spr.animation.play('pressed'); - if (downR) - spr.animation.play('static'); - case 2: - if (upP && spr.animation.curAnim.name != 'confirm') - spr.animation.play('pressed'); - if (upR) - spr.animation.play('static'); - case 3: - if (rightP && spr.animation.curAnim.name != 'confirm') - spr.animation.play('pressed'); - if (rightR) - spr.animation.play('static'); - } - - if (spr.animation.curAnim.name == 'confirm' && !curStage.startsWith('school')) - { - spr.centerOffsets(); - spr.offset.x -= 13; - spr.offset.y -= 13; - } - else - spr.centerOffsets(); - }); } function noteMiss(direction:Int = 1):Void @@ -2039,14 +2242,6 @@ class PlayState extends MusicBeatState // FlxG.sound.play(Paths.sound('missnote1'), 1, false); // FlxG.log.add('played imss note'); - boyfriend.stunned = true; - - // get stunned for 5 seconds - new FlxTimer().start(5 / 60, function(tmr:FlxTimer) - { - boyfriend.stunned = false; - }); - switch (direction) { case 0: @@ -2062,80 +2257,112 @@ class PlayState extends MusicBeatState } function badNoteCheck() - { - // just double pasting this shit cuz fuk u - // REDO THIS SYSTEM! - var upP = controls.UP_P; - var rightP = controls.RIGHT_P; - var downP = controls.DOWN_P; - var leftP = controls.LEFT_P; - - if (leftP) - noteMiss(0); - if (downP) - noteMiss(1); - if (upP) - noteMiss(2); - if (rightP) - noteMiss(3); - } - - function noteCheck(keyP:Bool, note:Note):Void - { - if (keyP) - goodNoteHit(note); - else { - badNoteCheck(); + // just double pasting this shit cuz fuk u + // REDO THIS SYSTEM! + var upP = controls.UP_P; + var rightP = controls.RIGHT_P; + var downP = controls.DOWN_P; + var leftP = controls.LEFT_P; + + if (leftP) + noteMiss(0); + if (upP) + noteMiss(2); + if (rightP) + noteMiss(3); + if (downP) + noteMiss(1); + updateAccuracy(); } - } - function goodNoteHit(note:Note):Void - { - if (!note.wasGoodHit) + function updateAccuracy() { - if (!note.isSustainNote) - { - popUpScore(note.strumTime); - combo += 1; - } - - if (note.noteData >= 0) - health += 0.023; + if (misses > 0 || accuracy < 96) + fc = false; else - health += 0.004; + fc = true; + totalPlayed += 1; + accuracy = totalNotesHit / totalPlayed * 100; + } - switch (note.noteData) - { - case 0: - boyfriend.playAnim('singLEFT', true); - case 1: - boyfriend.playAnim('singDOWN', true); - case 2: - boyfriend.playAnim('singUP', true); - case 3: - boyfriend.playAnim('singRIGHT', true); - } - playerStrums.forEach(function(spr:FlxSprite) + function noteCheck(keyP:Bool, note:Note):Void // sorry lol + { + if (loadRep) { - if (Math.abs(note.noteData) == spr.ID) + if (keyP) + goodNoteHit(note); + else if (!theFunne) + badNoteCheck(); + else if (rep.replay.keyPresses.length > repPresses && !keyP) { - spr.animation.play('confirm', true); + if (NearlyEquals(note.strumTime,rep.replay.keyPresses[repPresses].time, 4)) + { + goodNoteHit(note); + } + else if (!theFunne) + badNoteCheck(); } - }); - - note.wasGoodHit = true; - vocals.volume = 1; - - if (!note.isSustainNote) + } + else if (keyP) + { + goodNoteHit(note); + } + else if (!theFunne) { - note.kill(); - notes.remove(note, true); - note.destroy(); + badNoteCheck(); } } - } + + function goodNoteHit(note:Note):Void + { + if (!note.wasGoodHit) + { + if (!note.isSustainNote) + { + popUpScore(note.strumTime); + combo += 1; + } + else + totalNotesHit += 1; + + if (note.noteData >= 0) + health += 0.023; + else + health += 0.004; + + switch (note.noteData) + { + case 2: + boyfriend.playAnim('singUP', true); + case 3: + boyfriend.playAnim('singRIGHT', true); + case 1: + boyfriend.playAnim('singDOWN', true); + case 0: + boyfriend.playAnim('singLEFT', true); + } + + playerStrums.forEach(function(spr:FlxSprite) + { + if (Math.abs(note.noteData) == spr.ID) + { + spr.animation.play('confirm', true); + } + }); + + note.wasGoodHit = true; + vocals.volume = 1; + + note.kill(); + notes.remove(note, true); + note.destroy(); + + updateAccuracy(); + } + } + var fastCarCanDrive:Bool = true; diff --git a/source/Replay.hx b/source/Replay.hx new file mode 100644 index 0000000..001f981 --- /dev/null +++ b/source/Replay.hx @@ -0,0 +1,101 @@ +#if sys +import sys.io.File; +#end +import Controls.Control; +import flixel.FlxG; +import openfl.events.IOErrorEvent; +import openfl.events.Event; +import openfl.net.FileReference; +import lime.utils.Assets; +import haxe.Json; +import flixel.input.keyboard.FlxKey; +import openfl.utils.Dictionary; + +typedef KeyPress = +{ + public var time:Float; + public var key:String; +} + +typedef KeyRelease = +{ + public var time:Float; + public var key:String; +} + +typedef ReplayJSON = +{ + public var replayGameVer:String; + public var timestamp:Date; + public var songName:String; + public var songDiff:Int; + public var keyPresses:Array; + public var keyReleases:Array; +} + +class Replay +{ + public static var version:String = "1.0"; // replay file version + + public var path:String = ""; + public var replay:ReplayJSON; + public function new(path:String) + { + this.path = path; + replay = { + songName: "Tutorial", + songDiff: 1, + keyPresses: [], + keyReleases: [], + replayGameVer: version, + timestamp: Date.now() + }; + } + + public static function LoadReplay(path:String):Replay + { + var rep:Replay = new Replay(path); + + rep.LoadFromJSON(); + + trace('basic replay data:\nSong Name: ' + rep.replay.songName + '\nSong Diff: ' + rep.replay.songDiff + '\nKeys Length: ' + rep.replay.keyPresses.length); + + return rep; + } + + public function SaveReplay() + { + var json = { + "songName": PlayState.SONG.song.toLowerCase(), + "songDiff": PlayState.storyDifficulty, + "keyPresses": replay.keyPresses, + "keyReleases": replay.keyReleases, + "timestamp": Date.now(), + "replayGameVer": version + }; + + var data:String = Json.stringify(json); + + #if sys + File.saveContent("assets/replays/replay-" + PlayState.SONG.song + "-time" + Date.now().getTime() + ".kadeReplay", data); + #end + } + + + public function LoadFromJSON() + { + #if sys + trace('loading ' + Sys.getCwd() + 'assets\\replays\\' + path + ' replay...'); + try + { + var repl:ReplayJSON = cast Json.parse(File.getContent(Sys.getCwd() + "assets\\replays\\" + path)); + replay = repl; + } + catch(e) + { + trace('failed!\n' + e.message); + } + #end + } + +} diff --git a/source/TitleState.hx b/source/TitleState.hx index 3a30416..b9e912e 100644 --- a/source/TitleState.hx +++ b/source/TitleState.hx @@ -54,7 +54,7 @@ class TitleState extends MusicBeatState super.create(); - NGio.noLogin(APIStuff.API); + // NGio.noLogin(APIStuff.API); #if ng var ng:NGio = new NGio(APIStuff.API, APIStuff.EncKey); @@ -364,10 +364,9 @@ class TitleState extends MusicBeatState // credTextShit.text = 'In association \nwith'; // credTextShit.screenCenter(); case 5: - createCoolText(['In association', 'with']); + createCoolText(['Kade Engine', 'by']); case 7: - addMoreText('newgrounds'); - ngSpr.visible = true; + addMoreText('KadeDeveloper'); // credTextShit.text += '\nNewgrounds'; case 8: deleteCoolText();