diff options
| -rw-r--r-- | build/zombies.exe | bin | 2006675 -> 2008842 bytes | |||
| -rw-r--r-- | include/rounds.h | 1 | ||||
| -rw-r--r-- | src/game.c | 3 | ||||
| -rw-r--r-- | src/rounds.c | 53 | ||||
| -rw-r--r-- | src/zombies.c | 2 |
5 files changed, 56 insertions, 3 deletions
diff --git a/build/zombies.exe b/build/zombies.exe Binary files differindex 49f843c..57d73cd 100644 --- a/build/zombies.exe +++ b/build/zombies.exe diff --git a/include/rounds.h b/include/rounds.h index 832cc1d..de787b4 100644 --- a/include/rounds.h +++ b/include/rounds.h @@ -23,5 +23,6 @@ bool current_round_is_done(); void start_next_round(); int zombies_left_in_current_round(); void update_round_server(); +void draw_round(); #endif
\ No newline at end of file @@ -239,6 +239,7 @@ void update_server(platform_window* window) { play_sounds_in_queue(); broadcast_to_clients(create_protocol_sound_list()); clear_sounds_in_queue(); + broadcast_stamp = platform_get_time(TIME_FULL, TIME_NS) - broadcast_stamp; update_timer = 0.0f; } @@ -391,7 +392,7 @@ void update_game(platform_window* window) { #endif draw_players(window); - + draw_round(window); draw_spawners(window); draw_overlay(window); diff --git a/src/rounds.c b/src/rounds.c index 8db9ae8..1cdebd7 100644 --- a/src/rounds.c +++ b/src/rounds.c @@ -4,10 +4,20 @@ bool current_round_is_done() return _current_round.zombies == 0 && number_of_zombies_active() == 0; } +static u32 get_number_of_zombies_in_round(u32 round_nr) +{ + // 10 = 25 + // 20 = 66 + // 50 = 250 + // 100 = 640 + // 200 = 1670 + return 8 + pow(round_nr, 1.4f); +} + void start_next_round() { _current_round.round_nr++; - _current_round.zombies = 6; + _current_round.zombies = get_number_of_zombies_in_round(_current_round.round_nr); _current_round.state = ROUND_SWITCHING; _current_round.round_timer = 0.0f; @@ -20,12 +30,53 @@ int zombies_left_in_current_round() return _current_round.zombies; } +static float get_round_text_opacity() { + float opacity = 2.0f - ((_current_round.round_timer / ROUND_SWITCH_TIME)*2); + if (opacity > 1.0f) opacity = 1.0f; + return opacity; +} + +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); + int text_w = renderer->calculate_text_width(fnt_24, round_text); + int final_text_y = _global_camera.y + 20; + + if (_current_round.state == ROUND_SPAWNING) { + renderer->render_text(fnt_24, window_center_x - (text_w/2)+1, final_text_y+1, round_text, rgba(0,0,0,120)); + renderer->render_text(fnt_24, window_center_x - (text_w/2), final_text_y, round_text, rgb(189, 39, 19)); + + char time_text[30]; + sprintf(time_text, "%.0fs", _current_round.round_timer); + if (_current_round.round_timer >= 60) { + int min = (int)(_current_round.round_timer/60.0f); + int sec = (int)((int)_current_round.round_timer%60); + sprintf(time_text, "%dm %ds", min, sec); + } + int time_text_w = renderer->calculate_text_width(fnt_20, time_text); + final_text_y = _global_camera.y + 24 + fnt_24->px_h; + renderer->render_text(fnt_20, window_center_x - (time_text_w/2)+1, final_text_y+1, time_text, rgba(0,0,0,120)); + 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(); + text_w = renderer->calculate_text_width(fnt_32, round_text); + final_text_y = _global_camera.y + window->height/4.0f; + renderer->render_text(fnt_32, window_center_x - (text_w/2)+1, final_text_y+1, round_text, rgba(0,0,0,120*opacity)); + renderer->render_text(fnt_32, window_center_x - (text_w/2), final_text_y, round_text, rgba(189, 39, 19,255*opacity)); + } +} + void update_round_server() { _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; } } diff --git a/src/zombies.c b/src/zombies.c index a3fad4c..576fb95 100644 --- a/src/zombies.c +++ b/src/zombies.c @@ -102,9 +102,9 @@ void update_spawners_server() { for (int x = 0; x < MAX_SPAWNERS; x++) { spawner spawner = spawner_tiles[x]; if (!spawner.active) continue; - if (zombies_left_in_current_round() <= 0) continue; update_sprite(&spawner_tiles[x].sprite); spawner_tiles[x].sec_since_last_spawn += SERVER_TICK_RATE; + if (zombies_left_in_current_round() <= 0) continue; if (spawner_tiles[x].sec_since_last_spawn >= 1.0f) { spawn_zombie(spawner.position.x, spawner.position.y); spawner_tiles[x].sec_since_last_spawn = 0; |
