From 8f25fb29efc92c7a0dce6000998c0300ee779cb1 Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Mon, 29 Mar 2021 18:00:30 -0700 Subject: [PATCH 1/3] potential adobe animate texture atlas bullshit WIP --- source/TitleState.hx | 3 ++ source/animate/Animation.hx | 11 ++++++ source/animate/AnimationAtlas.hx | 67 ++++++++++++++++++++++++++++++++ 3 files changed, 81 insertions(+) create mode 100644 source/animate/Animation.hx create mode 100644 source/animate/AnimationAtlas.hx diff --git a/source/TitleState.hx b/source/TitleState.hx index 2f9c3a7f1..496de123d 100644 --- a/source/TitleState.hx +++ b/source/TitleState.hx @@ -1,5 +1,6 @@ package; +import animate.AnimationAtlas; import flixel.FlxG; import flixel.FlxSprite; import flixel.addons.transition.FlxTransitionSprite.GraphicTransTileDiamond; @@ -50,6 +51,8 @@ class TitleState extends MusicBeatState polymod.Polymod.init({modRoot: "mods", dirs: ['introMod'], framework: OPENFL}); #end + AnimationAtlas.fromAnimate(Paths.image('money'), Paths.file('images/money.json')); + swagShader = new ColorSwap(); FlxG.sound.muteKeys = [ZERO]; diff --git a/source/animate/Animation.hx b/source/animate/Animation.hx new file mode 100644 index 000000000..eec2c6c60 --- /dev/null +++ b/source/animate/Animation.hx @@ -0,0 +1,11 @@ +package animate; + +import flixel.group.FlxGroup; + +class Aniamtion extends FlxGroup +{ + public function new(symbolName:String, atlas:AnimationAtlas):Void + { + super(); + } +} diff --git a/source/animate/AnimationAtlas.hx b/source/animate/AnimationAtlas.hx new file mode 100644 index 000000000..264253637 --- /dev/null +++ b/source/animate/AnimationAtlas.hx @@ -0,0 +1,67 @@ +package animate; + +import flixel.FlxG; +import flixel.graphics.FlxGraphic; +import flixel.graphics.frames.FlxAtlasFrames; +import flixel.system.FlxAssets.FlxGraphicAsset; +import haxe.Json; +import openfl.Assets; + +class AnimationAtlas +{ + public function new(data:Dynamic, atlas:FlxAtlasFrames):Void {} + + 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); + + trace(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; + + trace(swagSprite); + } + + 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; +} From b388ea90641a49d3ad727183329eca3fd2e9b157 Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Mon, 29 Mar 2021 18:06:35 -0700 Subject: [PATCH 2/3] spritemap atlas bullshit? --- source/animate/AnimationAtlas.hx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/source/animate/AnimationAtlas.hx b/source/animate/AnimationAtlas.hx index 264253637..cd87c39d0 100644 --- a/source/animate/AnimationAtlas.hx +++ b/source/animate/AnimationAtlas.hx @@ -1,11 +1,15 @@ package animate; import flixel.FlxG; +import flixel.addons.ui.FlxUIColorSwatchSelecter.SwatchGraphic; 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.geom.Rectangle; class AnimationAtlas { @@ -44,7 +48,14 @@ class AnimationAtlas // probably nicer way to do this? Oh well var swagSprite:AnimateSprite = sprite.SPRITE; - trace(swagSprite); + 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; From d63e132d714b65fd51fb372bd4fdc842bc2cb6fb Mon Sep 17 00:00:00 2001 From: MtH Date: Mon, 29 Mar 2021 17:18:25 +0200 Subject: [PATCH 3/3] week score lerp fix INSPIRED BY PR #447 BY @jvc2 https://github.com/ninjamuffin99/Funkin/pull/447 --- source/StoryMenuState.hx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/StoryMenuState.hx b/source/StoryMenuState.hx index 3c9d629ec..23bbee0bb 100644 --- a/source/StoryMenuState.hx +++ b/source/StoryMenuState.hx @@ -227,6 +227,9 @@ class StoryMenuState extends MusicBeatState // scoreText.setFormat('VCR OSD Mono', 32); lerpScore = Math.floor(FlxMath.lerp(lerpScore, intendedScore, 0.5)); + if (Math.abs(lerpScore - intendedScore) <= 10) + lerpScore = intendedScore; + scoreText.text = "WEEK SCORE:" + lerpScore; txtWeekTitle.text = weekNames[curWeek].toUpperCase();