From b94fed484b71c918a7f4cb2c5961a1103166d2f2 Mon Sep 17 00:00:00 2001 From: MaybeMaru <97055307+MaybeMaru@users.noreply.github.com> Date: Mon, 18 Dec 2023 02:19:45 +0100 Subject: [PATCH] quality of life shit to add swag stuff later --- source/funkin/graphics/FlxSpriteExt.hx | 20 +++++++++++-- source/funkin/graphics/SmartSprite.hx | 40 ++++++++++++++++++++++++++ source/funkin/objects/note/Note.hx | 10 +++++++ source/funkin/objects/note/Sustain.hx | 1 + 4 files changed, 69 insertions(+), 2 deletions(-) create mode 100644 source/funkin/graphics/SmartSprite.hx diff --git a/source/funkin/graphics/FlxSpriteExt.hx b/source/funkin/graphics/FlxSpriteExt.hx index 6ba4f53c..81e6ee57 100644 --- a/source/funkin/graphics/FlxSpriteExt.hx +++ b/source/funkin/graphics/FlxSpriteExt.hx @@ -102,11 +102,27 @@ class FlxSpriteExt extends FlxSkewedSprite { if (flippedOffsets) { flipX = !flipX; scale.x *= -1; - super.draw(); + __superDraw(); flipX = !flipX; scale.x *= -1; } - else super.draw(); + else __superDraw(); + } + + @:noCompletion + private inline function __superDraw() { + inline checkEmptyFrame(); + if (alpha == 0 || _frame.type == EMPTY) return; + if (dirty) calcFrame(useFramePixels); // rarely + + for (i in 0...cameras.length) { + final camera = cameras[i]; + if (!camera.visible || !camera.exists || !isOnScreen(camera)) continue; + drawComplex(camera); + #if FLX_DEBUG FlxBasic.visibleCount++; #end + } + + #if FLX_DEBUG if (FlxG.debugger.drawDebug) drawDebug(); #end } public override function getScreenBounds(?rect:FlxRect, ?cam:FlxCamera):FlxRect { diff --git a/source/funkin/graphics/SmartSprite.hx b/source/funkin/graphics/SmartSprite.hx new file mode 100644 index 00000000..11c8c74c --- /dev/null +++ b/source/funkin/graphics/SmartSprite.hx @@ -0,0 +1,40 @@ +package funkin.graphics; + +enum RenderMode { + QUAD; + REPEAT; +} + +class SmartSprite extends FlxRepeatSprite { + public var renderMode:RenderMode = QUAD; + + public function new(?X:Float, ?Y:Float, ?SimpleGraphic:FlxGraphicAsset) { + super(X, Y, SimpleGraphic, 0, 0); + } + + override function drawComplex(camera:FlxCamera) { + switch (renderMode) { + case REPEAT: super.drawComplex(camera); + case QUAD: + _frame.prepareMatrix(_matrix, 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); + } + + getScreenPosition(_point, camera).subtractPoint(offset); + _point.addPoint(origin); + _matrix.translate(_point.x, _point.y); + camera.drawPixels(_frame, framePixels, _matrix, colorTransform, blend, antialiasing, shader); + } + + } +} \ No newline at end of file diff --git a/source/funkin/objects/note/Note.hx b/source/funkin/objects/note/Note.hx index 3ff5ced4..399eaea3 100644 --- a/source/funkin/objects/note/Note.hx +++ b/source/funkin/objects/note/Note.hx @@ -8,6 +8,16 @@ interface INoteData { public var noteData:Int; } +interface INoteObject extends INoteData { + public var strumTime:Float; + public var noteSpeed:Float; + public var targetStrum:NoteStrum; + public var parentNote:Note; + public var childNote:Sustain; + + public var isSustainNote:Bool; +} + class Note extends FlxSpriteExt implements INoteData { public var noteData:Int = 0; public var strumTime:Float = 0; diff --git a/source/funkin/objects/note/Sustain.hx b/source/funkin/objects/note/Sustain.hx index 85d81063..a430533b 100644 --- a/source/funkin/objects/note/Sustain.hx +++ b/source/funkin/objects/note/Sustain.hx @@ -5,6 +5,7 @@ import funkin.graphics.FlxRepeatSprite; class Sustain extends FlxRepeatSprite implements INoteData { public var noteData:Int = 0; + public var noteSpeed:Float = 1.0; public function new(noteData:Int = 0) { super();