diff options
| author | Aldrik Ramaekers <aldrikboy@gmail.com> | 2024-05-17 22:48:25 +0200 |
|---|---|---|
| committer | Aldrik Ramaekers <aldrikboy@gmail.com> | 2024-05-17 22:48:25 +0200 |
| commit | 003c13a4ae07c3ec15a31df0f7f65e3d1ffe9ae0 (patch) | |
| tree | a56b0e1d84d297c5869e8272fcac58c298a51ed5 /src/rounds.c | |
| parent | f06351b8a04d0a68628b05bed884832840998c6c (diff) | |
game fade in and out
Diffstat (limited to 'src/rounds.c')
| -rw-r--r-- | src/rounds.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/rounds.c b/src/rounds.c index 4d69aff..4c991af 100644 --- a/src/rounds.c +++ b/src/rounds.c @@ -21,6 +21,11 @@ void start_next_round() _current_round.state = ROUND_SWITCHING; _current_round.round_timer = 0.0f; + // Fade in at start of game. + if (_current_round.round_nr == 1) { + _current_round.fade_in_timer = FADE_IN_DURATION; + } + add_ui_audio_event_to_queue(EVENT_ROUND_CHANGE); log_infox("Next round: %d", _current_round.round_nr); @@ -85,10 +90,29 @@ void draw_round(platform_window* window) { } } +void restart_game() +{ + // TODO +} + void update_round_server() { static int visible_previously_count = 0; + if (!every_player_died()) { + _current_round.fade_in_timer -= SERVER_TICK_RATE; + if (_current_round.fade_in_timer <= 0.0f) + _current_round.fade_in_timer = 0.0f; + } + else { + _current_round.fade_in_timer += SERVER_TICK_RATE; + if (_current_round.fade_in_timer >= FADE_IN_DURATION) { + _current_round.fade_in_timer = FADE_IN_DURATION; + + restart_game(); + } + } + _current_round.round_timer += SERVER_TICK_RATE; if (_current_round.state == ROUND_SWITCHING) { if (_current_round.round_timer >= ROUND_SWITCH_TIME) { |
