Skip to content

Commit

Permalink
refactor: use judgment threshold constant
Browse files Browse the repository at this point in the history
  • Loading branch information
Naptie committed Nov 26, 2024
1 parent 9d61411 commit 574bc16
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/player/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ export const HOLD_BODY_TOLERANCE = 100;
export const HOLD_TAIL_TOLERANCE = 100;

/*
Minimum distance (in chart pixels) between the projections of the input and a note along
the judgment line required to hit the note.
Maximum distance (in chart pixels) between the projections of the input and a note along
the judgment line allowed to hit the note.
*/
export const JUDGEMENT_THRESHOLD = 200;
export const JUDGMENT_THRESHOLD = 200;

/*
The radius (in percentage) of rounded corners of the illustration on the ending scene.
Expand Down
6 changes: 3 additions & 3 deletions src/player/handlers/PointerHandler.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { dot } from 'mathjs';
import type { Input } from 'phaser';
import { FLICK_VELOCTY_THRESHOLD } from '../constants';
import { FLICK_VELOCTY_THRESHOLD, JUDGMENT_THRESHOLD } from '../constants';
import type { Line } from '../objects/Line';
import type { LongNote } from '../objects/LongNote';
import type { PlainNote } from '../objects/PlainNote';
Expand Down Expand Up @@ -141,7 +141,7 @@ export class PointerHandler {
((input.time - getTimeSec(this._scene.bpmList, note.note.startBeat)) * 100) ** 2;
});
const tap = taps
.filter((input) => input.distance < this._scene.p(200))
.filter((input) => input.distance <= this._scene.p(JUDGMENT_THRESHOLD))
.sort((a, b) => a.spaceTimeDistance - b.spaceTimeDistance)[0];
if (tap) this.consumeTap(tap.id);
return tap;
Expand Down Expand Up @@ -173,7 +173,7 @@ export class PointerHandler {
const drag = this._pointerDrags
.filter((input) => {
return (
input.distance < this._scene.p(200) &&
input.distance <= this._scene.p(JUDGMENT_THRESHOLD) &&
(!requireVelocity ||
(input.velocity.lengthSq() > 0 &&
(!input.velocityConsumed || input.velocity.dot(input.velocityConsumed) < 0)))
Expand Down

0 comments on commit 574bc16

Please sign in to comment.