diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/asset_defs.c | 30 | ||||
| -rw-r--r-- | src/audio.c | 6 | ||||
| -rw-r--r-- | src/players.c | 7 | ||||
| -rw-r--r-- | src/rounds.c | 23 |
4 files changed, 49 insertions, 17 deletions
diff --git a/src/asset_defs.c b/src/asset_defs.c index 70877a3..6bf6718 100644 --- a/src/asset_defs.c +++ b/src/asset_defs.c @@ -1,17 +1,21 @@ #include "../include/asset_defs.h" +//#include "../data/fonts/oxanium.h" +#include "../data/fonts/aleo.h" + void load_assets() { - fnt_52 = assets_load_font(noto_regular_ttf, noto_regular_ttf+noto_regular_ttf_len, 52); - fnt_48 = assets_load_font(noto_regular_ttf, noto_regular_ttf+noto_regular_ttf_len, 48); - fnt_44 = assets_load_font(noto_regular_ttf, noto_regular_ttf+noto_regular_ttf_len, 44); - fnt_40 = assets_load_font(noto_regular_ttf, noto_regular_ttf+noto_regular_ttf_len, 40); - fnt_36 = assets_load_font(noto_regular_ttf, noto_regular_ttf+noto_regular_ttf_len, 36); - fnt_32 = assets_load_font(noto_regular_ttf, noto_regular_ttf+noto_regular_ttf_len, 32); - fnt_28 = assets_load_font(noto_regular_ttf, noto_regular_ttf+noto_regular_ttf_len, 28); - fnt_24 = assets_load_font(noto_regular_ttf, noto_regular_ttf+noto_regular_ttf_len, 24); - fnt_20 = assets_load_font(noto_regular_ttf, noto_regular_ttf+noto_regular_ttf_len, 20); - fnt_16 = assets_load_font(noto_regular_ttf, noto_regular_ttf+noto_regular_ttf_len, 16); - fnt_12 = assets_load_font(noto_regular_ttf, noto_regular_ttf+noto_regular_ttf_len, 12); + + fnt_52 = assets_load_font(Aleo_Regular, Aleo_Regular + Aleo_Regular_Size, 52); + fnt_48 = assets_load_font(Aleo_Regular, Aleo_Regular + Aleo_Regular_Size, 48); + fnt_44 = assets_load_font(Aleo_Regular, Aleo_Regular + Aleo_Regular_Size, 44); + fnt_40 = assets_load_font(Aleo_Regular, Aleo_Regular + Aleo_Regular_Size, 40); + fnt_36 = assets_load_font(Aleo_Regular, Aleo_Regular + Aleo_Regular_Size, 36); + fnt_32 = assets_load_font(Aleo_Regular, Aleo_Regular + Aleo_Regular_Size, 32); + fnt_28 = assets_load_font(Aleo_Regular, Aleo_Regular + Aleo_Regular_Size, 28); + fnt_24 = assets_load_font(Aleo_Regular, Aleo_Regular + Aleo_Regular_Size, 24); + fnt_20 = assets_load_font(Aleo_Regular, Aleo_Regular + Aleo_Regular_Size, 20); + fnt_16 = assets_load_font(Aleo_Regular, Aleo_Regular + Aleo_Regular_Size, 16); + fnt_12 = assets_load_font(Aleo_Regular, Aleo_Regular + Aleo_Regular_Size, 12); // Icons img_icon_bullets = assets_load_image_from_file("data/imgs/bullets.png"); @@ -62,7 +66,9 @@ void load_assets() { wav_error = Mix_LoadWAV("data/sounds/error.wav"); wav_impact_zombie = Mix_LoadWAV("data/sounds/impact_zombie.wav"); wav_collect = Mix_LoadWAV("data/sounds/collect.wav"); - round_change = Mix_LoadWAV("data/sounds/round_change.wav"); + wav_round_change = Mix_LoadWAV("data/sounds/round_change.wav"); + wav_character = Mix_LoadWAV("data/sounds/character.wav"); + wav_step = Mix_LoadWAV("data/sounds/step.wav"); } font* get_font(platform_window* window, float scale) { diff --git a/src/audio.c b/src/audio.c index fadd214..f741570 100644 --- a/src/audio.c +++ b/src/audio.c @@ -51,7 +51,9 @@ static Mix_Chunk* get_sample_from_audio_event(audio_event event, u32 playerid) { switch (event.type) { - case EVENT_ROUND_CHANGE: return round_change; + case EVENT_FOOTSTEP: return wav_step; + case EVENT_CHARACTER_TYPE: return wav_character; + case EVENT_ROUND_CHANGE: return wav_round_change; case EVENT_COLLECT: return wav_collect; case EVENT_BOUNCE_THROWABLE: return wav_throwable_bounce; case EVENT_FIRE: return wav_fire; @@ -149,6 +151,6 @@ void play_positioned_sound(int channel, Mix_Chunk* wav, vec3f pos, float max_aud if (rads > 360) rads -= 360; */ - Mix_SetPosition(0, 0, volume*255); + //Mix_SetPosition(0, 0, volume*255); Mix_PlayChannel(channel, wav, 0); } diff --git a/src/players.c b/src/players.c index cd2e479..93b87cf 100644 --- a/src/players.c +++ b/src/players.c @@ -64,6 +64,7 @@ void spawn_player(u32 id, network_client client) { players[i].throwables.grenades = 3; players[i].throwables.molotovs = 1; players[i].points = 800; + players[i].sec_since_last_step = 0.0f; gun g = get_gun_by_type(players[i].guntype); players[i].total_ammo = g.max_ammunition; @@ -121,6 +122,11 @@ void move_user(platform_window* window, u32 id, protocol_move_type move, float d return; } + if (p->sec_since_last_step > 0.2f) { + add_audio_event_to_queue(EVENT_FOOTSTEP, p->id, (vec3f){.x = p->playerx, .y = p->playery, .z = p->height}); + p->sec_since_last_step = 0.0f; + } + if (move == MOVE_UPLEFT || move == MOVE_UPRIGHT || move == MOVE_DOWNLEFT || move == MOVE_DOWNRIGHT) { float diag = (speed_straight * sqrt(2)); speed = (speed_straight * (speed_straight / diag)) * delta; @@ -347,6 +353,7 @@ void update_players_server() { if (!players[i].active) continue; players[i].sec_since_last_shot += SERVER_TICK_RATE; players[i].sec_since_interact_state_change += SERVER_TICK_RATE; + players[i].sec_since_last_step += SERVER_TICK_RATE; gun g = get_gun_by_type(players[i].guntype); if (players[i].interact_state == INTERACT_RELOADING && players[i].sec_since_interact_state_change >= g.reload_time) { 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; } } |
