Skip to content

Commit de75ffa

Browse files
committed
Merge branch 'fix-hit-window-fps-offset' of https://github.com/JackXson-Real/Funkin into fix-hit-window-fps-offset
2 parents 7c6efba + 99beeb5 commit de75ffa

File tree

1 file changed

+42
-11
lines changed

1 file changed

+42
-11
lines changed

source/funkin/play/notes/Strumline.hx

Lines changed: 42 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,27 @@ class Strumline extends FlxSpriteGroup
4747

4848
// Positional fixes for new strumline graphics.
4949
static final INITIAL_OFFSET:Float = -0.275 * STRUMLINE_SIZE;
50+
51+
/**
52+
* Returns a dynamic offset for the strumline center based on FPS.
53+
* The lower the FPS, the higher the hit window is offset.
54+
*/
55+
function getDynamicOffset():Float {
56+
var baseOffset:Float;
57+
if (noteStyle != null && noteStyle.id != null && noteStyle.id.toLowerCase() == 'pixel')
58+
{
59+
baseOffset = INITIAL_OFFSET + 5.0;
60+
}
61+
else
62+
{
63+
baseOffset = INITIAL_OFFSET + 10.0;
64+
}
65+
var fps = Preferences.framerate;
66+
var maxOffset = (500 - 30) * 0.025;
67+
var t = (500 - fps) / (500 - 30);
68+
return baseOffset + maxOffset * t;
69+
}
70+
5071
static final NUDGE:Float = 2.0;
5172

5273
static final KEY_COUNT:Int = 4;
@@ -97,9 +118,9 @@ class Strumline extends FlxSpriteGroup
97118
/**
98119
* Reset the scroll speed to the current chart's scroll speed.
99120
*/
100-
public function resetScrollSpeed(?newScrollSpeed:Float):Void
121+
public function resetScrollSpeed():Void
101122
{
102-
scrollSpeed = newScrollSpeed ?? PlayState.instance?.currentChart?.scrollSpeed ?? 1.0;
123+
scrollSpeed = PlayState.instance?.currentChart?.scrollSpeed ?? 1.0;
103124
}
104125

105126
var _conductorInUse:Null<Conductor>;
@@ -184,7 +205,7 @@ class Strumline extends FlxSpriteGroup
184205

185206
static final BACKGROUND_PAD:Int = 16;
186207

187-
public function new(noteStyle:NoteStyle, isPlayer:Bool, ?scrollSpeed:Float)
208+
public function new(noteStyle:NoteStyle, isPlayer:Bool)
188209
{
189210
super();
190211

@@ -236,13 +257,14 @@ class Strumline extends FlxSpriteGroup
236257
if (inArrowContorlSchemeMode && isPlayer) this.background.x -= 100;
237258
#end
238259
this.add(this.background);
260+
strumlineScale = new FlxCallbackPoint(strumlineScaleCallback);
239261

240262
strumlineScale = new FlxCallbackPoint(strumlineScaleCallback);
241263

242264
this.refresh();
243265

244266
this.onNoteIncoming = new FlxTypedSignal<NoteSprite->Void>();
245-
resetScrollSpeed(scrollSpeed);
267+
resetScrollSpeed();
246268

247269
for (i in 0...KEY_COUNT)
248270
{
@@ -584,7 +606,7 @@ class Strumline extends FlxSpriteGroup
584606
if (note == null || !note.alive) continue;
585607
// Set the note's position.
586608
if (!customPositionData) note.y = this.y
587-
- INITIAL_OFFSET
609+
- getDynamicOffset()
588610
+ GRhythmUtil.getNoteY(note.strumTime, scrollSpeed, isDownscroll, conductorInUse)
589611
+ note.yOffset;
590612

@@ -643,6 +665,8 @@ class Strumline extends FlxSpriteGroup
643665
if (holdNote.cover != null && isPlayer)
644666
{
645667
holdNote.cover.playEnd();
668+
669+
trace("Sustain Note Splash Vibration");
646670
}
647671
else if (holdNote.cover != null)
648672
{
@@ -666,7 +690,7 @@ class Strumline extends FlxSpriteGroup
666690
if (isDownscroll)
667691
{
668692
holdNote.y = this.y
669-
- INITIAL_OFFSET
693+
- getDynamicOffset()
670694
+ GRhythmUtil.getNoteY(holdNote.strumTime, scrollSpeed, isDownscroll, conductorInUse)
671695
- holdNote.height
672696
+ STRUMLINE_SIZE / 2
@@ -675,7 +699,7 @@ class Strumline extends FlxSpriteGroup
675699
else
676700
{
677701
holdNote.y = this.y
678-
- INITIAL_OFFSET
702+
- getDynamicOffset()
679703
+ GRhythmUtil.getNoteY(holdNote.strumTime, scrollSpeed, isDownscroll, conductorInUse)
680704
+ yOffset
681705
+ STRUMLINE_SIZE / 2
@@ -707,11 +731,18 @@ class Strumline extends FlxSpriteGroup
707731
{
708732
if (isDownscroll)
709733
{
710-
holdNote.y = this.y - INITIAL_OFFSET - holdNote.height + STRUMLINE_SIZE / 2;
734+
holdNote.y = this.y
735+
- getDynamicOffset()
736+
- holdNote.height
737+
+ STRUMLINE_SIZE / 2
738+
+ holdNote.yOffset;
711739
}
712740
else
713741
{
714-
holdNote.y = this.y - INITIAL_OFFSET + STRUMLINE_SIZE / 2;
742+
holdNote.y = this.y
743+
- getDynamicOffset()
744+
+ STRUMLINE_SIZE / 2
745+
+ holdNote.yOffset;
715746
}
716747
}
717748
}
@@ -725,7 +756,7 @@ class Strumline extends FlxSpriteGroup
725756
if (isDownscroll)
726757
{
727758
holdNote.y = this.y
728-
- INITIAL_OFFSET
759+
- getDynamicOffset()
729760
+ GRhythmUtil.getNoteY(holdNote.strumTime, scrollSpeed, isDownscroll, conductorInUse)
730761
- holdNote.height
731762
+ STRUMLINE_SIZE / 2
@@ -734,7 +765,7 @@ class Strumline extends FlxSpriteGroup
734765
else
735766
{
736767
holdNote.y = this.y
737-
- INITIAL_OFFSET
768+
- getDynamicOffset()
738769
+ GRhythmUtil.getNoteY(holdNote.strumTime, scrollSpeed, isDownscroll, conductorInUse)
739770
+ STRUMLINE_SIZE / 2
740771
+ holdNote.yOffset;

0 commit comments

Comments
 (0)