From 9c07bb26b725c95d03af899e3e8c7a84695b08b8 Mon Sep 17 00:00:00 2001 From: Yoshman29 Date: Sun, 30 Oct 2022 19:53:04 +0100 Subject: [PATCH] fuck --- buildnumber.txt | 2 +- source/funkin/game/HudCamera.hx | 50 +++++++++++++++++++++++++++++++++ source/funkin/game/Note.hx | 4 +++ source/funkin/game/PlayState.hx | 12 +++++--- source/funkin/game/Strum.hx | 16 +++++++---- 5 files changed, 73 insertions(+), 11 deletions(-) create mode 100644 source/funkin/game/HudCamera.hx diff --git a/buildnumber.txt b/buildnumber.txt index 035d0f0c..147d4e7f 100644 --- a/buildnumber.txt +++ b/buildnumber.txt @@ -1 +1 @@ -822 \ No newline at end of file +845 \ No newline at end of file diff --git a/source/funkin/game/HudCamera.hx b/source/funkin/game/HudCamera.hx new file mode 100644 index 00000000..9fb4dcc3 --- /dev/null +++ b/source/funkin/game/HudCamera.hx @@ -0,0 +1,50 @@ +package funkin.game; + +import flixel.FlxCamera; + +import lime.app.Application; +import flixel.graphics.tile.FlxGraphicsShader; +import flash.display.Bitmap; +import flash.display.BitmapData; +import flash.display.DisplayObject; +import flash.display.Graphics; +import flash.display.Sprite; +import flash.geom.ColorTransform; +import flash.geom.Point; +import flash.geom.Rectangle; +import flixel.graphics.FlxGraphic; +import flixel.graphics.frames.FlxFrame; +import flixel.graphics.tile.FlxDrawBaseItem; +import flixel.graphics.tile.FlxDrawTrianglesItem; +import flixel.math.FlxMath; +import flixel.math.FlxMatrix; +import flixel.math.FlxPoint; +import flixel.math.FlxRect; +import flixel.system.FlxAssets.FlxShader; +import flixel.util.FlxAxes; +import flixel.util.FlxColor; +import flixel.util.FlxDestroyUtil; +import flixel.util.FlxSpriteUtil; +import openfl.display.BlendMode; +import openfl.filters.BitmapFilter; +import openfl.filters.ShaderFilter; +import openfl.Vector; + +class HudCamera extends FlxCamera { + public var downscroll:Bool = false; + public override function update(elapsed:Float) { + super.update(elapsed); + flipY = downscroll; + } + + + public override function drawPixels(?frame:FlxFrame, ?pixels:BitmapData, matrix:FlxMatrix, ?transform:ColorTransform, ?blend:BlendMode, ?smoothing:Bool = false, + ?shader:FlxShader):Void + { + if (downscroll) { + matrix.scale(1, -1); + matrix.translate(0, height); + } + super.drawPixels(frame, pixels, matrix, transform, blend, smoothing, shader); + } +} \ No newline at end of file diff --git a/source/funkin/game/Note.hx b/source/funkin/game/Note.hx index db5a5207..8b3e2210 100644 --- a/source/funkin/game/Note.hx +++ b/source/funkin/game/Note.hx @@ -37,6 +37,10 @@ class Note extends FlxSprite public var noteTypeID:Int = 0; + // TO APPLY THOSE ON A SINGLE NOTE + public var scrollSpeed:Null = null; + public var noteAngle:Null = null; + public var noteType(get, null):String; private function get_noteType() { return PlayState.instance.getNoteType(noteTypeID); diff --git a/source/funkin/game/PlayState.hx b/source/funkin/game/PlayState.hx index bf5f63de..75ebd195 100644 --- a/source/funkin/game/PlayState.hx +++ b/source/funkin/game/PlayState.hx @@ -75,6 +75,10 @@ class PlayState extends MusicBeatState public var stage:Stage; public var scrollSpeed:Float = 0; + public var downscroll(get, set):Bool; + + @:dox(hide) private function set_downscroll(v:Bool) {return camHUD.downscroll = v;} + @:dox(hide) private function get_downscroll():Bool {return camHUD.downscroll;} public var vocals:FlxSound; @@ -115,12 +119,11 @@ class PlayState extends MusicBeatState public var iconP1:HealthIcon; public var iconP2:HealthIcon; - public var camHUD:FlxCamera; + public var camHUD:HudCamera; public var camGame:FlxCamera; public var songScore:Int = 0; - public var downscroll:Bool = Options.downscroll; public var misses:Int = 0; public var scoreTxt:FlxText; public var missesTxt:FlxText; @@ -154,11 +157,12 @@ class PlayState extends MusicBeatState scripts.setParent(this); camGame = camera; - camHUD = new FlxCamera(); + camHUD = new HudCamera(); camHUD.bgColor.alpha = 0; FlxG.cameras.add(camHUD, false); + downscroll = Options.downscroll; // camGame.widescreen = true; persistentUpdate = true; @@ -988,7 +992,7 @@ class PlayState extends MusicBeatState if (event.strum == null) return; if (event.__reposNote) event.strum.updateNotePosition(daNote); - event.strum.updateClipRect(daNote); + event.strum.updateSustain(daNote); PlayState.instance.scripts.event("onNoteUpdatePost", event); } diff --git a/source/funkin/game/Strum.hx b/source/funkin/game/Strum.hx index a92a6603..ccbe58bd 100644 --- a/source/funkin/game/Strum.hx +++ b/source/funkin/game/Strum.hx @@ -14,13 +14,15 @@ class Strum extends FlxSprite { public var noteAngle:Null = null; // custom scroll speed per strum public var downscroll:Null = false; // custom downscroll per strum - public function getScrollSpeed() { + public function getScrollSpeed(?note:Note) { + if (note != null && note.scrollSpeed != null) return note.scrollSpeed; if (scrollSpeed != null) return scrollSpeed; if (PlayState.instance != null) return PlayState.instance.scrollSpeed; return 1; } - public function getNotesAngle() { + public function getNotesAngle(?note:Note) { + if (note != null && note.noteAngle != null) return note.noteAngle; if (noteAngle != null) return noteAngle; return angle; } @@ -44,11 +46,11 @@ class Strum extends FlxSprite { public function updateNotePosition(daNote:Note) { if (!daNote.exists) return; - var offset = FlxPoint.get(daNote.isSustainNote ? ((Note.swagWidth - daNote.width) / 2) : 0, (Conductor.songPosition - daNote.strumTime) * (0.45 * FlxMath.roundDecimal(getScrollSpeed(), 2))); + var offset = FlxPoint.get(daNote.isSustainNote ? ((Note.swagWidth - daNote.width) / 2) : 0, (Conductor.songPosition - daNote.strumTime) * (0.45 * FlxMath.roundDecimal(getScrollSpeed(daNote), 2))); var realOffset = FlxPoint.get(0, 0); if (daNote.isSustainNote) offset.y -= Note.swagWidth / 2; - var noteAngle = getNotesAngle(); + var noteAngle = getNotesAngle(daNote); daNote.angle = daNote.isSustainNote ? noteAngle : angle; if (Std.int(noteAngle % 360) != 0) { var noteAngleCos = Math.cos(noteAngle / 180 * Math.PI); @@ -67,8 +69,10 @@ class Strum extends FlxSprite { realOffset.put(); } - public function updateClipRect(daNote:Note) { - if (!daNote.isSustainNote || !daNote.wasGoodHit) return; + public function updateSustain(daNote:Note) { + if (!daNote.isSustainNote) return; + daNote.flipY = PlayState.instance.downscroll != (getScrollSpeed(daNote) < 0); + if (!daNote.wasGoodHit) return; daNote.updateClipRect(this); }