Merge branch 'KadeDev:master' into master

This commit is contained in:
CyndaquilDAC 2021-07-07 10:00:57 -05:00 committed by GitHub
commit 933cbee67b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 448 additions and 150 deletions

View File

@ -66,3 +66,4 @@ This game was made with love to Newgrounds and its community. Extra love to Tom
- [GWebDev](https://github.com/GrowtopiaFli) - Video Code - [GWebDev](https://github.com/GrowtopiaFli) - Video Code
- [Rozebud](https://github.com/ThatRozebudDude) - Ideas (that I stole) - [Rozebud](https://github.com/ThatRozebudDude) - Ideas (that I stole)
- [Puyo](https://github.com/daniel11420) - Setting up appveyor and a lot of other help - [Puyo](https://github.com/daniel11420) - Setting up appveyor and a lot of other help
- [Smokey](https://twitter.com/Smokey_5_) - telling me that I should do the tricky asset loading

Binary file not shown.

Binary file not shown.

View File

@ -1,5 +1,12 @@
package; package;
import lime.app.Application;
#if windows
import Discord.DiscordClient;
#end
import openfl.display.BitmapData;
import openfl.utils.Assets;
import flixel.ui.FlxBar;
import haxe.Exception; import haxe.Exception;
import flixel.tweens.FlxEase; import flixel.tweens.FlxEase;
import flixel.tweens.FlxTween; import flixel.tweens.FlxTween;
@ -25,15 +32,26 @@ class Caching extends MusicBeatState
var toBeDone = 0; var toBeDone = 0;
var done = 0; var done = 0;
var loaded = false;
var text:FlxText; var text:FlxText;
var kadeLogo:FlxSprite; var kadeLogo:FlxSprite;
public static var bitmapData:Map<String,FlxGraphic>;
var images = [];
var music = [];
var charts = [];
override function create() override function create()
{ {
FlxG.mouse.visible = false; FlxG.mouse.visible = false;
FlxG.worldBounds.set(0,0); FlxG.worldBounds.set(0,0);
bitmapData = new Map<String,FlxGraphic>();
text = new FlxText(FlxG.width / 2, FlxG.height / 2 + 300,0,"Loading..."); text = new FlxText(FlxG.width / 2, FlxG.height / 2 + 300,0,"Loading...");
text.size = 34; text.size = 34;
text.alignment = FlxTextAlign.CENTER; text.alignment = FlxTextAlign.CENTER;
@ -48,43 +66,27 @@ class Caching extends MusicBeatState
kadeLogo.alpha = 0; kadeLogo.alpha = 0;
add(kadeLogo); PlayerSettings.init();
add(text);
trace('starting caching..'); #if windows
DiscordClient.initialize();
sys.thread.Thread.create(() -> { Application.current.onExit.add (function (exitCode) {
cache(); DiscordClient.shutdown();
}); });
#end
super.create();
}
var calledDone = false; Highscore.load();
override function update(elapsed) FlxG.save.bind('funkin', 'ninjamuffin99');
KadeEngineData.initSave();
if (FlxG.save.data.cacheImages)
{ {
if (toBeDone != 0 && done != toBeDone)
{
var alpha = HelperFunctions.truncateFloat(done / toBeDone * 100,2) / 100;
kadeLogo.alpha = alpha;
text.alpha = alpha;
text.text = "Loading... (" + done + "/" + toBeDone + ")";
}
super.update(elapsed);
}
function cache()
{
var images = [];
var music = [];
var charts = [];
trace("caching images..."); trace("caching images...");
for (i in FileSystem.readDirectory(FileSystem.absolutePath("assets/shared/images/characters"))) for (i in FileSystem.readDirectory(FileSystem.absolutePath("assets/shared/images/characters")))
@ -93,6 +95,7 @@ class Caching extends MusicBeatState
continue; continue;
images.push(i); images.push(i);
} }
}
trace("caching music..."); trace("caching music...");
@ -104,13 +107,63 @@ class Caching extends MusicBeatState
toBeDone = Lambda.count(images) + Lambda.count(music); toBeDone = Lambda.count(images) + Lambda.count(music);
var bar = new FlxBar(10,FlxG.height - 50,FlxBarFillDirection.LEFT_TO_RIGHT,FlxG.width,40,null,"done",0,toBeDone);
bar.color = FlxColor.PURPLE;
add(bar);
add(kadeLogo);
add(text);
trace('starting caching..');
// update thread
sys.thread.Thread.create(() -> {
while(!loaded)
{
if (toBeDone != 0 && done != toBeDone)
{
var alpha = HelperFunctions.truncateFloat(done / toBeDone * 100,2) / 100;
kadeLogo.alpha = alpha;
text.alpha = alpha;
text.text = "Loading... (" + done + "/" + toBeDone + ")";
}
}
});
// cache thread
sys.thread.Thread.create(() -> {
cache();
});
super.create();
}
var calledDone = false;
override function update(elapsed)
{
super.update(elapsed);
}
function cache()
{
trace("LOADING: " + toBeDone + " OBJECTS."); trace("LOADING: " + toBeDone + " OBJECTS.");
for (i in images) for (i in images)
{ {
var replaced = i.replace(".png",""); var replaced = i.replace(".png","");
FlxG.bitmap.add(Paths.image("characters/" + replaced,"shared")); var data:BitmapData = BitmapData.fromFile("assets/shared/images/characters/" + i);
trace("cached " + replaced); trace('id ' + replaced + ' file - assets/shared/images/characters/' + i + ' ${data.width}');
var graph = FlxGraphic.fromBitmapData(data);
graph.persist = true;
graph.destroyOnNoUse = false;
bitmapData.set(replaced,graph);
done++; done++;
} }
@ -125,6 +178,10 @@ class Caching extends MusicBeatState
trace("Finished caching..."); trace("Finished caching...");
loaded = true;
trace(Assets.cache.hasBitmapData('GF_assets'));
FlxG.switchState(new TitleState()); FlxG.switchState(new TitleState());
} }

View File

@ -32,7 +32,7 @@ class Character extends FlxSprite
{ {
case 'gf': case 'gf':
// GIRLFRIEND CODE // GIRLFRIEND CODE
tex = Paths.getSparrowAtlas('characters/GF_assets'); tex = Paths.getSparrowAtlas('GF_assets','shared',true);
frames = tex; frames = tex;
animation.addByPrefix('cheer', 'GF Cheer', 24, false); animation.addByPrefix('cheer', 'GF Cheer', 24, false);
animation.addByPrefix('singLEFT', 'GF left note', 24, false); animation.addByPrefix('singLEFT', 'GF left note', 24, false);
@ -51,7 +51,7 @@ class Character extends FlxSprite
playAnim('danceRight'); playAnim('danceRight');
case 'gf-christmas': case 'gf-christmas':
tex = Paths.getSparrowAtlas('characters/gfChristmas'); tex = Paths.getSparrowAtlas('gfChristmas','shared',true);
frames = tex; frames = tex;
animation.addByPrefix('cheer', 'GF Cheer', 24, false); animation.addByPrefix('cheer', 'GF Cheer', 24, false);
animation.addByPrefix('singLEFT', 'GF left note', 24, false); animation.addByPrefix('singLEFT', 'GF left note', 24, false);
@ -70,7 +70,7 @@ class Character extends FlxSprite
playAnim('danceRight'); playAnim('danceRight');
case 'gf-car': case 'gf-car':
tex = Paths.getSparrowAtlas('characters/gfCar'); tex = Paths.getSparrowAtlas('gfCar','shared',true);
frames = tex; frames = tex;
animation.addByIndices('singUP', 'GF Dancing Beat Hair blowing CAR', [0], "", 24, false); animation.addByIndices('singUP', 'GF Dancing Beat Hair blowing CAR', [0], "", 24, false);
animation.addByIndices('danceLeft', 'GF Dancing Beat Hair blowing CAR', [30, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14], "", 24, false); animation.addByIndices('danceLeft', 'GF Dancing Beat Hair blowing CAR', [30, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14], "", 24, false);
@ -82,7 +82,7 @@ class Character extends FlxSprite
playAnim('danceRight'); playAnim('danceRight');
case 'gf-pixel': case 'gf-pixel':
tex = Paths.getSparrowAtlas('characters/gfPixel'); tex = Paths.getSparrowAtlas('gfPixel','shared',true);
frames = tex; frames = tex;
animation.addByIndices('singUP', 'GF IDLE', [2], "", 24, false); animation.addByIndices('singUP', 'GF IDLE', [2], "", 24, false);
animation.addByIndices('danceLeft', 'GF IDLE', [30, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14], "", 24, false); animation.addByIndices('danceLeft', 'GF IDLE', [30, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14], "", 24, false);
@ -98,7 +98,7 @@ class Character extends FlxSprite
case 'dad': case 'dad':
// DAD ANIMATION LOADING CODE // DAD ANIMATION LOADING CODE
tex = Paths.getSparrowAtlas('characters/DADDY_DEAREST', 'shared'); tex = Paths.getSparrowAtlas('DADDY_DEAREST','shared',true);
frames = tex; frames = tex;
animation.addByPrefix('idle', 'Dad idle dance', 24); animation.addByPrefix('idle', 'Dad idle dance', 24);
animation.addByPrefix('singUP', 'Dad Sing Note UP', 24); animation.addByPrefix('singUP', 'Dad Sing Note UP', 24);
@ -110,7 +110,7 @@ class Character extends FlxSprite
playAnim('idle'); playAnim('idle');
case 'spooky': case 'spooky':
tex = Paths.getSparrowAtlas('characters/spooky_kids_assets'); tex = Paths.getSparrowAtlas('spooky_kids_assets','shared',true);
frames = tex; frames = tex;
animation.addByPrefix('singUP', 'spooky UP NOTE', 24, false); animation.addByPrefix('singUP', 'spooky UP NOTE', 24, false);
animation.addByPrefix('singDOWN', 'spooky DOWN note', 24, false); animation.addByPrefix('singDOWN', 'spooky DOWN note', 24, false);
@ -123,7 +123,7 @@ class Character extends FlxSprite
playAnim('danceRight'); playAnim('danceRight');
case 'mom': case 'mom':
tex = Paths.getSparrowAtlas('characters/Mom_Assets'); tex = Paths.getSparrowAtlas('Mom_Assets','shared',true);
frames = tex; frames = tex;
animation.addByPrefix('idle', "Mom Idle", 24, false); animation.addByPrefix('idle', "Mom Idle", 24, false);
@ -139,7 +139,7 @@ class Character extends FlxSprite
playAnim('idle'); playAnim('idle');
case 'mom-car': case 'mom-car':
tex = Paths.getSparrowAtlas('characters/momCar'); tex = Paths.getSparrowAtlas('momCar','shared',true);
frames = tex; frames = tex;
animation.addByPrefix('idle', "Mom Idle", 24, false); animation.addByPrefix('idle', "Mom Idle", 24, false);
@ -154,7 +154,7 @@ class Character extends FlxSprite
playAnim('idle'); playAnim('idle');
case 'monster': case 'monster':
tex = Paths.getSparrowAtlas('characters/Monster_Assets'); tex = Paths.getSparrowAtlas('Monster_Assets','shared',true);
frames = tex; frames = tex;
animation.addByPrefix('idle', 'monster idle', 24, false); animation.addByPrefix('idle', 'monster idle', 24, false);
animation.addByPrefix('singUP', 'monster up note', 24, false); animation.addByPrefix('singUP', 'monster up note', 24, false);
@ -165,7 +165,7 @@ class Character extends FlxSprite
loadOffsetFile(curCharacter); loadOffsetFile(curCharacter);
playAnim('idle'); playAnim('idle');
case 'monster-christmas': case 'monster-christmas':
tex = Paths.getSparrowAtlas('characters/monsterChristmas'); tex = Paths.getSparrowAtlas('monsterChristmas','shared',true);
frames = tex; frames = tex;
animation.addByPrefix('idle', 'monster idle', 24, false); animation.addByPrefix('idle', 'monster idle', 24, false);
animation.addByPrefix('singUP', 'monster up note', 24, false); animation.addByPrefix('singUP', 'monster up note', 24, false);
@ -176,7 +176,7 @@ class Character extends FlxSprite
loadOffsetFile(curCharacter); loadOffsetFile(curCharacter);
playAnim('idle'); playAnim('idle');
case 'pico': case 'pico':
tex = Paths.getSparrowAtlas('characters/Pico_FNF_assetss'); tex = Paths.getSparrowAtlas('Pico_FNF_assetss','shared',true);
frames = tex; frames = tex;
animation.addByPrefix('idle', "Pico Idle Dance", 24); animation.addByPrefix('idle', "Pico Idle Dance", 24);
animation.addByPrefix('singUP', 'pico Up note0', 24, false); animation.addByPrefix('singUP', 'pico Up note0', 24, false);
@ -207,7 +207,7 @@ class Character extends FlxSprite
flipX = true; flipX = true;
case 'bf': case 'bf':
var tex = Paths.getSparrowAtlas('characters/BOYFRIEND', 'shared'); var tex = Paths.getSparrowAtlas('BOYFRIEND','shared',true);
frames = tex; frames = tex;
trace(tex.frames.length); trace(tex.frames.length);
@ -236,7 +236,7 @@ class Character extends FlxSprite
flipX = true; flipX = true;
case 'bf-christmas': case 'bf-christmas':
var tex = Paths.getSparrowAtlas('characters/bfChristmas'); var tex = Paths.getSparrowAtlas('bfChristmas','shared',true);
frames = tex; frames = tex;
animation.addByPrefix('idle', 'BF idle dance', 24, false); animation.addByPrefix('idle', 'BF idle dance', 24, false);
animation.addByPrefix('singUP', 'BF NOTE UP0', 24, false); animation.addByPrefix('singUP', 'BF NOTE UP0', 24, false);
@ -255,7 +255,7 @@ class Character extends FlxSprite
flipX = true; flipX = true;
case 'bf-car': case 'bf-car':
var tex = Paths.getSparrowAtlas('characters/bfCar'); var tex = Paths.getSparrowAtlas('bfCar','shared',true);
frames = tex; frames = tex;
animation.addByPrefix('idle', 'BF idle dance', 24, false); animation.addByPrefix('idle', 'BF idle dance', 24, false);
animation.addByPrefix('singUP', 'BF NOTE UP0', 24, false); animation.addByPrefix('singUP', 'BF NOTE UP0', 24, false);
@ -272,7 +272,7 @@ class Character extends FlxSprite
flipX = true; flipX = true;
case 'bf-pixel': case 'bf-pixel':
frames = Paths.getSparrowAtlas('characters/bfPixel'); frames = Paths.getSparrowAtlas('bfPixel','shared',true);
animation.addByPrefix('idle', 'BF IDLE', 24, false); animation.addByPrefix('idle', 'BF IDLE', 24, false);
animation.addByPrefix('singUP', 'BF UP NOTE', 24, false); animation.addByPrefix('singUP', 'BF UP NOTE', 24, false);
animation.addByPrefix('singLEFT', 'BF LEFT NOTE', 24, false); animation.addByPrefix('singLEFT', 'BF LEFT NOTE', 24, false);
@ -297,7 +297,7 @@ class Character extends FlxSprite
flipX = true; flipX = true;
case 'bf-pixel-dead': case 'bf-pixel-dead':
frames = Paths.getSparrowAtlas('characters/bfPixelsDEAD'); frames = Paths.getSparrowAtlas('bfPixelsDEAD','shared',true);
animation.addByPrefix('singUP', "BF Dies pixel", 24, false); animation.addByPrefix('singUP', "BF Dies pixel", 24, false);
animation.addByPrefix('firstDeath', "BF Dies pixel", 24, false); animation.addByPrefix('firstDeath', "BF Dies pixel", 24, false);
animation.addByPrefix('deathLoop', "Retry Loop", 24, true); animation.addByPrefix('deathLoop', "Retry Loop", 24, true);
@ -313,7 +313,7 @@ class Character extends FlxSprite
flipX = true; flipX = true;
case 'senpai': case 'senpai':
frames = Paths.getSparrowAtlas('characters/senpai'); frames = Paths.getSparrowAtlas('senpai','shared',true);
animation.addByPrefix('idle', 'Senpai Idle', 24, false); animation.addByPrefix('idle', 'Senpai Idle', 24, false);
animation.addByPrefix('singUP', 'SENPAI UP NOTE', 24, false); animation.addByPrefix('singUP', 'SENPAI UP NOTE', 24, false);
animation.addByPrefix('singLEFT', 'SENPAI LEFT NOTE', 24, false); animation.addByPrefix('singLEFT', 'SENPAI LEFT NOTE', 24, false);
@ -329,7 +329,7 @@ class Character extends FlxSprite
antialiasing = false; antialiasing = false;
case 'senpai-angry': case 'senpai-angry':
frames = Paths.getSparrowAtlas('characters/senpai'); frames = Paths.getSparrowAtlas('senpai','shared',true);
animation.addByPrefix('idle', 'Angry Senpai Idle', 24, false); animation.addByPrefix('idle', 'Angry Senpai Idle', 24, false);
animation.addByPrefix('singUP', 'Angry Senpai UP NOTE', 24, false); animation.addByPrefix('singUP', 'Angry Senpai UP NOTE', 24, false);
animation.addByPrefix('singLEFT', 'Angry Senpai LEFT NOTE', 24, false); animation.addByPrefix('singLEFT', 'Angry Senpai LEFT NOTE', 24, false);
@ -345,7 +345,7 @@ class Character extends FlxSprite
antialiasing = false; antialiasing = false;
case 'spirit': case 'spirit':
frames = Paths.getPackerAtlas('characters/spirit'); frames = Paths.getPackerAtlas('spirit','shared',true);
animation.addByPrefix('idle', "idle spirit_", 24, false); animation.addByPrefix('idle', "idle spirit_", 24, false);
animation.addByPrefix('singUP', "up_", 24, false); animation.addByPrefix('singUP', "up_", 24, false);
animation.addByPrefix('singRIGHT', "right_", 24, false); animation.addByPrefix('singRIGHT', "right_", 24, false);
@ -362,7 +362,7 @@ class Character extends FlxSprite
antialiasing = false; antialiasing = false;
case 'parents-christmas': case 'parents-christmas':
frames = Paths.getSparrowAtlas('characters/mom_dad_christmas_assets'); frames = Paths.getSparrowAtlas('mom_dad_christmas_assets','shared',true);
animation.addByPrefix('idle', 'Parent Christmas Idle', 24, false); animation.addByPrefix('idle', 'Parent Christmas Idle', 24, false);
animation.addByPrefix('singUP', 'Parent Up Note Dad', 24, false); animation.addByPrefix('singUP', 'Parent Up Note Dad', 24, false);
animation.addByPrefix('singDOWN', 'Parent Down Note Dad', 24, false); animation.addByPrefix('singDOWN', 'Parent Down Note Dad', 24, false);

View File

@ -75,7 +75,7 @@ class ChartingState extends MusicBeatState
var gridBG:FlxSprite; var gridBG:FlxSprite;
var _song:SwagSong; public static var _song:SwagSong;
var typingShit:FlxInputText; var typingShit:FlxInputText;
/* /*
@ -129,7 +129,7 @@ class ChartingState extends MusicBeatState
blackBorder.alpha = 0.3; blackBorder.alpha = 0.3;
snapText = new FlxText(60,10,0,"Snap: 1/" + snap + " (Press Control to unsnap the cursor)\nAdd Notes: 1-8 (or click)\n", 14); snapText = new FlxText(60,10,0,"Snap: 1/" + snap + " (Press Control to unsnap the cursor)\nAdd Notes: 1-8 (or click)\nDiff: 0", 14);
snapText.scrollFactor.set(); snapText.scrollFactor.set();
gridBlackLine = new FlxSprite(gridBG.x + gridBG.width / 2).makeGraphic(2, Std.int(gridBG.height), FlxColor.BLACK); gridBlackLine = new FlxSprite(gridBG.x + gridBG.width / 2).makeGraphic(2, Std.int(gridBG.height), FlxColor.BLACK);
@ -662,11 +662,13 @@ class ChartingState extends MusicBeatState
var writingNotes:Bool = false; var writingNotes:Bool = false;
var doSnapShit:Bool = true; var doSnapShit:Bool = true;
public var diff:Float = 0;
override function update(elapsed:Float) override function update(elapsed:Float)
{ {
updateHeads(); updateHeads();
snapText.text = "Snap: 1/" + snap + " (" + (doSnapShit ? "Control to disable" : "Snap Disabled, Control to renable") + ")\nAdd Notes: 1-8 (or click)\n"; snapText.text = "Song Diff: " + diff + "\nSnap: 1/" + snap + " (" + (doSnapShit ? "Control to disable" : "Snap Disabled, Control to renable") + ")\nAdd Notes: 1-8 (or click)";
curStep = recalculateSteps(); curStep = recalculateSteps();
@ -1260,6 +1262,9 @@ class ChartingState extends MusicBeatState
curRenderedSustains.add(sustainVis); curRenderedSustains.add(sustainVis);
} }
} }
if (_song != null)
diff = DiffCalc.CalculateDiff(_song);
} }
private function addSection(lengthInSteps:Int = 16):Void private function addSection(lengthInSteps:Int = 16):Void

View File

@ -1,3 +1,5 @@
import openfl.system.System;
import flixel.math.FlxMath;
import Song.SwagSong; import Song.SwagSong;
class SmallNote // basically Note.hx but small as fuck class SmallNote // basically Note.hx but small as fuck
@ -14,18 +16,26 @@ class SmallNote // basically Note.hx but small as fuck
class DiffCalc class DiffCalc
{ {
public static function CalculateDiff(song:SwagSong)
public static var scale = 3 * 1.8;
public static function CalculateDiff(song:SwagSong, ?accuracy:Float = .93)
{ {
trace('calcuilafjwaf');
// cleaned notes // cleaned notes
var cleanedNotes:Array<SmallNote> = []; var cleanedNotes:Array<SmallNote> = [];
if (song.notes == null)
return 0.0;
if (song.notes.length == 0)
return 0.0;
// find all of the notes // find all of the notes
for(i in song.notes) // sections for(i in song.notes) // sections
{ {
for (ii in i.sectionNotes) // notes for (ii in i.sectionNotes) // notes
{ {
if (ii[2] != 0) // skip helds
continue;
var gottaHitNote:Bool = i.mustHitSection; var gottaHitNote:Bool = i.mustHitSection;
if (ii[1] > 3) if (ii[1] > 3)
@ -41,6 +51,8 @@ class DiffCalc
cleanedNotes.sort((a, b) -> Std.int(a.strumTime - b.strumTime)); cleanedNotes.sort((a, b) -> Std.int(a.strumTime - b.strumTime));
var firstNoteTime = cleanedNotes[0].strumTime; var firstNoteTime = cleanedNotes[0].strumTime;
// normalize the notes // normalize the notes
@ -57,84 +69,293 @@ class DiffCalc
case 0: case 0:
handOne.push(i); handOne.push(i);
case 1: case 1:
handTwo.push(i); handOne.push(i);
case 2: case 2:
handTwo.push(i); handTwo.push(i);
case 3: case 3:
handOne.push(i); handTwo.push(i);
} }
} }
var leftHandCol:Array<Float> = []; // d 0
var leftMHandCol:Array<Float> = []; // f 1
var rightMHandCol:Array<Float> = []; // j 2
var rightHandCol:Array<Float> = []; // k 3
for(i in 0...handOne.length - 1)
{
if (handOne[i].noteData == 0)
leftHandCol.push(handOne[i].strumTime);
else
leftMHandCol.push(handOne[i].strumTime);
}
for(i in 0...handTwo.length - 1)
{
if (handTwo[i].noteData == 3)
rightHandCol.push(handTwo[i].strumTime);
else
rightMHandCol.push(handTwo[i].strumTime);
}
// length in segments of the song // length in segments of the song
var length = ((cleanedNotes[cleanedNotes.length - 1].strumTime / 1000) / 0.5); var length = ((cleanedNotes[cleanedNotes.length - 1].strumTime / 1000) / 0.5);
// hackey way of creating a array with a length // hackey way of creating a array with a length
var segmentsOne:Array<Int> = new_Array(1,Std.int(length)); var segmentsOne = new haxe.ds.Vector(Math.floor(length));
var segmentsTwo:Array<Int> = new_Array(1,Std.int(length));
var segmentsTwo = new haxe.ds.Vector(Math.floor(length));
for(i in 0...segmentsOne.length)
segmentsOne[i] = new Array<SmallNote>();
for(i in 0...segmentsTwo.length)
segmentsTwo[i] = new Array<SmallNote>();
// algo loop // algo loop
for(i in handOne) for(i in handOne)
{ {
var index = Std.int(((i.strumTime / 1000))); var index = Std.int((((i.strumTime * 2) / 1000)));
if (index + 1 > segmentsOne.length) if (index + 1 > length)
continue; continue;
segmentsOne[index] = segmentsOne[index] + 1; segmentsOne[index].push(i);
} }
for(i in handTwo) for(i in handTwo)
{ {
var index = Std.int(((i.strumTime / 1000))); var index = Std.int((((i.strumTime * 2) / 1000)));
if (index + 1 > segmentsTwo.length) if (index + 1 > length)
continue; continue;
segmentsTwo[index] = segmentsTwo[index] + 1; segmentsTwo[index].push(i);
} }
// get the average of all of the segments // Remove 0 intervals
var sumOne:Float = 0; /*for(i in 0...segmentsOne.length)
var sumTwo:Float = 0; {
if (segmentsOne[i].length == 0)
segmentsOne[i] = null;
}
for(i in 0...segmentsTwo.length)
{
if (segmentsTwo[i].length == 0)
segmentsTwo[i] = null;
}*/
var lone = segmentsOne.length; var hand_npsOne:Array<Float> = new Array<Float>();
var ltwo = segmentsOne.length; var hand_npsTwo:Array<Float> = new Array<Float>();
for(i in segmentsOne) for(i in segmentsOne)
{ {
if (i == 0) // remove empty/breaks if (i == null)
{
lone--;
continue; continue;
hand_npsOne.push(i.length * scale * 1.6);
} }
//trace(i);
sumOne += i / .5; // half it because otherwise instead of nps its just fucking notes per half second which is dumb and stupid
}
for(i in segmentsTwo) for(i in segmentsTwo)
{ {
if (i == 0) // remove empty/breaks if (i == null)
{
ltwo--;
continue; continue;
} hand_npsTwo.push(i.length * scale * 1.6);
//trace(i);
sumTwo += i / .5; // half it because otherwise instead of nps its just fucking notes per half second which is dumb and stupid
} }
var handOneAvg = sumOne / lone; var hand_diffOne:Array<Float> = new Array<Float>();
var handTwoAvg = sumTwo / ltwo; var hand_diffTwo:Array<Float> = new Array<Float>();
return HelperFunctions.truncateFloat(handOneAvg > handTwoAvg ? handOneAvg : handTwoAvg,2); for(i in 0...segmentsOne.length)
} {
var ve = segmentsOne[i];
static public function new_Array<T>( ArrayType:T, Length:Int ):Array<T> { if (ve == null)
var empty:Null<T> = null; continue;
var newArray:Array<T> = new Array<T>(); var fuckYouOne:Array<SmallNote> = [];
var fuckYouTwo:Array<SmallNote> = [];
for ( i in 0...Length ) { for(note in ve)
newArray.push( empty ); {
} switch(note.noteData)
{
return newArray; case 0: // fingie 1
fuckYouOne.push(note);
case 1: // fingie 2
fuckYouTwo.push(note);
}
}
var one = fingieCalc(fuckYouOne,leftHandCol);
var two = fingieCalc(fuckYouTwo,leftMHandCol);
var bigFuck = ((((one > two ? one : two) * 8) + (hand_npsOne[i] / scale) * 5) / 13) * scale;
//trace(bigFuck + " - hand one [" + i + "]");
hand_diffOne.push(bigFuck);
}
for(i in 0...segmentsTwo.length)
{
var ve = segmentsTwo[i];
if (ve == null)
continue;
var fuckYouOne:Array<SmallNote> = [];
var fuckYouTwo:Array<SmallNote> = [];
for(note in ve)
{
switch(note.noteData)
{
case 2: // fingie 1
fuckYouOne.push(note);
case 3: // fingie 2
fuckYouTwo.push(note);
}
}
var one = fingieCalc(fuckYouOne,rightMHandCol);
var two = fingieCalc(fuckYouTwo,rightHandCol);
var bigFuck = ((((one > two ? one : two) * 8) + (hand_npsTwo[i] / scale) * 5) / 13) * scale;
hand_diffTwo.push(bigFuck);
// trace(bigFuck + " - hand two [" + i + "]");
}
for (i in 0...4)
{
smoothBrain(hand_npsOne,0);
smoothBrain(hand_npsTwo,0);
smoothBrainTwo(hand_diffOne);
smoothBrainTwo(hand_diffTwo);
}
//trace(hand_diffOne);
//trace(hand_diffTwo);
//trace(hand_npsOne);
//trace(hand_npsTwo);
var point_npsOne:Array<Float> = new Array<Float>();
var point_npsTwo:Array<Float> = new Array<Float>();
for(i in segmentsOne)
{
if (i == null)
continue;
point_npsOne.push(i.length);
}
for(i in segmentsTwo)
{
if (i == null)
continue;
point_npsTwo.push(i.length);
}
var maxPoints:Float = 0;
for(i in point_npsOne)
maxPoints += i;
for(i in point_npsTwo)
maxPoints += i;
if (accuracy > .965)
accuracy = .965;
return HelperFunctions.truncateFloat(chisel(accuracy,hand_diffOne,hand_diffTwo,point_npsOne,point_npsTwo,maxPoints),2);
}
public static function chisel(scoreGoal:Float,diffOne:Array<Float>,diffTwo:Array<Float>,pointsOne:Array<Float>,pointsTwo:Array<Float>,maxPoints:Float)
{
var lowerBound:Float = 0;
var upperBound:Float = 100;
while(upperBound - lowerBound > 0.01)
{
var average:Float = (upperBound + lowerBound) / 2;
var amtOfPoints:Float = calcuate(average,diffOne,pointsOne) + calcuate(average,diffTwo,pointsTwo);
if (amtOfPoints / maxPoints < scoreGoal)
lowerBound = average;
else
upperBound = average;
}
return upperBound;
}
public static function calcuate(midPoint:Float,diff:Array<Float>,points:Array<Float>)
{
var output:Float = 0;
for (i in 0...diff.length)
{
var res = diff[i];
if (midPoint > res)
output += points[i];
else
output += points[i] * Math.pow(midPoint / res,1.2);
}
return output;
}
public static function findStupid(strumTime:Float, array:Array<Float>)
{
for(i in 0...array.length)
if (array[i] == strumTime)
return i;
return -1;
}
public static function fingieCalc(floats:Array<SmallNote>, columArray:Array<Float>):Float
{
var sum:Float = 0;
if (floats.length == 0)
return 0;
var startIndex = findStupid(floats[0].strumTime,columArray);
if (startIndex == -1)
return 0;
for(i in floats)
{
sum += columArray[startIndex + 1] - columArray[startIndex];
startIndex++;
}
if (sum == 0)
return 0;
return (1375 * (floats.length)) / sum;
}
// based arrayer
// basicily smmoth the shit
public static function smoothBrain(npsVector:Array<Float>, weirdchamp:Float)
{
var floatOne = weirdchamp;
var floatTwo = weirdchamp;
for (i in 0...npsVector.length)
{
var result = npsVector[i];
var chunker = floatOne;
floatOne = floatTwo;
floatTwo = result;
npsVector[i] = (chunker + floatOne + floatTwo) / 3;
}
}
// Smooth the shit but less
public static function smoothBrainTwo(diffVector:Array<Float>)
{
var floatZero:Float = 0;
for(i in 0...diffVector.length)
{
var result = diffVector[i];
var fuck = floatZero;
floatZero = result;
diffVector[i] = (fuck + floatZero) / 2;
}
} }
} }

