-
Notifications
You must be signed in to change notification settings - Fork 6
game
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".
Inherits from Screen. Base class for all gameplay screens.
| 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 |
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.
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.
std::optional<Screens> update() override;Each frame:
- Calls
Screen::update(). - Advances the
transition; once it finishes, starts the song. - Computes
ms_from_startfrom wall-clock time minusstart_msand accumulatedpause_time. - Calls
global_keys()and eachPlayer::update(). - Updates
song_info,background, andresult_transition. - When all players are finished and
result_transitionis complete, saves scores and returnsScreens::RESULT.
void draw() override;Renders in this order:
-
background->draw_back()or the movie frame. -
draw_players()— note lane and notes for each player. -
background->draw_fore(). -
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.
Inherits from GameScreen. Two-player variant.
| Member | Type | Description |
|---|---|---|
parser_2p |
optional<SongParser> |
Separately parsed chart for player 2 |
-
on_screen_start()calls the base, then constructs a secondPlayerusing P2's session data andparser_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 toScreens::RESULT_2Pfires when both players are finished.
Inherits from GameScreen. Plays a sequence of songs for a dan (ranking) challenge with shared pass/fail criteria.
| 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 |
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 |
-
on_screen_start()callsinit_dan()instead of the base init path.init_dan()sets updan_gauge, reads all songs in the course, and linksdan_gaugeinto eachPlayer. -
change_song()is called when a song ends; it loads the next chart and continues without returning to song select. -
check_exam_failures()evaluates eachExamagainst the current cumulative stats and setsexam_failedflags. -
draw()callsdraw_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.
Building
libs
- animation
- audio
- config
- filesystem
- global_data
- input
- logging
- ray
- scores
- screen
- script
- song_parser
- text
- texture
- video
- webcam
libs/parsers
objects
objects/game
- player
- background
- gauge
- judgment
- combo
- branch_indicator
- ending_animations
- gogo_time
- fireworks
- song_info
- transition
- result_transition
- judge_counter
- score_counter
- score_counter_animation
- balloon_counter
- drumroll_counter
- kusudama_counter
- drum_hit_effect
- lane_hit_effect
- gauge_hit_effect
- combo_announce
- note_arc
objects/global
objects/title
objects/entry
objects/settings
objects/result
objects/song_select
- player
- navigator
- box_base
- box_song
- box_folder
- neiro
- modifier
- ura_switch
- diff_sort
- search_box
- dan_transition
- genre_bg
- score_history
- song_select_script
scenes