summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.vscode/settings.json8
-rw-r--r--build/data/imgs/tile_cobblestone.pngbin3147 -> 0 bytes
-rw-r--r--build/data/imgs/tiles/tile_cobblestone.pngbin42438 -> 42822 bytes
-rw-r--r--build/data/sounds/impact_zombie.wavbin0 -> 62100 bytes
-rw-r--r--build/zombies.exebin1979802 -> 1981936 bytes
-rw-r--r--data/imgs/tile_cobblestone.pngbin3147 -> 0 bytes
-rw-r--r--data/imgs/tiles/tile_cobblestone.pngbin42438 -> 42822 bytes
-rw-r--r--data/sounds/impact_zombie.wavbin0 -> 62100 bytes
-rw-r--r--include/asset_defs.h1
-rw-r--r--include/audio.h2
-rw-r--r--include/zombies.h6
-rw-r--r--src/asset_defs.c1
-rw-r--r--src/audio.c30
-rw-r--r--src/bullets.c2
-rw-r--r--src/throwables.c7
-rw-r--r--src/zombies.c1
16 files changed, 51 insertions, 7 deletions
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
--- a/build/data/imgs/tile_cobblestone.png
+++ /dev/null
Binary files differ
diff --git a/build/data/imgs/tiles/tile_cobblestone.png b/build/data/imgs/tiles/tile_cobblestone.png
index 31ab8ee..32c78ac 100644
--- a/build/data/imgs/tiles/tile_cobblestone.png
+++ b/build/data/imgs/tiles/tile_cobblestone.png
Binary files differ
diff --git a/build/data/sounds/impact_zombie.wav b/build/data/sounds/impact_zombie.wav
new file mode 100644
index 0000000..ca557ef
--- /dev/null
+++ b/build/data/sounds/impact_zombie.wav
Binary files differ
diff --git a/build/zombies.exe b/build/zombies.exe
index b02bfb7..dc93d54 100644
--- a/build/zombies.exe
+++ b/build/zombies.exe
Binary files differ
diff --git a/data/imgs/tile_cobblestone.png b/data/imgs/tile_cobblestone.png
deleted file mode 100644
index 86a59fb..0000000
--- a/data/imgs/tile_cobblestone.png
+++ /dev/null
Binary files differ
diff --git a/data/imgs/tiles/tile_cobblestone.png b/data/imgs/tiles/tile_cobblestone.png
index 31ab8ee..32c78ac 100644
--- a/data/imgs/tiles/tile_cobblestone.png
+++ b/data/imgs/tiles/tile_cobblestone.png
Binary files differ
diff --git a/data/sounds/impact_zombie.wav b/data/sounds/impact_zombie.wav
new file mode 100644
index 0000000..ca557ef
--- /dev/null
+++ b/data/sounds/impact_zombie.wav
Binary files 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};