Skip to content

Commit e4baf51

Browse files
authored
Fix Inconsistency in Sustain Input (#663)
Make player sustains the same as cpu sustains
1 parent 1ca98b3 commit e4baf51

File tree

2 files changed

+16
-21
lines changed

2 files changed

+16
-21
lines changed

source/funkin/game/Note.hx

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -278,30 +278,22 @@ class Note extends FlxSprite
278278
public function updateSustain(strum:Strum) {
279279
var scrollSpeed = strum.getScrollSpeed(this);
280280

281-
var len = 0.45 * CoolUtil.quantize(scrollSpeed, 100);
282-
283-
if (nextSustain != null && lastScrollSpeed != scrollSpeed) {
284-
// is long sustain
281+
if (lastScrollSpeed != scrollSpeed) {
285282
lastScrollSpeed = scrollSpeed;
286-
287-
scale.y = (sustainLength * len) / frameHeight;
288-
updateHitbox();
289-
scale.y += gapFix / frameHeight;
283+
if (nextSustain != null) {
284+
scale.y = (sustainLength * 0.45 * scrollSpeed) / frameHeight;
285+
updateHitbox();
286+
scale.y += gapFix / frameHeight;
287+
}
290288
}
291289

292-
if (!wasGoodHit) return;
293-
var t = FlxMath.bound((Conductor.songPosition - strumTime) / (height) * len, 0, 1);
294-
var swagRect = this.clipRect == null ? new FlxRect() : this.clipRect;
295-
swagRect.x = 0;
296-
swagRect.y = t * frameHeight;
297-
swagRect.width = frameWidth;
298-
swagRect.height = frameHeight;
299-
300-
setClipRect(swagRect);
290+
updateSustainClip();
301291
}
302292

303-
public inline function setClipRect(rect:FlxRect) {
304-
this.clipRect = rect;
293+
public function updateSustainClip() if (wasGoodHit) {
294+
var t = FlxMath.bound((Conductor.songPosition - strumTime) / height * 0.45 * lastScrollSpeed, 0, 1);
295+
var rect = clipRect == null ? FlxRect.get() : clipRect;
296+
clipRect = rect.set(0, frameHeight * t, frameWidth, frameHeight * (1 - t));
305297
}
306298

307299
@:noCompletion
@@ -317,5 +309,7 @@ class Note extends FlxSprite
317309

318310
public override function destroy() {
319311
super.destroy();
312+
313+
clipRect = FlxDestroyUtil.put(clipRect);
320314
}
321315
}

source/funkin/game/StrumLine.hx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ class StrumLine extends FlxTypedGroup<Strum> {
189189

190190
if (cpu && __updateNote_event.__autoCPUHit && !daNote.avoid && !daNote.wasGoodHit && daNote.strumTime < __updateNote_songPos) PlayState.instance.goodNoteHit(this, daNote);
191191

192-
if (daNote.wasGoodHit && daNote.isSustainNote && daNote.strumTime + (daNote.sustainLength) < __updateNote_songPos) {
192+
if (daNote.wasGoodHit && daNote.isSustainNote && daNote.strumTime + daNote.sustainLength < __updateNote_songPos) {
193193
deleteNote(daNote);
194194
return;
195195
}
@@ -215,8 +215,9 @@ class StrumLine extends FlxTypedGroup<Strum> {
215215
var __notePerStrum:Array<Note> = [];
216216

217217
function __inputProcessPressed(note:Note) {
218-
if (__pressed[note.strumID] && note.isSustainNote && note.canBeHit && !note.wasGoodHit) {
218+
if (__pressed[note.strumID] && note.isSustainNote && note.strumTime < __updateNote_songPos && !note.wasGoodHit) {
219219
PlayState.instance.goodNoteHit(this, note);
220+
note.updateSustainClip();
220221
}
221222
}
222223
function __inputProcessJustPressed(note:Note) {

0 commit comments

Comments
 (0)