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

The game screen is where active gameplay takes place. It manages the song timeline, player input, audio playback, and the transition to the result screen. Three variants exist: GameScreen (single player), Game2PScreen (two-player), and DanGameScreen (dan/ranking mode). All use the skin name "game".

GameScreen

Inherits from Screen. Base class for all gameplay screens.

Members

Member Type Description
mask_shader ray::Shader Shader used to render rainbow balloon notes with a mask texture
start_ms double Absolute timestamp when the song audio began
ms_from_start double Milliseconds elapsed since song start (used for note timing)
start_delay double Delay (ms) before the song audio begins; default 1000 ms
song_started bool Whether the song audio is currently playing
paused bool Whether the game is paused
score_saved bool Whether the score has already been written to disk
pause_time int Accumulated pause duration (ms) subtracted from timing
bpm float Current song BPM, read from chart metadata
movie optional<VideoPlayer> Music video, present when the chart specifies a BGMOVIE
song_music optional<string> Audio key used by the audio subsystem
parser optional<SongParser> Parsed chart data; reset on screen exit
scene_preset string Name of the Lua background script to load
players vector<unique_ptr<Player>> One Player per active player
song_info SongInfo Song title and number display
transition optional<Transition> Intro transition shown before gameplay starts
result_transition ResultTransition Slide animation that moves the player UI toward the result screen
allnet_indicator AllNetIcon Online connectivity indicator
background optional<Background> Lua-driven dynamic background; absent when a movie is playing

Lifecycle

void on_screen_start() override;

Loads the mask shader, parses the selected song via init_tja(), loads hit sounds, creates SongInfo, ResultTransition, and either a Background (Lua) or a VideoPlayer (for songs with a music video). Starts the intro Transition.

Screens on_screen_end(Screens next_screen) override;

Unloads the shader, stops and releases the movie, resets background, transition, song_music, parser, and players, then calls Screen::on_screen_end.

Methods

virtual void init_tja(fs::path song);

Parses the chart file, resolves the audio path, loads it as "song", and populates per-player session metadata (title, subtitle).

void load_hitsounds();

Loads don and kat hit-sound files for both P1 and P2 from the configured hit-sound slot. Supports both .ogg and .wav formats; .wav is selected when the hit-sound index is -1.

void start_song(double ms_from_start);

Sets start_ms to the current wall-clock time minus any elapsed ms_from_start, then begins audio playback.

void restart_song();

Resets all player state, reloads the chart, and calls start_song(0).

void pause_song();

Toggles paused, stopping or resuming audio accordingly.

void resync_song(double ms_from_start);

Seeks the audio stream to ms_from_start and updates start_ms to maintain synchronisation.

void end_song();

Sets song_started = false, stops audio, saves scores for all players, and starts result_transition.

std::optional<Screens> global_keys();

Handles pause/restart input that applies regardless of gameplay state.

void save_score(int player_id);

Reads ResultData from the relevant Player, writes it to the score store via Scores::save(), and sets score_saved = true.

Update

std::optional<Screens> update() override;

Each frame:

  1. Calls Screen::update().
  2. Advances the transition; once it finishes, starts the song.
  3. Computes ms_from_start from wall-clock time minus start_ms and accumulated pause_time.
  4. Calls global_keys() and each Player::update().
  5. Updates song_info, background, and result_transition.
  6. When all players are finished and result_transition is complete, saves scores and returns Screens::RESULT.

Draw

void draw() override;

Renders in this order:

  1. background->draw_back() or the movie frame.
  2. draw_players() — note lane and notes for each player.
  3. background->draw_fore().
  4. draw_overlay() — song info, transition, result transition, and allnet indicator.
void draw_players();

Calls Player::draw() or Player::draw_practice() for each player at its assigned x/y position.

void draw_overlay();

Draws song_info, the intro transition, result_transition, and allnet_indicator.


Game2PScreen

Inherits from GameScreen. Two-player variant.

Additional members

Member Type Description
parser_2p optional<SongParser> Separately parsed chart for player 2

Behaviour differences

  • on_screen_start() calls the base, then constructs a second Player using P2's session data and parser_2p.
  • init_tja() parses both P1's and P2's selected songs independently so each player can play a different difficulty or even a different chart.
  • update() mirrors the base loop but advances both players. The transition to Screens::RESULT_2P fires when both players are finished.

DanGameScreen

Inherits from GameScreen. Plays a sequence of songs for a dan (ranking) challenge with shared pass/fail criteria.

Additional members

Member Type Description
song_index int Index of the currently playing song in the dan course (0-based)
total_notes int Cumulative note count across all songs in the course
dan_color int Index used to select the correct dan emblem colour texture
dan_gauge Gauge Shared gauge in GaugeMode::DAN; the player's Player::dan_gauge points here
exam_failed vector<bool> Per-exam failure flags set by check_exam_failures()
dan_info_cache optional<DanInfoCache> Cached per-frame exam display data recalculated each update
hori_name unique_ptr<OutlinedText> Outlined text showing the course name
prev_good etc. int Cumulative stat totals from previous songs, used to compute per-song deltas

DanExamInfo

Per-exam display data computed each frame.

Field Type Description
progress float Normalised exam progress (0–1)
bar_width float Width of the progress bar in pixels
counter_value int Current stat value being measured by the exam
red_value int Threshold at which the bar turns red
bar_texture string Texture key for the progress bar (red or gold)
exam_type string Type of exam condition (e.g. "good", "combo")
exam_range string Whether the exam applies to all songs or just one

Behaviour differences

  • on_screen_start() calls init_dan() instead of the base init path. init_dan() sets up dan_gauge, reads all songs in the course, and links dan_gauge into each Player.
  • change_song() is called when a song ends; it loads the next chart and continues without returning to song select.
  • check_exam_failures() evaluates each Exam against the current cumulative stats and sets exam_failed flags.
  • draw() calls draw_dan_info() after the base draw to overlay exam progress bars and the course name.
  • When all songs are complete, exits to Screens::DAN_RESULT.

Clone this wiki locally