View File

@ -64,7 +64,6 @@ class FreeplayState extends MusicBeatState
{ {
var data:Array<String> = initSonglist[i].split(':'); var data:Array<String> = initSonglist[i].split(':');
var meta = new SongMetadata(data[0], Std.parseInt(data[2]), data[1]); var meta = new SongMetadata(data[0], Std.parseInt(data[2]), data[1]);
#if debug
songs.push(meta); songs.push(meta);
var format = StringTools.replace(meta.songName, " ", "-"); var format = StringTools.replace(meta.songName, " ", "-");
switch (format) { switch (format) {
@ -78,24 +77,7 @@ class FreeplayState extends MusicBeatState
FreeplayState.loadDiff(2,format,meta.songName,diffs); FreeplayState.loadDiff(2,format,meta.songName,diffs);
FreeplayState.songData.set(meta.songName,diffs); FreeplayState.songData.set(meta.songName,diffs);
trace('loaded diffs for ' + meta.songName); trace('loaded diffs for ' + meta.songName);
#else
if(Std.parseInt(data[2]) <= FlxG.save.data.weekUnlocked - 1)
{
songs.push(meta);
var format = StringTools.replace(meta.songName, " ", "-");
switch (format) {
case 'Dad-Battle': format = 'Dadbattle';
case 'Philly-Nice': format = 'Philly';
}
var diffs = [];
FreeplayState.loadDiff(0,format,meta.songName,diffs);
FreeplayState.loadDiff(1,format,meta.songName,diffs);
FreeplayState.loadDiff(2,format,meta.songName,diffs);
FreeplayState.songData.set(meta.songName,diffs);
trace('loaded diffs for ' + meta.songName);
}
#end
} }
//trace("\n" + diffList); //trace("\n" + diffList);

View File

@ -97,6 +97,9 @@ class KadeEngineData
if (FlxG.save.data.optimize == null) if (FlxG.save.data.optimize == null)
FlxG.save.data.optimize = false; FlxG.save.data.optimize = false;
if (FlxG.save.data.cacheImages == null)
FlxG.save.data.cacheImages = false;
var gamepad:FlxGamepad = FlxG.gamepads.lastActive; var gamepad:FlxGamepad = FlxG.gamepads.lastActive;
KeyBinds.gamepad = gamepad != null; KeyBinds.gamepad = gamepad != null;

View File

@ -119,6 +119,29 @@ class CpuStrums extends Option
} }
class GraphicLoading extends Option
{
public function new(desc:String)
{
super();
description = desc;
}
public override function press():Bool
{
FlxG.save.data.cacheImages = !FlxG.save.data.cacheImages;
display = updateDisplay();
return true;
}
private override function updateDisplay():String
{
return FlxG.save.data.cacheImages ? "Preload Characters" : "Do not Preload Characters";
}
}
class DownscrollOption extends Option class DownscrollOption extends Option
{ {
public function new(desc:String) public function new(desc:String)

View File

@ -59,6 +59,7 @@ class OptionsMenu extends MusicBeatState
new ScoreScreen("Show the score screen after the end of a song"), new ScoreScreen("Show the score screen after the end of a song"),
new ShowInput("Display every single input in the score screen."), new ShowInput("Display every single input in the score screen."),
new Optimization("No backgrounds, no characters, centered notes, no player 2."), new Optimization("No backgrounds, no characters, centered notes, no player 2."),
new GraphicLoading("On startup, cache every character. Significantly decrease load times. (HIGH MEMORY)"),
new BotPlay("Showcase your charts and mods with autoplay.") new BotPlay("Showcase your charts and mods with autoplay.")
]), ]),

