From 0ef1df33c9aab1bc26d3b91c83d4b8be1e137344 Mon Sep 17 00:00:00 2001 From: kade-github <26305836+Kade-github@users.noreply.github.com> Date: Wed, 18 Jun 2025 13:46:38 -0700 Subject: [PATCH] calculate note y is in GRhythmUtil now --- source/funkin/play/PlayState.hx | 1 - source/funkin/play/notes/Strumline.hx | 34 ++++++++++++++------------- source/funkin/play/scoring/Scoring.hx | 3 +++ source/funkin/util/GRhythmUtil.hx | 31 ++++++++++-------------- 4 files changed, 34 insertions(+), 35 deletions(-) diff --git a/source/funkin/play/PlayState.hx b/source/funkin/play/PlayState.hx index 04f13816b..0bad2e2bd 100644 --- a/source/funkin/play/PlayState.hx +++ b/source/funkin/play/PlayState.hx @@ -2665,7 +2665,6 @@ class PlayState extends MusicBeatSubState // Generate a list of notes within range. var notesInRange:Array = playerStrumline.getNotesMayHit(); - var holdNotesInRange:Array = playerStrumline.getHoldNotesHitOrMissed(); var notesByDirection:Array> = [[], [], [], []]; diff --git a/source/funkin/play/notes/Strumline.hx b/source/funkin/play/notes/Strumline.hx index d49ebdd87..4f0b2ffc6 100644 --- a/source/funkin/play/notes/Strumline.hx +++ b/source/funkin/play/notes/Strumline.hx @@ -16,6 +16,7 @@ import funkin.play.notes.SustainTrail; import funkin.play.notes.NoteVibrationsHandler; import funkin.data.song.SongData.SongNoteData; import funkin.util.SortUtil; +import funkin.util.GRhythmUtil; import funkin.play.notes.notekind.NoteKindManager; import flixel.math.FlxPoint; #if mobile @@ -526,17 +527,6 @@ class Strumline extends FlxSpriteGroup } } - /** - * For a note's strumTime, calculate its Y position relative to the strumline. - * NOTE: Assumes Conductor and PlayState are both initialized. - * @param strumTime The strumtime of the note. - * @return The Y position of the note. - */ - public function calculateNoteYPos(strumTime:Float):Float - { - return Constants.PIXELS_PER_MS * (conductorInUse.getTimeWithDelta() - strumTime - Conductor.instance.inputOffset) * scrollSpeed * (isDownscroll ? 1 : -1); - } - public function updateNotes():Void { if (noteData.length == 0) return; @@ -581,7 +571,10 @@ class Strumline extends FlxSpriteGroup if (note == null || !note.alive) continue; // Set the note's position. - if (!customPositionData) note.y = this.y - INITIAL_OFFSET + calculateNoteYPos(note.strumTime) + note.yOffset; + if (!customPositionData) note.y = this.y + - INITIAL_OFFSET + + GRhythmUtil.getNoteY(note.strumTime, scrollSpeed, isDownscroll, conductorInUse) + + note.yOffset; // If the note is miss var isOffscreen:Bool = isDownscroll ? note.y > FlxG.height : note.y < -note.height; @@ -664,14 +657,19 @@ class Strumline extends FlxSpriteGroup { holdNote.y = this.y - INITIAL_OFFSET - + calculateNoteYPos(holdNote.strumTime) + + GRhythmUtil.getNoteY(holdNote.strumTime, scrollSpeed, isDownscroll, conductorInUse) - holdNote.height + STRUMLINE_SIZE / 2 + holdNote.yOffset; } else { - holdNote.y = this.y - INITIAL_OFFSET + calculateNoteYPos(holdNote.strumTime) + yOffset + STRUMLINE_SIZE / 2 + holdNote.yOffset; + holdNote.y = this.y + - INITIAL_OFFSET + + GRhythmUtil.getNoteY(holdNote.strumTime, scrollSpeed, isDownscroll, conductorInUse) + + yOffset + + STRUMLINE_SIZE / 2 + + holdNote.yOffset; } } @@ -718,14 +716,18 @@ class Strumline extends FlxSpriteGroup { holdNote.y = this.y - INITIAL_OFFSET - + calculateNoteYPos(holdNote.strumTime) + + GRhythmUtil.getNoteY(holdNote.strumTime, scrollSpeed, isDownscroll, conductorInUse) - holdNote.height + STRUMLINE_SIZE / 2 + holdNote.yOffset; } else { - holdNote.y = this.y - INITIAL_OFFSET + calculateNoteYPos(holdNote.strumTime) + STRUMLINE_SIZE / 2 + holdNote.yOffset; + holdNote.y = this.y + - INITIAL_OFFSET + + GRhythmUtil.getNoteY(holdNote.strumTime, scrollSpeed, isDownscroll, conductorInUse) + + STRUMLINE_SIZE / 2 + + holdNote.yOffset; } } } diff --git a/source/funkin/play/scoring/Scoring.hx b/source/funkin/play/scoring/Scoring.hx index f0c4ebd4a..e2dab3b2f 100644 --- a/source/funkin/play/scoring/Scoring.hx +++ b/source/funkin/play/scoring/Scoring.hx @@ -456,6 +456,7 @@ enum abstract ScoringRank(String) return temp1 > temp2; } + // Greater than or equal to comparison @:op(A >= B) static function compareGTEQ(a:Null, b:Null):Bool { if (a != null && b == null) return true; @@ -467,6 +468,7 @@ enum abstract ScoringRank(String) return temp1 >= temp2; } + // Less than comparison @:op(A < B) static function compareLT(a:Null, b:Null):Bool { if (a != null && b == null) return true; @@ -478,6 +480,7 @@ enum abstract ScoringRank(String) return temp1 < temp2; } + // Less than or equal to comparison @:op(A <= B) static function compareLTEQ(a:Null, b:Null):Bool { if (a != null && b == null) return true; diff --git a/source/funkin/util/GRhythmUtil.hx b/source/funkin/util/GRhythmUtil.hx index 5c039ee1f..f5334c9c7 100644 --- a/source/funkin/util/GRhythmUtil.hx +++ b/source/funkin/util/GRhythmUtil.hx @@ -3,24 +3,6 @@ package funkin.util; import funkin.play.notes.NoteSprite; import funkin.Conductor; -/** - * A structure to hold the result of a hit window check. - * @param inWindow True if the note is within the hit window. - * @param hit True if the note was hit. - * @param time The time of the hit. - * @param note The note that was hit. - * @param isControlled True if the note is controlled by the player. - */ -typedef GHitRes = -{ - public var inWindow:Bool; - - public var hit:Bool; - public var time:Float; - public var note:NoteSprite; - public var isControlled:Bool; -} - /** * A structure to hold the hit window values. * @param start The start time of the hit window. @@ -118,4 +100,17 @@ class GRhythmUtil return {botplayHit: false, cont: true }; } + /** + * Get the y-position of a note based on its strum time. + * @param strumTime The strum time of the note. + * @param scrollSpeed The scroll speed of the strumline. + * @param downscroll Whether the strumline is in downscroll mode. + * @param conductorInUse The conductor to use for calculating the y-position. + * @return The y-position of the note. + */ + public static function getNoteY(strumTime:Float, scrollSpeed:Float, downscroll:Bool = false, ?conductorInUse:Conductor = null):Float + { + if (conductorInUse == null) conductorInUse = Conductor.instance; + return Constants.PIXELS_PER_MS * (conductorInUse.getTimeWithDelta() - strumTime - conductorInUse.inputOffset) * scrollSpeed * (downscroll ? 1 : -1); + } }