calculate note y is in GRhythmUtil now
This commit is contained in:
@@ -2665,7 +2665,6 @@ class PlayState extends MusicBeatSubState
|
||||
|
||||
// Generate a list of notes within range.
|
||||
var notesInRange:Array<NoteSprite> = playerStrumline.getNotesMayHit();
|
||||
var holdNotesInRange:Array<SustainTrail> = playerStrumline.getHoldNotesHitOrMissed();
|
||||
|
||||
var notesByDirection:Array<Array<NoteSprite>> = [[], [], [], []];
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<ScoringRank>, b:Null<ScoringRank>):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<ScoringRank>, b:Null<ScoringRank>):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<ScoringRank>, b:Null<ScoringRank>):Bool
|
||||
{
|
||||
if (a != null && b == null) return true;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user