View File

@ -1,5 +1,8 @@
package; package;
import openfl.utils.Assets;
import flixel.graphics.FlxGraphic;
import flixel.system.FlxAssets.FlxGraphicAsset;
import flixel.FlxG; import flixel.FlxG;
import flixel.graphics.frames.FlxAtlasFrames; import flixel.graphics.frames.FlxAtlasFrames;
import openfl.utils.AssetType; import openfl.utils.AssetType;
@ -125,13 +128,30 @@ class Paths
return 'assets/fonts/$key'; return 'assets/fonts/$key';
} }
inline static public function getSparrowAtlas(key:String, ?library:String) inline static public function getSparrowAtlas(key:String, ?library:String, ?isCharacter:Bool = false)
{ {
if (isCharacter)
if (FlxG.save.data.cacheImages)
return FlxAtlasFrames.fromSparrow(imageCached(key), file('images/characters/$key.xml', library));
else
return FlxAtlasFrames.fromSparrow(image('characters/$key'), file('images/characters/$key.xml'));
return FlxAtlasFrames.fromSparrow(image(key, library), file('images/$key.xml', library)); return FlxAtlasFrames.fromSparrow(image(key, library), file('images/$key.xml', library));
} }
inline static public function getPackerAtlas(key:String, ?library:String) inline static public function imageCached(key:String):FlxGraphic
{ {
var data = Caching.bitmapData.get(key);
trace('finding ${key} - ${data.bitmap}');
return data;
}
inline static public function getPackerAtlas(key:String, ?library:String, ?isCharacter:Bool = false)
{
if (isCharacter)
if (FlxG.save.data.cacheImages)
return FlxAtlasFrames.fromSpriteSheetPacker(imageCached(key), file('images/$key.txt', library));
else
return FlxAtlasFrames.fromSpriteSheetPacker(image('characters/$key'), file('images/characters/$key.txt'));
return FlxAtlasFrames.fromSpriteSheetPacker(image(key, library), file('images/$key.txt', library)); return FlxAtlasFrames.fromSpriteSheetPacker(image(key, library), file('images/$key.txt', library));
} }
} }

