summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/audio.c5
-rw-r--r--src/math_helper.c4
-rw-r--r--src/zombies.c2
3 files changed, 9 insertions, 2 deletions
diff --git a/src/audio.c b/src/audio.c
index 43a403d..e831f6b 100644
--- a/src/audio.c
+++ b/src/audio.c
@@ -35,7 +35,7 @@ void add_audio_event_to_queue(audio_event_type event, u32 playerid, vec3f positi
}
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});
+ add_object_audio_event_to_queue(event, OBJECT_NONE, -1, global_audio_source_position);
}
static Mix_Chunk* get_sample_from_audio_event(audio_event event, u32 playerid) {
@@ -158,6 +158,8 @@ void play_positioned_sound(int channel, Mix_Chunk* wav, vec3f pos, float max_aud
// calculate volume
int tiles_between_throwable_and_player = distance_between_3f((vec3f){.x = p->playerx, .y = p->playery, .z = p->height}, pos);
+ if (vec3f_equals(pos, global_audio_source_position)) tiles_between_throwable_and_player = 0; // Global audio source.
+
float volume = (tiles_between_throwable_and_player / max_audible_dist);
if (volume > 1.0f) volume = 1.0f;
if (volume < 0.0f) volume = 0.0f;
@@ -173,5 +175,6 @@ void play_positioned_sound(int channel, Mix_Chunk* wav, vec3f pos, float max_aud
*/
int c = Mix_PlayChannel(-1, wav, 0);
+ if (c == -1) log_info("Audio not playable because no channels are free");
Mix_SetPosition(c, 0, (int)(volume*255));
}
diff --git a/src/math_helper.c b/src/math_helper.c
index 900b8aa..cb38861 100644
--- a/src/math_helper.c
+++ b/src/math_helper.c
@@ -108,6 +108,10 @@ box get_box_of_square(vec3f position, vec3f size) {
return (box){rendertl, rendertr, renderbl, renderbr, rendertl, rendertr, renderbl, renderbr};
}
+bool vec3f_equals(vec3f p1, vec3f p2) {
+ return p1.x == p2.x && p1.y == p2.y && p1.z == p2.z;
+}
+
box get_render_box_of_square_without_incline(platform_window* window, vec3f position, vec3f size) {
map_info info = get_map_info(window);
float render_x = (info.tile_width * position.x);
diff --git a/src/zombies.c b/src/zombies.c
index 8ebf1b1..aa108b3 100644
--- a/src/zombies.c
+++ b/src/zombies.c
@@ -434,7 +434,7 @@ void draw_zombies(platform_window* window) {
renderer->render_rectangle(zombie_pos.x + (zombie_size/2) - (bar_w/2), zombie_pos.y - bar_h, bar_w*percentage, bar_h, rgb(100,0,0));
}
- if (global_state.server) draw_path_of_zombie(window, o);
+ //if (global_state.server) draw_path_of_zombie(window, o);
}
}