Skip to content
Anthony Samms edited this page Jun 2, 2026 · 1 revision

The Player class is the core gameplay unit. It owns the note chart, handles all player input, evaluates judgments, maintains the score, and drives every piece of gameplay UI (gauge, combo, counters, effects, ending animation). One instance is created per active player by game.

Timing namespace

Defines the hit windows used for note judgment.

Constant Value (ms) Description
GOOD 25.025 Standard good window
OK 75.075 Standard ok window
BAD 108.442 Standard bad window
GOOD_EASY 41.708 Wider good window for easy difficulty
OK_EASY 108.442 Wider ok window for easy
BAD_EASY 125.125 Wider bad window for easy

JudgePos namespace

Global position of the judgment zone (the drum receptor on screen). Scaled by tex.screen_scale.

Constant Default Description
X 414 Horizontal position in pixels
Y 256 Vertical position in pixels

Player

Construction

Player(optional<SongParser>& parser_ref, PlayerNum player_num, int difficulty, bool is_2p, const Modifiers& modifiers);

Copies the SongParser into an internal optional, builds all note deques and the timeline, initialises the gauge and all UI objects, and loads texture IDs for the note sprites.

Public members

Member Type Description
end_time double Duration of the song in ms
bpm float Current BPM, updated by timeline events
player_num PlayerNum P1 or P2
last_note_hit double Timestamp of the most recent note judgment
judge_counter optional<JudgeCounter> Running GOOD/OK/BAD/drumroll tally display
gauge optional<Gauge> The player's health/score gauge (owns it)
dan_gauge Gauge* Non-owning pointer to a shared gauge in dan mode; set by DanGameScreen

Private scoring members

Member Type Description
good_count int Total GOOD judgments
ok_count int Total OK judgments
bad_count int Total BAD judgments (misses)
combo int Current consecutive-note streak
max_combo int Highest combo reached during the song
score int Current accumulated score
total_drumroll int Total successful drumroll hits
base_score int Score awarded per GOOD note
score_init int Bonus component of the base score
score_diff int Per-note score increment during combo

Private note queues

All queues use deque for efficient front removal as notes scroll past.

Member Type Description
don_notes deque<Note> DON (red) notes waiting to be judged
kat_notes deque<Note> KAT (blue) notes waiting to be judged
other_notes deque<Note> Drumrolls, balloons, and other special notes
barlines deque<Note> Bar line markers drawn in the note lane
draw_note_list deque<Note> Notes currently visible in the lane
branch_m/e/n deque<NoteList> Master/Expert/Normal branch note sections
timeline deque<TimelineObject> BPM changes, gogo-time markers, scroll events, etc.

Private state members

Member Type Description
is_gogo_time bool Whether the current section doubles score
is_drumroll bool Whether a drumroll is currently active
curr_drumroll_count int Hits on the current drumroll
is_balloon bool Whether a balloon is currently active
curr_balloon_count int Remaining hits needed to pop the balloon
balloon_index int Index into the chart's balloon hit-count array
is_branch bool Whether the chart has branching sections
branch_p_count float Accuracy percentage accumulated in the branch window
branch_r_count int Hit count accumulated in the branch window
current_lyric optional<OutlinedText> Lyric text displayed during the song

Private UI members

Member Type Description
combo_display Combo Large animated combo counter
score_counter ScoreCounter Score number display
base_score_list vector<ScoreCounterAnimation> Floating score pop-up animations
draw_judge_list vector<Judgment> Active GOOD/OK/BAD judgment animations
lane_hit_effect optional<LaneHitEffect> Lane flash on drum hit
draw_drum_hit_list vector<DrumHitEffect> Drum pad flash animations
gauge_hit_effect vector<GaugeHitEffect> Gauge circle animations on hit
draw_arc_list vector<NoteArc> Bezier arc animations for notes
drumroll_counter optional<DrumrollCounter> Drumroll hit counter
balloon_counter optional<BalloonCounter> Balloon pop counter
kusudama_counter optional<KusudamaCounter> Kusudama counter
gogo_time optional<GogoTime> Go-go time visual effect
fireworks optional<Fireworks> Fireworks on gogotime
combo_announce optional<ComboAnnounce> Announcement at combo milestones
branch_indicator optional<BranchIndicator> Branch level-up/down animation
ending_anim optional<variant<FailAnimation, ClearAnimation, FCAnimation>> End-of-song animation

Public methods

void update(double ms_from_start, double current_ms, optional<Background>& background);

Main update called every frame. Processes the timeline, handles input, advances note queues, updates all UI components, and triggers gameplay events in the background.

void draw(double ms_from_start, float x, float y, ray::Shader& mask_shader);

Renders the note lane, bar lines, notes, and all overlay UI at the given screen position.

void draw_practice(double ms_from_start, float x, float y, ray::Shader& mask_shader, bool draw_notes_on);

Practice-mode draw that can hide notes (draw_notes_on = false) for the "notes off" practice option.

void draw_overlays(float y, const ray::Shader& mask_shader);

Draws the gauge, combo, score, counters, judgment popups, and all active effects.

void draw_lane_cover(float y);

Draws the lane cover modifier overlay when that modifier is active.

ResultData get_result_score();

Compiles and returns the player's final statistics as a ResultData struct.

void reload_for_dan(optional<SongParser>& new_parser, int new_difficulty);

Replaces the chart with a new one for the next song in a dan course without recreating the player.

void seek_to(double resume_time);

Discards all notes before resume_time so that practice-mode scrubbing can jump mid-song.

void spawn_ending_anim();

Creates the correct ending animation variant (FailAnimation, ClearAnimation, or FCAnimation) based on the player's ok/bad counts.

Private methods

Method Description
handle_timeline() Pops and applies timeline events (BPM changes, gogo-time, scroll, branches)
note_manager() Checks note queues and dispatches judgment calls
check_note() Evaluates a DON or KAT input against the front of the note queue
check_drumroll() Registers a drumroll hit
check_balloon() Registers a balloon hit and pops it when the count reaches zero
check_kusudama() Dan-mode kusudama balloon logic
evaluate_branch() Decides which branch path to follow based on accuracy or hit-count
get_position_x/y() Calculates the on-screen position of a note at the given timestamp
spawn_hit_effects() Creates DrumHitEffect, LaneHitEffect, GaugeHitEffect, and NoteArc
autoplay_manager() Simulates perfect input when autoplay is enabled
handle_input() Reads physical input and dispatches to check_note / check_drumroll etc.
draw_notes() Iterates draw_note_list and draws each visible note
draw_drumroll() Draws the drumroll body texture between head and tail
draw_balloon() Draws the balloon body texture
draw_song_timer() Draws the remaining-time progress bar
draw_modifiers() Draws active modifier icons in the lane

Clone this wiki locally