From f2522c04446bb4bd597a8625f9398e67ff957565 Mon Sep 17 00:00:00 2001 From: Aldrik Ramaekers Date: Sat, 28 Oct 2023 16:27:07 +0200 Subject: more sounds --- .vscode/settings.json | 8 ++++++++ build/data/imgs/tile_cobblestone.png | Bin 3147 -> 0 bytes build/data/imgs/tiles/tile_cobblestone.png | Bin 42438 -> 42822 bytes build/data/sounds/impact_zombie.wav | Bin 0 -> 62100 bytes build/zombies.exe | Bin 1979802 -> 1981936 bytes data/imgs/tile_cobblestone.png | Bin 3147 -> 0 bytes data/imgs/tiles/tile_cobblestone.png | Bin 42438 -> 42822 bytes data/sounds/impact_zombie.wav | Bin 0 -> 62100 bytes include/asset_defs.h | 1 + include/audio.h | 2 ++ include/zombies.h | 6 ++++++ src/asset_defs.c | 1 + src/audio.c | 30 +++++++++++++++++++++++------ src/bullets.c | 2 ++ src/throwables.c | 7 ++++++- src/zombies.c | 1 + 16 files changed, 51 insertions(+), 7 deletions(-) create mode 100644 .vscode/settings.json delete mode 100644 build/data/imgs/tile_cobblestone.png create mode 100644 build/data/sounds/impact_zombie.wav delete mode 100644 data/imgs/tile_cobblestone.png create mode 100644 data/sounds/impact_zombie.wav diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..7a89823 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,8 @@ +{ + "files.associations": { + "*.ejs": "html", + "initializer_list": "c", + "type_traits": "c", + "xutility": "c" + } +} \ No newline at end of file diff --git a/build/data/imgs/tile_cobblestone.png b/build/data/imgs/tile_cobblestone.png deleted file mode 100644 index 86a59fb..0000000 Binary files a/build/data/imgs/tile_cobblestone.png and /dev/null differ diff --git a/build/data/imgs/tiles/tile_cobblestone.png b/build/data/imgs/tiles/tile_cobblestone.png index 31ab8ee..32c78ac 100644 Binary files a/build/data/imgs/tiles/tile_cobblestone.png and b/build/data/imgs/tiles/tile_cobblestone.png differ diff --git a/build/data/sounds/impact_zombie.wav b/build/data/sounds/impact_zombie.wav new file mode 100644 index 0000000..ca557ef Binary files /dev/null and b/build/data/sounds/impact_zombie.wav differ diff --git a/build/zombies.exe b/build/zombies.exe index b02bfb7..dc93d54 100644 Binary files a/build/zombies.exe and b/build/zombies.exe differ diff --git a/data/imgs/tile_cobblestone.png b/data/imgs/tile_cobblestone.png deleted file mode 100644 index 86a59fb..0000000 Binary files a/data/imgs/tile_cobblestone.png and /dev/null differ diff --git a/data/imgs/tiles/tile_cobblestone.png b/data/imgs/tiles/tile_cobblestone.png index 31ab8ee..32c78ac 100644 Binary files a/data/imgs/tiles/tile_cobblestone.png and b/data/imgs/tiles/tile_cobblestone.png differ diff --git a/data/sounds/impact_zombie.wav b/data/sounds/impact_zombie.wav new file mode 100644 index 0000000..ca557ef Binary files /dev/null and b/data/sounds/impact_zombie.wav differ diff --git a/include/asset_defs.h b/include/asset_defs.h index 63f46bd..acca89e 100644 --- a/include/asset_defs.h +++ b/include/asset_defs.h @@ -42,6 +42,7 @@ Mix_Chunk* wav_throwable_bounce; Mix_Chunk* wav_shoot_mp5; Mix_Chunk* wav_reload_mp5; +Mix_Chunk* wav_impact_zombie; Mix_Chunk* wav_impact_wood; Mix_Chunk* wav_error; diff --git a/include/audio.h b/include/audio.h index 47cd10e..38543dd 100644 --- a/include/audio.h +++ b/include/audio.h @@ -20,12 +20,14 @@ typedef struct t_audio_event { u32 playerid; vec3f position; object_type obj; + zombie_type zombie; } audio_event; #define MAX_AUDIO_EVENTS 20 audio_event audio_events[MAX_AUDIO_EVENTS] = {0}; int max_audio_events = MAX_AUDIO_EVENTS; +void add_zombie_audio_event_to_queue(audio_event_type event, zombie_type zombie, u32 playerid, vec3f position); void add_object_audio_event_to_queue(audio_event_type event, object_type obj, u32 playerid, vec3f position); void add_audio_event_to_queue(audio_event_type event, u32 playerid, vec3f position); void play_sounds_in_queue(); diff --git a/include/zombies.h b/include/zombies.h index 0c18bef..eeadaaf 100644 --- a/include/zombies.h +++ b/include/zombies.h @@ -8,6 +8,11 @@ #include "pathfinding.h" #include "sprite.h" +typedef enum t_zombie_type { + ZOMBIE_TYPE_NONE, + ZOMBIE_TYPE_NORMAL, +} zombie_type; + typedef struct t_zombie { bool alive; float health; @@ -18,6 +23,7 @@ typedef struct t_zombie { float time_since_last_path; pathfinding_request request; vec2f next2tiles[2]; + zombie_type type; } zombie; typedef struct t_spawner { diff --git a/src/asset_defs.c b/src/asset_defs.c index 86832d4..a83ad96 100644 --- a/src/asset_defs.c +++ b/src/asset_defs.c @@ -41,4 +41,5 @@ void load_assets() { wav_reload_mp5 = Mix_LoadWAV("data/sounds/reload_mp5.wav"); wav_impact_wood = Mix_LoadWAV("data/sounds/impact_wood.wav"); wav_error = Mix_LoadWAV("data/sounds/error.wav"); + wav_impact_zombie = Mix_LoadWAV("data/sounds/impact_zombie.wav"); } \ No newline at end of file diff --git a/src/audio.c b/src/audio.c index 0c53538..b174610 100644 --- a/src/audio.c +++ b/src/audio.c @@ -1,10 +1,19 @@ #include "../include/audio.h" +void add_zombie_audio_event_to_queue(audio_event_type event, zombie_type zombie, u32 playerid, vec3f position) { + for (int i = 0; i < max_audio_events; i++) { + if (audio_events[i].active) continue; + + audio_events[i] = (audio_event){.active = true, .obj = OBJECT_NONE, .zombie = zombie, .playerid = playerid, .position = position, .type = event}; + return; + } +} + void add_object_audio_event_to_queue(audio_event_type event, object_type obj, u32 playerid, vec3f position) { for (int i = 0; i < max_audio_events; i++) { if (audio_events[i].active) continue; - audio_events[i] = (audio_event){.active = true, .obj = obj, .playerid = playerid, .position = position, .type = event}; + audio_events[i] = (audio_event){.active = true, .obj = obj, .zombie = ZOMBIE_TYPE_NONE, .playerid = playerid, .position = position, .type = event}; return; } } @@ -35,7 +44,7 @@ static Mix_Chunk* get_sample_from_audio_event(audio_event event, u32 playerid) { case EVENT_SHOOT: { switch (p->guntype) { - case GUN_MP5: return wav_shoot_mp5; + case GUN_MP5: return wav_shoot_mp5; default: return wav_error; } } @@ -48,10 +57,19 @@ static Mix_Chunk* get_sample_from_audio_event(audio_event event, u32 playerid) { } case EVENT_IMPACT: { - switch (event.obj) - { - case OBJECT_PLANTBOX1: return wav_impact_wood; - default: return wav_error; + if (event.zombie != ZOMBIE_TYPE_NONE) { + switch (event.zombie) + { + case ZOMBIE_TYPE_NORMAL: return wav_impact_zombie; + default: return wav_error; + } + } + else { + switch (event.obj) + { + case OBJECT_PLANTBOX1: return wav_impact_wood; + default: return wav_error; + } } } diff --git a/src/bullets.c b/src/bullets.c index 728326e..f7f033d 100644 --- a/src/bullets.c +++ b/src/bullets.c @@ -248,6 +248,8 @@ void update_bullets_server(platform_window* window) { bullets[i].endx = b.endx; bullets[i].damage = b.damage; b = bullets[i]; + + add_zombie_audio_event_to_queue(EVENT_IMPACT, ZOMBIE_TYPE_NORMAL, p->id, (vec3f){.x = p->playerx, .y = p->playery, .z = p->height}); } } } diff --git a/src/throwables.c b/src/throwables.c index 1d04565..630dccb 100644 --- a/src/throwables.c +++ b/src/throwables.c @@ -121,6 +121,11 @@ void draw_throwables(platform_window* window) { float throwable_render_x = t.position.x*info.tile_width + (t.position.y*info.px_incline); float throwable_render_y = t.position.y*info.tile_height - (t.position.z*info.px_raised_per_h); - renderer->render_image(img_grenade, throwable_render_x, throwable_render_y, 10, 10); + box full_box = get_render_box_of_square(window, t.position, (vec3f){0.2, 0.2, 0.2}); + renderer->render_image(img_grenade, full_box.tl_u.x, full_box.tl_u.y, + full_box.br_d.x - full_box.tl_d.x, full_box.br_d.y - full_box.tr_u.y); + + + //renderer->render_image(img_grenade, throwable_render_x, throwable_render_y, 10, 10); } } \ No newline at end of file diff --git a/src/zombies.c b/src/zombies.c index c72e04b..4c1225a 100644 --- a/src/zombies.c +++ b/src/zombies.c @@ -46,6 +46,7 @@ void spawn_zombie(int x, int y) { zombies[i].path = array_create(sizeof(vec2f)); zombies[i].next_path = array_create(sizeof(vec2f)); zombies[i].alive = true; + zombies[i].type = ZOMBIE_TYPE_NORMAL; zombies[i].health = 100.0f; zombies[i].position = (vec3f){x,y, 0}; zombies[i].size = (vec3f){0.4, 0.4, 1}; -- cgit v1.2.3-70-g09d2