summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build/data/sounds/round_change.wavbin0 -> 195918 bytes
-rw-r--r--build/zombies.exebin2022770 -> 2024122 bytes
-rw-r--r--data/sounds/round_change.wavbin0 -> 195918 bytes
-rw-r--r--include/asset_defs.h2
-rw-r--r--include/audio.h4
-rw-r--r--main.c4
-rw-r--r--src/asset_defs.c2
-rw-r--r--src/audio.c25
-rw-r--r--src/map.c5
-rw-r--r--src/rounds.c16
-rw-r--r--src/zombies.c2
11 files changed, 43 insertions, 17 deletions
diff --git a/build/data/sounds/round_change.wav b/build/data/sounds/round_change.wav
new file mode 100644
index 0000000..bb3d3fa
--- /dev/null
+++ b/build/data/sounds/round_change.wav
Binary files differ
diff --git a/build/zombies.exe b/build/zombies.exe
index 6dc4e09..feed36e 100644
--- a/build/zombies.exe
+++ b/build/zombies.exe
Binary files differ
diff --git a/data/sounds/round_change.wav b/data/sounds/round_change.wav
new file mode 100644
index 0000000..bb3d3fa
--- /dev/null
+++ b/data/sounds/round_change.wav
Binary files differ
diff --git a/include/asset_defs.h b/include/asset_defs.h
index 7001403..002ad23 100644
--- a/include/asset_defs.h
+++ b/include/asset_defs.h
@@ -69,6 +69,8 @@ Mix_Chunk* wav_impact_wood;
Mix_Chunk* wav_error;
Mix_Chunk* wav_collect;
+Mix_Chunk* round_change;
+
void load_assets();
font* get_font(platform_window* window, float scale);
diff --git a/include/audio.h b/include/audio.h
index a22ec95..d9343e5 100644
--- a/include/audio.h
+++ b/include/audio.h
@@ -22,6 +22,7 @@ typedef enum t_audio_event_type {
EVENT_IMPACT,
EVENT_COLLECT,
EVENT_FIRE,
+ EVENT_ROUND_CHANGE,
} audio_event_type;
typedef struct t_audio_event {
@@ -36,12 +37,15 @@ typedef struct t_audio_event {
#define MAX_AUDIO_EVENTS 20
audio_event audio_events[MAX_AUDIO_EVENTS] = {0};
+bool audio_channel_usage[NUM_AUDIO_CHANNELS] = {0};
int max_audio_events = MAX_AUDIO_EVENTS;
+void audio_channel_finished(int channel);
void add_throwable_audio_event_to_queue(audio_event_type event, throwable_type throwable, u32 playerid, vec3f position);
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 add_ui_audio_event_to_queue(audio_event_type event);
void play_sounds_in_queue();
void clear_sounds_in_queue();
void play_sound(int channel, Mix_Chunk* wav);
diff --git a/main.c b/main.c
index d0224b1..5662d56 100644
--- a/main.c
+++ b/main.c
@@ -1,6 +1,7 @@
#define ASSET_IMAGE_COUNT 50
#define ASSET_QUEUE_COUNT 50
#define ASSET_FONT_COUNT 20
+#define NUM_AUDIO_CHANNELS 64
#include <projectbase/project_base.h>
@@ -98,9 +99,10 @@ int main(int argc, char **argv)
settings_set_number("USE_GPU", 1);
if (Mix_OpenAudio(48000, AUDIO_F32SYS, 2, 2048) == 0) {
- if (Mix_AllocateChannels(NUMBER_OF_AUDIO_CHANNELS) == 64) {
+ if (Mix_AllocateChannels(NUMBER_OF_AUDIO_CHANNELS) == NUM_AUDIO_CHANNELS) {
log_info("Audio system initialized.");
Mix_MasterVolume(MIX_MAX_VOLUME/4);
+ Mix_ChannelFinished(audio_channel_finished);
}
else {
log_info("Channel allocation failed.");
diff --git a/src/asset_defs.c b/src/asset_defs.c
index 4fe621d..70877a3 100644
--- a/src/asset_defs.c
+++ b/src/asset_defs.c
@@ -62,6 +62,7 @@ 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");
}
font* get_font(platform_window* window, float scale) {
@@ -75,7 +76,6 @@ font* get_font(platform_window* window, float scale) {
if (index_to_return < 0) index_to_return = 0;
if (index_to_return > 10) index_to_return = 10;
- log_infox("%d %d", (int)(diff/0.2f), index_to_return);
font* arr[] = {
fnt_12, // scale = 0.2
fnt_16,
diff --git a/src/audio.c b/src/audio.c
index 73232af..fadd214 100644
--- a/src/audio.c
+++ b/src/audio.c
@@ -31,18 +31,18 @@ void add_audio_event_to_queue(audio_event_type event, u32 playerid, vec3f positi
add_object_audio_event_to_queue(event, OBJECT_NONE, playerid, position);
}
+void add_ui_audio_event_to_queue(audio_event_type event) {
+ add_object_audio_event_to_queue(event, OBJECT_NONE, -1, (vec3f){-1,-1,-1});
+}
+
static int get_channel_from_audio_event_type(audio_event_type event) {
- switch (event)
- {
- case EVENT_BOUNCE_THROWABLE: return CHANNEL_THROWABLES;
- case EVENT_SHOOT: return CHANNEL_SHOOTING;
- case EVENT_RELOAD: return CHANNEL_RELOAD;
- case EVENT_IMPACT: return CHANNEL_IMPACT;
- case EVENT_EXPLODE_THROWABLE: return CHANNEL_EXPLODE;
- case EVENT_COLLECT: return CHANNEL_COLLECT;
-
- default: return 0;
+ for (int i = 0; i < NUM_AUDIO_CHANNELS; i++) {
+ if (!audio_channel_usage[i]) {
+ audio_channel_usage[i] = true;
+ return i;
+ }
}
+ return 0;
}
static Mix_Chunk* get_sample_from_audio_event(audio_event event, u32 playerid) {
@@ -51,6 +51,7 @@ 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_COLLECT: return wav_collect;
case EVENT_BOUNCE_THROWABLE: return wav_throwable_bounce;
case EVENT_FIRE: return wav_fire;
@@ -125,6 +126,10 @@ void play_sound(int channel, Mix_Chunk* wav) {
Mix_PlayChannel(channel, wav, 0);
}
+void audio_channel_finished(int channel) {
+ audio_channel_usage[channel] = false;
+}
+
void play_positioned_sound(int channel, Mix_Chunk* wav, vec3f pos, float max_audible_dist) {
player* p = get_player_by_id(player_id);
if (!p) return;
diff --git a/src/map.c b/src/map.c
index 1eddf90..06ddd25 100644
--- a/src/map.c
+++ b/src/map.c
@@ -213,6 +213,11 @@ void create_empty_map() {
map_to_load.objects[2] = (object){.active = true, .h = 0, .position = (vec2f){0, 1}, .size = (vec3f){1,1,2}, .type = OBJECT_COBBLESTONEWALL1};
map_to_load.objects[3] = (object){.active = true, .h = 0, .position = (vec2f){0, 2}, .size = (vec3f){1,1,2}, .type = OBJECT_COBBLESTONEWALL1};
+ map_to_load.objects[4] = (object){.active = true, .h = 0, .position = (vec2f){14, 8}, .size = (vec3f){1,1,2}, .type = OBJECT_PLANTBOX1};
+ map_to_load.objects[5] = (object){.active = true, .h = 0, .position = (vec2f){14, 12}, .size = (vec3f){1,1,2}, .type = OBJECT_PLANTBOX1};
+ map_to_load.objects[6] = (object){.active = true, .h = 0, .position = (vec2f){16, 10}, .size = (vec3f){1,1,2}, .type = OBJECT_PLANTBOX1};
+ map_to_load.objects[7] = (object){.active = true, .h = 0, .position = (vec2f){14, 14}, .size = (vec3f){1,1,2}, .type = OBJECT_PLANTBOX1};
+
map_to_load.light_emitters[0] = (light_emitter){.brightness = 1.0f, .position = (vec3f){0, 0, 10}, .range = 20.0f, .active = true};
map_to_load.light_emitters[1] = (light_emitter){.brightness = 1.0f, .position = (vec3f){0, 30, 10}, .range = 20.0f, .active = true};
diff --git a/src/rounds.c b/src/rounds.c
index 1cdebd7..7d40493 100644
--- a/src/rounds.c
+++ b/src/rounds.c
@@ -21,6 +21,8 @@ void start_next_round()
_current_round.state = ROUND_SWITCHING;
_current_round.round_timer = 0.0f;
+ add_ui_audio_event_to_queue(EVENT_ROUND_CHANGE);
+
log_infox("Next round: %d", _current_round.round_nr);
}
@@ -41,7 +43,7 @@ void draw_round(platform_window* window) {
char round_text[30];
int window_center_x = _global_camera.x + window->width / 2;
- sprintf(round_text, "ROUND: %d", _current_round.round_nr);
+ 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;
@@ -62,11 +64,17 @@ 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 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));
+ int box_pad = 10;
+ int box_x = window_center_x - (text_w/2)+1 - box_pad;
+ int box_y = final_text_y - box_pad;
+ 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));
}
}
diff --git a/src/zombies.c b/src/zombies.c
index 576fb95..6bb4eb6 100644
--- a/src/zombies.c
+++ b/src/zombies.c
@@ -312,7 +312,7 @@ void draw_zombies(platform_window* window) {
render_quad_with_outline(box.tl_u, box.tl_d, box.bl_u, box.bl_d, rgb(200,200,0));
render_quad_with_outline(box.bl_u, box.br_u, box.bl_d, box.br_d, rgb(200,200,0));
- //if (global_state.server) draw_path_of_zombie(window, o);
+ if (global_state.server) draw_path_of_zombie(window, o);
}
}