diff options
| author | Aldrik Ramaekers <aldrik@amftech.nl> | 2023-12-24 11:04:11 +0100 |
|---|---|---|
| committer | Aldrik Ramaekers <aldrik@amftech.nl> | 2023-12-24 11:04:11 +0100 |
| commit | cb9c0f812695da554e1feb5afe71b38324b65103 (patch) | |
| tree | 36fb3d13a9136acbfc63684e1ab750fa0f25709e /src/rounds.c | |
| parent | aa7043faa9ed8ed676603bd1a44388026700b3b1 (diff) | |
new font and audio
Diffstat (limited to 'src/rounds.c')
| -rw-r--r-- | src/rounds.c | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/src/rounds.c b/src/rounds.c index 7d40493..88166c6 100644 --- a/src/rounds.c +++ b/src/rounds.c @@ -38,12 +38,14 @@ static float get_round_text_opacity() { return opacity; } +static int round_text_len = 0; void draw_round(platform_window* window) { if (_current_round.round_nr == 0) return; char round_text[30]; int window_center_x = _global_camera.x + window->width / 2; sprintf(round_text, "ROUND %d", _current_round.round_nr); + round_text_len = strlen(round_text); int text_w = renderer->calculate_text_width(fnt_24, round_text); int final_text_y = _global_camera.y + 20; @@ -64,7 +66,11 @@ void draw_round(platform_window* window) { renderer->render_text(fnt_20, window_center_x - (time_text_w/2), final_text_y, time_text, rgb(189, 39, 19)); } else if (_current_round.state == ROUND_SWITCHING) { - //float opacity = get_round_text_opacity(); + float delay_per_char = 0.1f; + int characters_visible_count = _current_round.round_timer/delay_per_char; + if (characters_visible_count > round_text_len) characters_visible_count = round_text_len; + round_text[characters_visible_count] = 0; + text_w = renderer->calculate_text_width(fnt_32, round_text); final_text_y = _global_camera.y + window->height/4.0f; int box_pad = 10; @@ -73,18 +79,29 @@ void draw_round(platform_window* window) { int box_w = text_w + box_pad*2; int box_h = fnt_32->px_h + box_pad*2; renderer->render_rectangle(box_x, box_y, box_w, box_h, rgba(255,0,0,100)); - renderer->render_text(fnt_32, window_center_x - (text_w/2)+1, final_text_y+1, round_text, rgba(0,0,0,120)); renderer->render_text(fnt_32, window_center_x - (text_w/2), final_text_y, round_text, rgba(255,255,255,255)); } } void update_round_server() { + static int visible_previously_count = 0; + _current_round.round_timer += SERVER_TICK_RATE; if (_current_round.state == ROUND_SWITCHING) { if (_current_round.round_timer >= ROUND_SWITCH_TIME) { _current_round.state = ROUND_SPAWNING; - _current_round.round_timer = 0.0f; + _current_round.round_timer = 0.0f; + visible_previously_count = 0; + } + + float delay_per_char = 0.1f; + int characters_visible_count = _current_round.round_timer/delay_per_char; + if (characters_visible_count > round_text_len) characters_visible_count = round_text_len; + if (visible_previously_count < characters_visible_count) { + add_ui_audio_event_to_queue(EVENT_CHARACTER_TYPE); + log_info("CHARACTER!"); + visible_previously_count = characters_visible_count; } } |