View File

@ -2776,7 +2776,7 @@ class PlayState extends MusicBeatState
else else
{ {
FlxG.sound.playMusic(Paths.music('freakyMenu')); FlxG.sound.playMusic(Paths.music('freakyMenu'));
FlxG.switchState(new MainMenuState()); FlxG.switchState(new StoryMenuState());
} }
#if windows #if windows

View File

@ -75,7 +75,7 @@ class ResultsScreen extends FlxSubState
text.text = "Week Cleared!"; text.text = "Week Cleared!";
} }
comboText = new FlxText(20,-75,0,'Judgements:\nSicks - ${PlayState.sicks}\nGoods - ${PlayState.goods}\nBads - ${PlayState.bads}\n\nCombo Breaks: ${(PlayState.isStoryMode ? PlayState.campaignMisses : PlayState.misses)}\nHighest Combo: ${PlayState.highestCombo + 1}\n\nScore: ${PlayState.instance.songScore}\nAccuracy: ${HelperFunctions.truncateFloat(PlayState.instance.accuracy,2)}%\n\n${Ratings.GenerateLetterRank(PlayState.instance.accuracy)}\n\nF1 - View replay\nF2 - Replay song comboText = new FlxText(20,-75,0,'Judgements:\nSicks - ${PlayState.sicks}\nGoods - ${PlayState.goods}\nBads - ${PlayState.bads}\n\nCombo Breaks: ${(PlayState.isStoryMode ? PlayState.campaignMisses : PlayState.misses)}\nHighest Combo: ${PlayState.highestCombo + 1}\nScore: ${PlayState.instance.songScore}\nAccuracy: ${HelperFunctions.truncateFloat(PlayState.instance.accuracy,2)}%\n\n${Ratings.GenerateLetterRank(PlayState.instance.accuracy)}\n\nF1 - View replay\nF2 - Replay song
'); ');
comboText.size = 28; comboText.size = 28;
comboText.setBorderStyle(FlxTextBorderStyle.OUTLINE,FlxColor.BLACK,4,1); comboText.setBorderStyle(FlxTextBorderStyle.OUTLINE,FlxColor.BLACK,4,1);

View File

@ -67,16 +67,7 @@ class TitleState extends MusicBeatState
trace("Loaded " + openfl.Assets.getLibrary("default").assetsLoaded + " assets (DEFAULT)"); trace("Loaded " + openfl.Assets.getLibrary("default").assetsLoaded + " assets (DEFAULT)");
} }
PlayerSettings.init();
#if windows
DiscordClient.initialize();
Application.current.onExit.add (function (exitCode) {
DiscordClient.shutdown();
});
#end
curWacky = FlxG.random.getObject(getIntroTextShit()); curWacky = FlxG.random.getObject(getIntroTextShit());
@ -93,15 +84,9 @@ class TitleState extends MusicBeatState
trace('NEWGROUNDS LOL'); trace('NEWGROUNDS LOL');
#end #end
FlxG.save.bind('funkin', 'ninjamuffin99');
KadeEngineData.initSave();
// var file:SMFile = SMFile.loadFile("file.sm"); // var file:SMFile = SMFile.loadFile("file.sm");
// this was testing things // this was testing things
Highscore.load();
#if FREEPLAY #if FREEPLAY
FlxG.switchState(new FreeplayState()); FlxG.switchState(new FreeplayState());
#elseif CHARTING #elseif CHARTING