From be4b35938baa564c7995228849a4298fff3959fb Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Wed, 26 May 2021 19:22:15 -0400 Subject: [PATCH] debug anim shit in progress --- source/CoolUtil.hx | 24 +++++++- source/DebugBoundingState.hx | 19 +++++- source/TitleState.hx | 2 + source/ui/stageBuildShit/StageBuilderState.hx | 58 ++++++++++++++----- 4 files changed, 83 insertions(+), 20 deletions(-) diff --git a/source/CoolUtil.hx b/source/CoolUtil.hx index 4bbcd6bd3..648724d8e 100644 --- a/source/CoolUtil.hx +++ b/source/CoolUtil.hx @@ -44,6 +44,24 @@ class CoolUtil return dumbArray; } + static var oldCamPos:FlxPoint = new FlxPoint(); + static var oldMousePos:FlxPoint = new FlxPoint(); + + public static function mouseCamDrag():Void + { + if (FlxG.mouse.justPressedMiddle) + { + oldCamPos.set(FlxG.camera.scroll.x, FlxG.camera.scroll.y); + oldMousePos.set(FlxG.mouse.screenX, FlxG.mouse.screenY); + } + + if (FlxG.mouse.pressedMiddle) + { + FlxG.camera.scroll.x = oldCamPos.x - (FlxG.mouse.screenX - oldMousePos.x); + FlxG.camera.scroll.y = oldCamPos.y - (FlxG.mouse.screenY - oldMousePos.y); + } + } + /** Lerps camera, but accountsfor framerate shit? Right now it's simply for use to change the followLerp variable of a camera during update @@ -57,10 +75,10 @@ class CoolUtil } /* - * frame dependant lerp kinda lol - */ + * frame dependant lerp kinda lol + */ public static function coolLerp(base:Float, target:Float, ratio:Float):Float { return base + camLerpShit(ratio) * (target - base); } -} \ No newline at end of file +} diff --git a/source/DebugBoundingState.hx b/source/DebugBoundingState.hx index 44b54f6b7..ef89d3300 100644 --- a/source/DebugBoundingState.hx +++ b/source/DebugBoundingState.hx @@ -3,6 +3,8 @@ package; import flixel.FlxG; import flixel.FlxSprite; import flixel.FlxState; +import flixel.addons.display.FlxGridOverlay; +import flixel.graphics.frames.FlxAtlasFrames; import openfl.Assets; import sys.io.File; @@ -10,7 +12,16 @@ class DebugBoundingState extends FlxState { override function create() { - var bf:FlxSprite = new FlxSprite().loadGraphic(Paths.image('characters/temp')); + var bg:FlxSprite = FlxGridOverlay.create(10, 10); + + bg.scrollFactor.set(); + add(bg); + + var tex = Paths.getSparrowAtlas('characters/temp'); + // tex.frames[0].uv + + var bf:FlxSprite = new FlxSprite(); + bf.loadGraphic(tex.parent); add(bf); FlxG.stage.window.onDropFile.add(function(path:String) @@ -32,4 +43,10 @@ class DebugBoundingState extends FlxState super.create(); } + + override function update(elapsed:Float) + { + CoolUtil.mouseCamDrag(); + super.update(elapsed); + } } diff --git a/source/TitleState.hx b/source/TitleState.hx index 660580b33..392dd86f1 100644 --- a/source/TitleState.hx +++ b/source/TitleState.hx @@ -158,6 +158,8 @@ class TitleState extends MusicBeatState // netConnection.addEventListener(MouseEvent.MOUSE_DOWN, overlay_onMouseDown); #elseif STAGEBUILD FlxG.switchState(new StageBuilderState()); + #elseif ANIMDEBUG + FlxG.switchState(new DebugBoundingState()); #else new FlxTimer().start(1, function(tmr:FlxTimer) { diff --git a/source/ui/stageBuildShit/StageBuilderState.hx b/source/ui/stageBuildShit/StageBuilderState.hx index 8875bc7a9..d0c00edf7 100644 --- a/source/ui/stageBuildShit/StageBuilderState.hx +++ b/source/ui/stageBuildShit/StageBuilderState.hx @@ -5,10 +5,8 @@ import flixel.FlxSprite; import flixel.addons.display.FlxGridOverlay; import flixel.group.FlxGroup; import flixel.math.FlxPoint; -import flixel.system.FlxSound; import flixel.ui.FlxButton; import flixel.util.FlxTimer; -import openfl.Assets; class StageBuilderState extends MusicBeatState { @@ -16,13 +14,51 @@ class StageBuilderState extends MusicBeatState private var sprGrp:FlxGroup; + // var snd:Sound; + // var sndChannel:SoundChannel; + override function create() { super.create(); FlxG.mouse.visible = true; - // var snd:Sound = new Sound(); + // var alsoSnd:FlxSound = new FlxSound(); + + // snd = new Sound(); + + // var swagBytes:ByteArray = new ByteArray(8192); + + // for (shit in 0...8192) + // { + // swagBytes.writeFloat(Math.sin((shit) / Math.PI) * 0.25); + // swagBytes.writeFloat(Math.sin((shit) / Math.PI) * 0.25); + // trace('wweseosme???'); + // } + + // snd.__buffer = AudioBuffer.fromBytes(swagBytes); + // snd.dispatchEvent(new Event(Event.COMPLETE)); + + // swagBytes.writeFloat(Math.sin((shit + event.position) / Math.PI) * 0.25); + // swagBytes.writeFloat(Math.sin((shit + event.position) / Math.PI) * 0.25); + + // function sineShit(event:SampleDataEvent):Void + // { + // for (shit in 0...8192) + // { + // event.data.writeFloat(Math.sin((shit + event.position) / Math.PI) * 0.25); + // event.data.writeFloat(Math.sin((shit + event.position) / Math.PI) * 0.25); + // trace('wweseosme???'); + // } + // } + + // snd.addEventListener(SampleDataEvent.SAMPLE_DATA, sineShit); + // snd.__buffer. + // snd = Assets.getSound(Paths.music('freakyMenu')); + // for (thing in snd.load) + // thing = Std.int(thing / 2); + // snd.play(); + // trace(snd.__buffer.data.toBytes().getData().bytes); var bg:FlxSprite = FlxGridOverlay.create(10, 10); add(bg); @@ -97,22 +133,12 @@ class StageBuilderState extends MusicBeatState // trace(); } - var oldCamPos:FlxPoint = new FlxPoint(); - var oldMousePos:FlxPoint = new FlxPoint(); - override function update(elapsed:Float) { - if (FlxG.mouse.justPressedMiddle) - { - oldCamPos.set(FlxG.camera.scroll.x, FlxG.camera.scroll.y); - oldMousePos.set(FlxG.mouse.screenX, FlxG.mouse.screenY); - } + // trace(sndChannel.position); + // trace(snd - if (FlxG.mouse.pressedMiddle) - { - FlxG.camera.scroll.x = oldCamPos.x - (FlxG.mouse.screenX - oldMousePos.x); - FlxG.camera.scroll.y = oldCamPos.y - (FlxG.mouse.screenY - oldMousePos.y); - } + CoolUtil.mouseCamDrag(); super.update(elapsed); }