From e5c63674293aa92c70b40b3c055445ec3bc60d34 Mon Sep 17 00:00:00 2001 From: Fyrid19 Date: Wed, 11 Sep 2024 23:10:21 -0400 Subject: [PATCH] re-organized some stuff, working on stages --- Project.xml | 3 + cmd/data/haxelibs.json | 5 + source/animate/FlxAnimate.hx | 149 -------- source/animate/FlxSymbol.hx | 324 ------------------ source/backend/Conductor.hx | 2 +- source/funkin/charting/ChartingState.hx | 8 +- .../funkin/{states => game}/PauseSubState.hx | 2 +- source/funkin/{states => game}/PlayState.hx | 11 +- .../NoteData.hx => game/notes/Direction.hx} | 2 +- source/funkin/{objects => game}/notes/Note.hx | 6 +- .../funkin/{objects => game}/notes/NoteNew.hx | 31 +- .../{objects => game}/notes/NoteSplash.hx | 2 +- .../{objects => game}/notes/StrumLine.hx | 7 +- .../{objects => game}/notes/StrumNote.hx | 2 +- .../{objects => game}/notes/SustainTrail.hx | 4 +- source/funkin/game/notes/import.hx | 4 + source/funkin/game/notes/skins/NoteSkin.hx | 13 + .../{ => game}/objects/BackgroundDancer.hx | 2 +- .../{ => game}/objects/BackgroundGirls.hx | 2 +- source/funkin/{ => game}/objects/Boyfriend.hx | 2 +- source/funkin/{ => game}/objects/Character.hx | 2 +- .../{ => game}/objects/CutsceneCharacter.hx | 2 +- .../ui => game/objects}/HealthIcon.hx | 2 +- source/funkin/{ => game}/objects/TankmenBG.hx | 2 +- .../funkin/{objects => game/song}/Section.hx | 2 +- source/funkin/{objects => game/song}/Song.hx | 4 +- source/funkin/game/song/SongGroup.hx | 44 +++ .../{objects => game/stage}/BGSprite.hx | 2 +- source/funkin/game/stage/BGSpriteNew.hx | 14 + source/funkin/game/stage/FunkinStage.hx | 13 + source/funkin/objects/notes/NoteBasic.hx | 10 - source/funkin/objects/notes/import.hx | 5 - source/funkin/objects/notes/skins/NoteSkin.hx | 13 - source/funkin/objects/ui/Prompt.hx | 115 ------- source/funkin/states/debug/TestPlayState.hx | 2 +- source/import.hx | 4 +- source/utils/NoteSkinUtil.hx | 39 --- 37 files changed, 135 insertions(+), 721 deletions(-) delete mode 100644 source/animate/FlxAnimate.hx delete mode 100644 source/animate/FlxSymbol.hx rename source/funkin/{states => game}/PauseSubState.hx (99%) rename source/funkin/{states => game}/PlayState.hx (99%) rename source/funkin/{objects/notes/NoteData.hx => game/notes/Direction.hx} (95%) rename source/funkin/{objects => game}/notes/Note.hx (98%) rename source/funkin/{objects => game}/notes/NoteNew.hx (65%) rename source/funkin/{objects => game}/notes/NoteSplash.hx (97%) rename source/funkin/{objects => game}/notes/StrumLine.hx (92%) rename source/funkin/{objects => game}/notes/StrumNote.hx (97%) rename source/funkin/{objects => game}/notes/SustainTrail.hx (95%) create mode 100644 source/funkin/game/notes/import.hx create mode 100644 source/funkin/game/notes/skins/NoteSkin.hx rename source/funkin/{ => game}/objects/BackgroundDancer.hx (96%) rename source/funkin/{ => game}/objects/BackgroundGirls.hx (96%) rename source/funkin/{ => game}/objects/Boyfriend.hx (96%) rename source/funkin/{ => game}/objects/Character.hx (99%) rename source/funkin/{ => game}/objects/CutsceneCharacter.hx (98%) rename source/funkin/{objects/ui => game/objects}/HealthIcon.hx (97%) rename source/funkin/{ => game}/objects/TankmenBG.hx (98%) rename source/funkin/{objects => game/song}/Section.hx (95%) rename source/funkin/{objects => game/song}/Song.hx (95%) create mode 100644 source/funkin/game/song/SongGroup.hx rename source/funkin/{objects => game/stage}/BGSprite.hx (96%) create mode 100644 source/funkin/game/stage/BGSpriteNew.hx create mode 100644 source/funkin/game/stage/FunkinStage.hx delete mode 100644 source/funkin/objects/notes/NoteBasic.hx delete mode 100644 source/funkin/objects/notes/import.hx delete mode 100644 source/funkin/objects/notes/skins/NoteSkin.hx delete mode 100644 source/funkin/objects/ui/Prompt.hx delete mode 100644 source/utils/NoteSkinUtil.hx diff --git a/Project.xml b/Project.xml index 87880dd..78fcbc1 100644 --- a/Project.xml +++ b/Project.xml @@ -106,6 +106,9 @@ + + + diff --git a/cmd/data/haxelibs.json b/cmd/data/haxelibs.json index 514514c..8a37595 100644 --- a/cmd/data/haxelibs.json +++ b/cmd/data/haxelibs.json @@ -70,6 +70,11 @@ "version": "", "git": "https://github.com/larsiusprime/polymod" }, + { + "name": "flxanimate", + "version": "", + "git": "https://github.com/Fyrid19/flxanimate" + }, { "name": "hxdiscord_rpc", "version": "", diff --git a/source/animate/FlxAnimate.hx b/source/animate/FlxAnimate.hx deleted file mode 100644 index 635cbe5..0000000 --- a/source/animate/FlxAnimate.hx +++ /dev/null @@ -1,149 +0,0 @@ -package animate; - -// import animateAtlasPlayer.assets.AssetManager; -// import animateAtlasPlayer.core.Animation; -import animate.FlxSymbol.Parsed; -import flixel.FlxG; -import flixel.FlxSprite; -import flixel.graphics.FlxGraphic; -import flixel.graphics.frames.FlxAtlasFrames; -import flixel.math.FlxPoint; -import flixel.math.FlxRect; -import flixel.system.FlxAssets.FlxGraphicAsset; -import haxe.Json; -import openfl.Assets; -import openfl.display.BitmapData; -import openfl.geom.Rectangle; - -class FlxAnimate extends FlxSymbol -{ - // var myAnim:Animation; - // var animBitmap:BitmapData; - var loadedQueue:Bool = false; - - var swagFrames:Array = []; - - public function new(x:Float, y:Float) - { - var folder:String = 'tightBars'; - coolParse = cast Json.parse(Assets.getText(Paths.file('images/' + folder + '/Animation.json'))); - coolParse.AN.TL.L.reverse(); - super(x, y, coolParse); - - frames = FlxAnimate.fromAnimate(Paths.file('images/' + folder + '/spritemap1.png'), Paths.file('images/' + folder + '/spritemap1.json')); - // frames - } - - override function draw() - { - super.draw(); - - renderFrame(coolParse.AN.TL, coolParse, true); - - if (FlxG.keys.justPressed.E) - { - for (shit in FlxSymbol.nestedShit.keys()) - { - for (spr in FlxSymbol.nestedShit.get(shit)) - { - spr.draw(); - } - } - - FlxSymbol.nestedShit.clear(); - } - } - - var curFrame:Int = 0; - - // notes to self - // account for different layers - var playingAnim:Bool = false; - var frameTickTypeShit:Float = 0; - var animFrameRate:Int = 24; - - override function update(elapsed:Float) - { - super.update(elapsed); - - if (FlxG.keys.justPressed.SPACE) - playingAnim = !playingAnim; - - if (playingAnim) - { - frameTickTypeShit += elapsed; - - // prob fix this framerate thing for higher framerates? - if (frameTickTypeShit >= 1 / 24) - { - changeFrame(1); - frameTickTypeShit = 0; - } - } - - if (FlxG.keys.justPressed.RIGHT) - changeFrame(1); - if (FlxG.keys.justPressed.LEFT) - changeFrame(-1); - } - - // This stuff is u - public static function fromAnimate(Source:FlxGraphicAsset, Description:String):FlxAtlasFrames - { - var graphic:FlxGraphic = FlxG.bitmap.add(Source); - if (graphic == null) - return null; - - var frames:FlxAtlasFrames = FlxAtlasFrames.findFrame(graphic); - if (frames != null) - return frames; - - if (graphic == null || Description == null) - return null; - - frames = new FlxAtlasFrames(graphic); - - var data:AnimateObject; - - var json:String = Description; - - trace(json); - - if (Assets.exists(json)) - json = Assets.getText(json); - - data = cast Json.parse(json).ATLAS; - - for (sprite in data.SPRITES) - { - // probably nicer way to do this? Oh well - var swagSprite:AnimateSprite = sprite.SPRITE; - - var rect = FlxRect.get(swagSprite.x, swagSprite.y, swagSprite.w, swagSprite.h); - - var size = new Rectangle(0, 0, rect.width, rect.height); - - var offset = FlxPoint.get(-size.left, -size.top); - var sourceSize = FlxPoint.get(size.width, size.height); - - frames.addAtlasFrame(rect, sourceSize, offset, swagSprite.name); - } - - return frames; - } -} - -typedef AnimateObject = -{ - SPRITES:Array -} - -typedef AnimateSprite = -{ - var name:String; - var x:Int; - var y:Int; - var w:Int; - var h:Int; - var rotated:Bool; -} diff --git a/source/animate/FlxSymbol.hx b/source/animate/FlxSymbol.hx deleted file mode 100644 index 749abbe..0000000 --- a/source/animate/FlxSymbol.hx +++ /dev/null @@ -1,324 +0,0 @@ -package animate; - -import flixel.FlxCamera; -import flixel.FlxSprite; -import flixel.graphics.frames.FlxFrame.FlxFrameAngle; -import flixel.math.FlxAngle; -import flixel.math.FlxMatrix; -import flixel.math.FlxPoint; -import openfl.geom.Matrix; - -class FlxSymbol extends FlxSprite -{ - public var coolParse:Parsed; - public var oldMatrix:Array = []; - - private var hasFrameByPass:Bool = false; - - public function new(x:Float, y:Float, coolParsed:Parsed) - { - super(x, y); - - this.coolParse = coolParsed; - - var hasSymbolDictionary:Bool = Reflect.hasField(coolParse, "SD"); - - if (hasSymbolDictionary) - symbolAtlasShit = parseSymbolDictionary(coolParse); - } - - var symbolAtlasShit:Map = new Map(); - - override function draw() - { - super.draw(); - } - - public static var nestedShit:Map> = new Map(); - - var symbolMap:Map = new Map(); - - var drawQueue:Array = []; - - public var daFrame:Int = 0; - public var nestDepth:Int = 0; - - public var transformMatrix:Matrix = new Matrix(); - - function renderFrame(TL:Timeline, coolParsed:Parsed, ?isMainLoop:Bool = false) - { - drawQueue = []; - - for (layer in TL.L) - { - // layer.FR.reverse(); - // var frame = layer.FR[0] - - for (frame in layer.FR) - { - if (daFrame >= frame.I && daFrame < frame.I + frame.DU) - { - for (element in frame.E) - { - if (Reflect.hasField(element, 'ASI')) - { - var m3d = element.ASI.M3D; - var dumbassMatrix:Matrix = new Matrix(m3d[0], m3d[1], m3d[4], m3d[5], m3d[12], m3d[13]); - - var spr:FlxSymbol = new FlxSymbol(0, 0, coolParsed); - matrixExposed = true; - spr.frames = frames; - spr.frame = spr.frames.getByName(element.ASI.N); - - // dumbassMatrix.translate(origin.x, origin.y); - - dumbassMatrix.concat(_matrix); - spr.matrixExposed = true; - spr.transformMatrix.concat(dumbassMatrix); - // spr._matrix.concat(spr.transformMatrix); - - spr.origin.set(); - spr.origin.x += origin.x; - spr.origin.y += origin.y; - - spr.antialiasing = true; - spr.draw(); - } - else - { - var nestedSymbol = symbolMap.get(element.SI.SN); - var nestedShit:FlxSymbol = new FlxSymbol(0, 0, coolParse); - nestedShit.frames = frames; - - var swagMatrix:FlxMatrix = new FlxMatrix(element.SI.M3D[0], element.SI.M3D[1], element.SI.M3D[4], element.SI.M3D[5], - element.SI.M3D[12], element.SI.M3D[13]); - - swagMatrix.concat(_matrix); - - nestedShit._matrix.concat(swagMatrix); - nestedShit.origin.set(element.SI.TRP.x, element.SI.TRP.y); - // nestedShit.angle += ((180 / Math.PI) * Math.atan2(swagMatrix.b, swagMatrix.a)); - // nestedShit.angle += angle; - - if (symbolAtlasShit.exists(nestedSymbol.SN)) - { - // nestedShit.frames.getByName(symbolAtlasShit.get(nestedSymbol.SN)); - // nestedShit.draw(); - } - - // scale.y = Math.sqrt(_matrix.c * _matrix.c + _matrix.d * _matrix.d); - // scale.x = Math.sqrt(_matrix.a * _matrix.a + _matrix.b * _matrix.b); - - // nestedShit.oldMatrix = element.SI.M3D; - - nestedShit.hasFrameByPass = true; - nestedShit.nestDepth = nestDepth + 1; - nestedShit.renderFrame(nestedSymbol.TL, coolParsed); - - // renderFrame(nestedSymbol.TL, coolParsed); - } - } - } - } - } - - // drawQueue.reverse(); - // - // for (thing in drawQueue) - // thing.draw(); - } - - function setDaMap(spr:FlxSymbol):Void - { - if (!nestedShit.exists(nestDepth)) - nestedShit.set(nestDepth, [spr]); - else - nestedShit.get(nestDepth).push(spr); - } - - function changeFrame(frameChange:Int = 0):Void - { - daFrame += frameChange; - } - - function parseSymbolDictionary(coolParsed:Parsed):Map - { - var awesomeMap:Map = new Map(); - for (symbol in coolParsed.SD.S) - { - symbolMap.set(symbol.SN, symbol); - - var symbolName = symbol.SN; - for (layer in symbol.TL.L) - { - for (frame in layer.FR) - { - for (element in frame.E) - { - if (Reflect.hasField(element, 'ASI')) - { - awesomeMap.set(symbolName, element.ASI.N); - } - } - } - } - } - - return awesomeMap; - } - - override function drawComplex(camera:FlxCamera):Void - { - _frame.prepareMatrix(_matrix, FlxFrameAngle.ANGLE_0, checkFlipX(), checkFlipY()); - _matrix.translate(-origin.x, -origin.y); - _matrix.scale(scale.x, scale.y); - - if (matrixExposed) - { - _matrix.concat(transformMatrix); - } - else - { - if (bakedRotationAngle <= 0) - { - updateTrig(); - - if (angle != 0) - _matrix.rotateWithTrig(_cosAngle, _sinAngle); - } - - // updateSkewMatrix(); - _matrix.concat(_skewMatrix); - } - - _point.addPoint(origin); - if (isPixelPerfectRender(camera)) - _point.floor(); - - _matrix.translate(_point.x, _point.y); - camera.drawPixels(_frame, framePixels, _matrix, colorTransform, blend, antialiasing); - } - - var _skewMatrix:Matrix = new Matrix(); - - // public var transformMatrix(default, null):Matrix = new Matrix(); - - /** - * Bool flag showing whether transformMatrix is used for rendering or not. - * False by default, which means that transformMatrix isn't used for rendering - */ - public var matrixExposed:Bool = false; - - public var skew(default, null):FlxPoint = FlxPoint.get(); - - function updateSkewMatrix():Void - { - _skewMatrix.identity(); - - if (skew.x != 0 || skew.y != 0) - { - _skewMatrix.b = Math.tan(skew.y * FlxAngle.TO_RAD); - _skewMatrix.c = Math.tan(skew.x * FlxAngle.TO_RAD); - } - } -} - -// TYPEDEFS FOR ANIMATION.JSON PARSING - -typedef Parsed = -{ - var MD:Metadata; - var AN:Animation; - var SD:SymbolDictionary; // Doesn't always have symbol dictionary!! -} - -typedef Metadata = -{ - /** Framerate */ - var FRT:Int; -} - -/** Basically treated like one big symbol*/ -typedef Animation = -{ - /** symbolName */ - var SN:String; - - var TL:Timeline; - - /** IDK what STI stands for, Symbole Type Instance? - Anyways, it is NOT used in SYMBOLS, only the main AN animation - */ - var STI:Dynamic; -} - -/** DISCLAIMER, MAY NOT ACTUALLY BE CALLED - SYMBOL TYPE ISNTANCE, IM JUST MAKING ASSUMPTION!! */ -typedef SymbolTypeInstance = -{ - // var TL:Timeline; - // var SN:String; -} - -typedef SymbolDictionary = -{ - var S:Array; -} - -typedef Timeline = -{ - /** Layers */ - var L:Array; -} - -// Singular layer, not to be confused with LAYERS -typedef Layer = -{ - var LN:String; - - /** Frames */ - var FR:Array; -} - -typedef Frame = -{ - var I:Int; - - /** Duration, in frames*/ - var DU:Int; - - /** Elements*/ - var E:Array; -} - -typedef Element = -{ - var SI:SymbolInstance; - var ASI:AtlasSymbolInstance; -} - -/** - Symbol instance, for SYMBOLS and refers to SYMBOLS - */ -typedef SymbolInstance = -{ - var SN:String; - - /** SymbolType (Graphic, Movieclip, Button)*/ - var ST:String; - - var TRP:TransformationPoint; - var M3D:Array; -} - -typedef AtlasSymbolInstance = -{ - var N:String; - var M3D:Array; -} - -typedef TransformationPoint = -{ - var x:Float; - var y:Float; -} diff --git a/source/backend/Conductor.hx b/source/backend/Conductor.hx index 95c63cb..6ac75ad 100644 --- a/source/backend/Conductor.hx +++ b/source/backend/Conductor.hx @@ -1,6 +1,6 @@ package backend; -import funkin.objects.Song.SwagSong; +import funkin.game.song.Song.SwagSong; /** * ... diff --git a/source/funkin/charting/ChartingState.hx b/source/funkin/charting/ChartingState.hx index fb058f3..2169e6c 100644 --- a/source/funkin/charting/ChartingState.hx +++ b/source/funkin/charting/ChartingState.hx @@ -1,7 +1,7 @@ package funkin.charting; -import funkin.objects.Section.SwagSection; -import funkin.objects.Song.SwagSong; +import funkin.game.song.Section.SwagSection; +import funkin.game.song.Song.SwagSong; import flixel.addons.display.FlxGridOverlay; import flixel.addons.ui.FlxInputText; @@ -30,8 +30,8 @@ import openfl.media.Sound; import openfl.net.FileReference; import openfl.utils.ByteArray; -import funkin.objects.notes.Note; -import funkin.objects.notes.NoteSplash; +import funkin.game.notes.Note; +import funkin.game.notes.NoteSplash; class ChartingState extends MusicBeatState { diff --git a/source/funkin/states/PauseSubState.hx b/source/funkin/game/PauseSubState.hx similarity index 99% rename from source/funkin/states/PauseSubState.hx rename to source/funkin/game/PauseSubState.hx index 046d451..bdaea2d 100644 --- a/source/funkin/states/PauseSubState.hx +++ b/source/funkin/game/PauseSubState.hx @@ -1,4 +1,4 @@ -package funkin.states; +package funkin.game; import flixel.input.keyboard.FlxKey; import flixel.sound.FlxSound; diff --git a/source/funkin/states/PlayState.hx b/source/funkin/game/PlayState.hx similarity index 99% rename from source/funkin/states/PlayState.hx rename to source/funkin/game/PlayState.hx index 92f8e06..ebf1b44 100644 --- a/source/funkin/states/PlayState.hx +++ b/source/funkin/game/PlayState.hx @@ -1,7 +1,7 @@ -package funkin.states; +package funkin.game; -import funkin.objects.Section.SwagSection; -import funkin.objects.Song.SwagSong; +import funkin.game.song.Section.SwagSection; +import funkin.game.song.Song.SwagSong; import flixel.FlxCamera; import flixel.addons.effects.FlxTrail; import flixel.addons.effects.chainable.FlxWaveEffect; @@ -19,8 +19,9 @@ import hxvlc.flixel.FlxVideoSprite; import funkin.charting.ChartingState; -import funkin.objects.notes.Note; -import funkin.objects.notes.NoteSplash; +import funkin.game.stage.BGSprite; +import funkin.game.notes.Note; +import funkin.game.notes.NoteSplash; class PlayState extends MusicBeatState { diff --git a/source/funkin/objects/notes/NoteData.hx b/source/funkin/game/notes/Direction.hx similarity index 95% rename from source/funkin/objects/notes/NoteData.hx rename to source/funkin/game/notes/Direction.hx index 8c1fadf..4da7fc8 100644 --- a/source/funkin/objects/notes/NoteData.hx +++ b/source/funkin/game/notes/Direction.hx @@ -1,4 +1,4 @@ -package funkin.objects.notes; +package funkin.game.notes; // based off funkin kinda enum abstract Direction(Int) from Int to Int { diff --git a/source/funkin/objects/notes/Note.hx b/source/funkin/game/notes/Note.hx similarity index 98% rename from source/funkin/objects/notes/Note.hx rename to source/funkin/game/notes/Note.hx index 340efeb..cae42a5 100644 --- a/source/funkin/objects/notes/Note.hx +++ b/source/funkin/game/notes/Note.hx @@ -1,8 +1,4 @@ -package funkin.objects.notes; - -#if polymod -import polymod.format.ParseRules.TargetSignatureElement; -#end +package funkin.game.notes; class Note extends FlxSprite { public var strumTime:Float = 0; diff --git a/source/funkin/objects/notes/NoteNew.hx b/source/funkin/game/notes/NoteNew.hx similarity index 65% rename from source/funkin/objects/notes/NoteNew.hx rename to source/funkin/game/notes/NoteNew.hx index 503ab07..c4b9fa0 100644 --- a/source/funkin/objects/notes/NoteNew.hx +++ b/source/funkin/game/notes/NoteNew.hx @@ -1,6 +1,6 @@ -package funkin.objects.notes; +package funkin.game.notes; -class NoteNew extends FlxSprite implements NoteBasic { +class NoteNew extends FlxSprite { public var strumTime:Float = 0; // The time the note will appear on the strum line public var noteType:String = ''; // The name of the note type (Nothing for default) @@ -35,34 +35,9 @@ class NoteNew extends FlxSprite implements NoteBasic { this.noteDirection = noteDirection; this.strumLine = strumLine; - noteSkin.parse(); - var curStage:String = PlayState.curStage; - if (curStage.startsWith('school')) { - noteSkin.jsonPath = Paths.noteSkin('pixel'); // so i can softcode later - noteSkin.path = 'weeb/pixelUI/arrows-pixels'; - noteSkin.extraPaths[0] = 'weeb/pixelUI/arrowEnds'; - noteSkin.extraData = [17, 17, 7, 6, PlayState.daPixelZoom]; // width, height, sustain width, sustain height, zoom - noteSkin.atlasIncluded = false; - noteSkin.antialiasing = false; - } - - antialiasing = noteSkin.antialiasing; - - var color:String = noteDirection.getColor(); - if (noteSkin.atlasIncluded) { - frames = Paths.getSparrowAtlas(noteSkin.path); - animation.addByPrefix('scroll', '$color instance'); - setGraphicSize(Std.int(width * 0.7)); - updateHitbox(); - } else { - loadGraphic(Paths.image(noteSkin.path), true, noteSkin.extraData[0], noteSkin.extraData[1]); - animation.add('scroll', [4 + noteDirection]); - setGraphicSize(Std.int(width * noteSkin.extraData[4])); - updateHitbox(); - } + // insert stupid hscript BULLSHIT. x += swagWidth * noteDirection; - animation.play('scroll'); } override function update(elapsed:Float) { diff --git a/source/funkin/objects/notes/NoteSplash.hx b/source/funkin/game/notes/NoteSplash.hx similarity index 97% rename from source/funkin/objects/notes/NoteSplash.hx rename to source/funkin/game/notes/NoteSplash.hx index 8e36b2d..602325f 100644 --- a/source/funkin/objects/notes/NoteSplash.hx +++ b/source/funkin/game/notes/NoteSplash.hx @@ -1,4 +1,4 @@ -package funkin.objects.notes; +package funkin.game.notes; import haxe.io.Path; diff --git a/source/funkin/objects/notes/StrumLine.hx b/source/funkin/game/notes/StrumLine.hx similarity index 92% rename from source/funkin/objects/notes/StrumLine.hx rename to source/funkin/game/notes/StrumLine.hx index b672f73..455bb93 100644 --- a/source/funkin/objects/notes/StrumLine.hx +++ b/source/funkin/game/notes/StrumLine.hx @@ -1,8 +1,7 @@ -package funkin.objects.notes; +package funkin.game.notes; -import funkin.objects.notes.NoteBasic; -import funkin.objects.notes.NoteNew as Note; -import funkin.objects.notes.SustainTrail; +import funkin.game.notes.NoteNew as Note; +import funkin.game.notes.SustainTrail; import flixel.util.FlxSort; class StrumLine extends FlxSpriteGroup { diff --git a/source/funkin/objects/notes/StrumNote.hx b/source/funkin/game/notes/StrumNote.hx similarity index 97% rename from source/funkin/objects/notes/StrumNote.hx rename to source/funkin/game/notes/StrumNote.hx index 9447e39..759cb8f 100644 --- a/source/funkin/objects/notes/StrumNote.hx +++ b/source/funkin/game/notes/StrumNote.hx @@ -1,4 +1,4 @@ -package funkin.objects.notes; +package funkin.game.notes; import flixel.graphics.frames.FlxFrame; diff --git a/source/funkin/objects/notes/SustainTrail.hx b/source/funkin/game/notes/SustainTrail.hx similarity index 95% rename from source/funkin/objects/notes/SustainTrail.hx rename to source/funkin/game/notes/SustainTrail.hx index aee228b..85f34b9 100644 --- a/source/funkin/objects/notes/SustainTrail.hx +++ b/source/funkin/game/notes/SustainTrail.hx @@ -1,10 +1,10 @@ -package funkin.objects.notes; +package funkin.game.notes; import flixel.graphics.tile.FlxDrawTrianglesItem.DrawData; import flixel.FlxStrip; // somewhat based off base fnf sustain trail -class SustainTrail extends FlxStrip implements NoteBasic { +class SustainTrail extends FlxStrip { public var strumTime:Float = 0; // The time the note will appear on the strum line public var noteType:String = ''; // The name of the note type (Nothing for default) diff --git a/source/funkin/game/notes/import.hx b/source/funkin/game/notes/import.hx new file mode 100644 index 0000000..e37da54 --- /dev/null +++ b/source/funkin/game/notes/import.hx @@ -0,0 +1,4 @@ +package funkin.game.notes; + +import funkin.game.notes.skins.NoteSkin; +import funkin.game.notes.Direction; \ No newline at end of file diff --git a/source/funkin/game/notes/skins/NoteSkin.hx b/source/funkin/game/notes/skins/NoteSkin.hx new file mode 100644 index 0000000..8532fb0 --- /dev/null +++ b/source/funkin/game/notes/skins/NoteSkin.hx @@ -0,0 +1,13 @@ +package funkin.game.notes.skins; + +class NoteSkin { + public var skinName:String; + public var displayName:String; + public var path:String; + + public function new(path:String, skinName:String, ?displayName:String) { + this.skinName = skinName; + this.displayName = displayName != null ? displayName : skinName; + this.path = path; + } +} \ No newline at end of file diff --git a/source/funkin/objects/BackgroundDancer.hx b/source/funkin/game/objects/BackgroundDancer.hx similarity index 96% rename from source/funkin/objects/BackgroundDancer.hx rename to source/funkin/game/objects/BackgroundDancer.hx index 5e70fad..918197c 100644 --- a/source/funkin/objects/BackgroundDancer.hx +++ b/source/funkin/game/objects/BackgroundDancer.hx @@ -1,4 +1,4 @@ -package funkin.objects; +package funkin.game.objects; class BackgroundDancer extends FlxSprite { diff --git a/source/funkin/objects/BackgroundGirls.hx b/source/funkin/game/objects/BackgroundGirls.hx similarity index 96% rename from source/funkin/objects/BackgroundGirls.hx rename to source/funkin/game/objects/BackgroundGirls.hx index c29205e..126a078 100644 --- a/source/funkin/objects/BackgroundGirls.hx +++ b/source/funkin/game/objects/BackgroundGirls.hx @@ -1,4 +1,4 @@ -package funkin.objects; +package funkin.game.objects; class BackgroundGirls extends FlxSprite { diff --git a/source/funkin/objects/Boyfriend.hx b/source/funkin/game/objects/Boyfriend.hx similarity index 96% rename from source/funkin/objects/Boyfriend.hx rename to source/funkin/game/objects/Boyfriend.hx index 07b7577..a793605 100644 --- a/source/funkin/objects/Boyfriend.hx +++ b/source/funkin/game/objects/Boyfriend.hx @@ -1,4 +1,4 @@ -package funkin.objects; +package funkin.game.objects; class Boyfriend extends Character { diff --git a/source/funkin/objects/Character.hx b/source/funkin/game/objects/Character.hx similarity index 99% rename from source/funkin/objects/Character.hx rename to source/funkin/game/objects/Character.hx index 80a4391..9d78968 100644 --- a/source/funkin/objects/Character.hx +++ b/source/funkin/game/objects/Character.hx @@ -1,4 +1,4 @@ -package funkin.objects; +package funkin.game.objects; import flixel.util.FlxSort; diff --git a/source/funkin/objects/CutsceneCharacter.hx b/source/funkin/game/objects/CutsceneCharacter.hx similarity index 98% rename from source/funkin/objects/CutsceneCharacter.hx rename to source/funkin/game/objects/CutsceneCharacter.hx index e2473b3..ab412af 100644 --- a/source/funkin/objects/CutsceneCharacter.hx +++ b/source/funkin/game/objects/CutsceneCharacter.hx @@ -1,4 +1,4 @@ -package funkin.objects; +package funkin.game.objects; import flixel.math.FlxPoint; diff --git a/source/funkin/objects/ui/HealthIcon.hx b/source/funkin/game/objects/HealthIcon.hx similarity index 97% rename from source/funkin/objects/ui/HealthIcon.hx rename to source/funkin/game/objects/HealthIcon.hx index 0772dff..cfc1f7e 100644 --- a/source/funkin/objects/ui/HealthIcon.hx +++ b/source/funkin/game/objects/HealthIcon.hx @@ -1,4 +1,4 @@ -package funkin.objects.ui; +package funkin.game.objects; class HealthIcon extends FlxSprite { diff --git a/source/funkin/objects/TankmenBG.hx b/source/funkin/game/objects/TankmenBG.hx similarity index 98% rename from source/funkin/objects/TankmenBG.hx rename to source/funkin/game/objects/TankmenBG.hx index 13f6dcf..4f3fe99 100644 --- a/source/funkin/objects/TankmenBG.hx +++ b/source/funkin/game/objects/TankmenBG.hx @@ -1,4 +1,4 @@ -package funkin.objects; +package funkin.game.objects; import haxe.display.Display.Package; diff --git a/source/funkin/objects/Section.hx b/source/funkin/game/song/Section.hx similarity index 95% rename from source/funkin/objects/Section.hx rename to source/funkin/game/song/Section.hx index e1334f3..75d1ede 100644 --- a/source/funkin/objects/Section.hx +++ b/source/funkin/game/song/Section.hx @@ -1,4 +1,4 @@ -package funkin.objects; +package funkin.game.song; typedef SwagSection = { diff --git a/source/funkin/objects/Song.hx b/source/funkin/game/song/Song.hx similarity index 95% rename from source/funkin/objects/Song.hx rename to source/funkin/game/song/Song.hx index f62b962..ad63574 100644 --- a/source/funkin/objects/Song.hx +++ b/source/funkin/game/song/Song.hx @@ -1,6 +1,6 @@ -package funkin.objects; +package funkin.game.song; -import funkin.objects.Section.SwagSection; +import funkin.game.song.Section.SwagSection; import haxe.Json; import lime.utils.Assets; diff --git a/source/funkin/game/song/SongGroup.hx b/source/funkin/game/song/SongGroup.hx new file mode 100644 index 0000000..94488df --- /dev/null +++ b/source/funkin/game/song/SongGroup.hx @@ -0,0 +1,44 @@ +package funkin.game.song; + +import flixel.sound.FlxSound; + +class SongGroup { + public var inst:FlxSound; + public var voices:Array; + + public function new(song:String, ?difficulty:String, ?voiceSuffixes:Array) { + inst = new FlxSound().loadEmbedded(Paths.inst(song, difficulty)); + voices = new Array(); + + voices = []; + for (i in 0...voiceSuffixes.length) { + var vocalTrack:FlxSound = new FlxSound().loadEmbedded(Paths.voices(song, voiceSuffixes[i], difficulty)); + voices.push(vocalTrack); + } + } + + // is supposed to prevent that weird audio bug + // but then again just make your inst and voices the same length + public function update() { + if (inst != null && voices != null) { + for (i in 0...voices.length) { + if (inst.time > voices[i].length) { + voices[i].destroy(); + } + } + } + } + + public function play() { + if (inst != null) inst.play(); + if (voices != null) for (i in 0...voices.length) { + voices[i].play(); + } + } + + public function syncVoices() { + if (voices != null && inst != null) for (i in 0...voices.length) { + voices[i].time = inst.time; + } + } +} \ No newline at end of file diff --git a/source/funkin/objects/BGSprite.hx b/source/funkin/game/stage/BGSprite.hx similarity index 96% rename from source/funkin/objects/BGSprite.hx rename to source/funkin/game/stage/BGSprite.hx index c8e2f2e..d58c411 100644 --- a/source/funkin/objects/BGSprite.hx +++ b/source/funkin/game/stage/BGSprite.hx @@ -1,4 +1,4 @@ -package funkin.objects; +package funkin.game.stage; class BGSprite extends FlxSprite { diff --git a/source/funkin/game/stage/BGSpriteNew.hx b/source/funkin/game/stage/BGSpriteNew.hx new file mode 100644 index 0000000..d13448a --- /dev/null +++ b/source/funkin/game/stage/BGSpriteNew.hx @@ -0,0 +1,14 @@ +package funkin.game.stage; + +class BGSprite extends FlxSprite { + public var assetPath:String; + public var animated:Bool; + + public function new(Asset:String, X:Float, Y:Float, ?Animated:Bool, ?ScrollX:Float, ?ScrollY:Float) { + super(X, Y); + + if (!Asset.startsWith('assets/')) { + + } + } +} \ No newline at end of file diff --git a/source/funkin/game/stage/FunkinStage.hx b/source/funkin/game/stage/FunkinStage.hx new file mode 100644 index 0000000..d5039de --- /dev/null +++ b/source/funkin/game/stage/FunkinStage.hx @@ -0,0 +1,13 @@ +package funkin.game.stage; + +class FunkinStage { + public var bgSprites:FlxTypedGroup; + public var fgSprites:FlxTypedGroup; + public var stageSounds:Array; + public var soundSuffix:String; + + public function new() { + bgSprites = new FlxTypedGroup(); + fgSprites = new FlxTypedGroup(); + } +} \ No newline at end of file diff --git a/source/funkin/objects/notes/NoteBasic.hx b/source/funkin/objects/notes/NoteBasic.hx deleted file mode 100644 index fc87516..0000000 --- a/source/funkin/objects/notes/NoteBasic.hx +++ /dev/null @@ -1,10 +0,0 @@ -package funkin.objects.notes; - -interface NoteBasic { - public var strumTime:Float; - public var noteType:String; - public var noteTypeID:Int; - public var noteDirection:Direction; - public var strumLine:StrumLine; - public var noteSkin:NoteSkin; -} \ No newline at end of file diff --git a/source/funkin/objects/notes/import.hx b/source/funkin/objects/notes/import.hx deleted file mode 100644 index 9f77f91..0000000 --- a/source/funkin/objects/notes/import.hx +++ /dev/null @@ -1,5 +0,0 @@ -package funkin.objects.notes; - -import utils.NoteSkinUtil; -import utils.NoteSkinUtil.NoteSkin; -import funkin.objects.notes.NoteData.Direction; \ No newline at end of file diff --git a/source/funkin/objects/notes/skins/NoteSkin.hx b/source/funkin/objects/notes/skins/NoteSkin.hx deleted file mode 100644 index bfb1e61..0000000 --- a/source/funkin/objects/notes/skins/NoteSkin.hx +++ /dev/null @@ -1,13 +0,0 @@ -package funkin.objects.notes.skins; - -class NoteSkin { - public var skinName:String; - public var displayName:String; - public var assetPath:String; - - public function new(skinName:String, displayName:String, assetPath:String) { - this.skinName = skinName; - this.displayName = displayName; - this.assetPath = assetPath; - } -} \ No newline at end of file diff --git a/source/funkin/objects/ui/Prompt.hx b/source/funkin/objects/ui/Prompt.hx deleted file mode 100644 index a109627..0000000 --- a/source/funkin/objects/ui/Prompt.hx +++ /dev/null @@ -1,115 +0,0 @@ -package funkin.objects.ui; - -import funkin.ui.*; -import funkin.ui.AtlasText.BoldText; - -class Prompt extends flixel.FlxSubState -{ - inline static var MARGIN = 100; - - public var onYes:Void->Void; - public var onNo:Void->Void; - public var buttons:TextMenuList; - public var field:AtlasText; - public var back:FlxSprite; - - var style:ButtonStyle; - - public function new (text:String, style:ButtonStyle = Ok) - { - this.style = style; - super(0x80000000); - - buttons = new TextMenuList(Horizontal); - - field = new BoldText(text); - field.scrollFactor.set(0, 0); - } - - override function create() - { - super.create(); - - field.y = MARGIN; - field.screenCenter(X); - add(field); - - createButtons(); - add(buttons); - } - - public function createBg(width:Int, height:Int, color = 0xFF808080) - { - back = new FlxSprite(); - back.makeGraphic(width, height, color, false, "prompt-bg"); - back.screenCenter(XY); - add(back); - members.unshift(members.pop());// bring to front - } - - - public function createBgFromMargin(margin = MARGIN, color = 0xFF808080) - { - createBg(Std.int(FlxG.width - margin * 2), Std.int(FlxG.height - margin * 2), color); - } - - public function setButtons(style:ButtonStyle) - { - if (this.style != style) - { - this.style = style; - createButtons(); - } - } - - function createButtons() - { - // destroy previous buttons - while(buttons.members.length > 0) - { - buttons.remove(buttons.members[0], true).destroy(); - } - - switch(style) - { - case Yes_No : createButtonsHelper("yes", "no"); - case Ok : createButtonsHelper("ok"); - case Custom(yes, no): createButtonsHelper(yes, no); - case None : buttons.exists = false; - }; - } - - function createButtonsHelper(yes:String, ?no:String) - { - buttons.exists = true; - // pass anonymous functions rather than the current callbacks, in case they change later - var yesButton = buttons.createItem(yes, function() onYes()); - yesButton.screenCenter(X); - yesButton.y = FlxG.height - yesButton.height - MARGIN; - yesButton.scrollFactor.set(0, 0); - if (no != null) - { - // place right - yesButton.x = FlxG.width - yesButton.width - MARGIN; - - var noButton = buttons.createItem(no, function() onNo()); - noButton.x = MARGIN; - noButton.y = FlxG.height - noButton.height - MARGIN; - noButton.scrollFactor.set(0, 0); - } - } - - public function setText(text:String) - { - field.text = text; - field.screenCenter(X); - } -} - -enum ButtonStyle -{ - Ok; - Yes_No; - Custom(yes:String, no:Null);//Todo: more than 2 - None; -} \ No newline at end of file diff --git a/source/funkin/states/debug/TestPlayState.hx b/source/funkin/states/debug/TestPlayState.hx index 6b033aa..fb13c75 100644 --- a/source/funkin/states/debug/TestPlayState.hx +++ b/source/funkin/states/debug/TestPlayState.hx @@ -1,6 +1,6 @@ package funkin.states.debug; -import funkin.objects.Song.SwagSong; +import funkin.game.song.Song.SwagSong; class TestPlayState extends MusicBeatState { public var strumLines:FlxTypedGroup; diff --git a/source/import.hx b/source/import.hx index 47ed4d1..0e02086 100644 --- a/source/import.hx +++ b/source/import.hx @@ -7,11 +7,13 @@ import utils.DiscordRPC; import utils.FunkinUtil; import utils.Highscore; -import funkin.states.PlayState; +import funkin.game.PlayState; import funkin.states.LoadingState; import funkin.states.*; import funkin.objects.*; import funkin.objects.ui.*; +import funkin.game.objects.*; +import funkin.game.song.*; import shaders.*; diff --git a/source/utils/NoteSkinUtil.hx b/source/utils/NoteSkinUtil.hx deleted file mode 100644 index 6449712..0000000 --- a/source/utils/NoteSkinUtil.hx +++ /dev/null @@ -1,39 +0,0 @@ -package utils; - -import funkin.objects.notes.NoteBasic; - -@:structInit class NoteSkinParams { - public var jsonPath:String; - public var name:String; - public var path:String; - public var extraPaths:Array; - public var atlasIncluded:Bool; - public var extraData:Array; - public var antialiasing:Bool; -} - -class NoteSkinUtil { - function setSkin(noteSkin:NoteSkin, isSustain:Bool, params:NoteSkinParams) { - noteSkin.jsonPath = params.jsonPath; - noteSkin.name = params.name; - noteSkin.path = params.path; - noteSkin.extraPaths = params.extraPaths; - noteSkin.atlasIncluded = params.atlasIncluded; - noteSkin.extraData = params.extraData; - noteSkin.antialiasing = params.antialiasing; - noteSkin.parse(); - } -} - -class NoteSkin { - public var jsonPath:String = ''; - public var name:String = 'Default'; - public var path:String = 'NOTE_assets'; - public var extraPaths:Array = ['']; - public var atlasIncluded:Bool = false; // if true it'll load like the pixel notes - public var extraData:Array = []; // used for non-atlas skins (if it has atlas then its just extra) - public var antialiasing:Bool = true; - public function parse(?skinFile:String) { - trace('parse noteskin file (should be json)'); - } -} \ No newline at end of file