summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/asset_defs.c4
-rw-r--r--src/game.c10
-rw-r--r--src/overlay.c39
-rw-r--r--src/zombies.c4
4 files changed, 49 insertions, 8 deletions
diff --git a/src/asset_defs.c b/src/asset_defs.c
index 45a248f..1440e48 100644
--- a/src/asset_defs.c
+++ b/src/asset_defs.c
@@ -32,6 +32,9 @@ void load_menu_assets() { // Assets loaded at game start
void load_assets() { // Assets loaded at match start.
// UI
img_red_border = assets_load_image_from_file("data/imgs/ui/red_border.png");
+ img_heart = assets_load_image_from_file("data/imgs/ui/heart.png");
+ img_hurt_overlay_left = assets_load_image_from_file("data/imgs/ui/hurt_overlay_left.png");
+ img_hurt_overlay_right = assets_load_image_from_file("data/imgs/ui/hurt_overlay_right.png");
// Icons
img_icon_bullets = assets_load_image_from_file("data/imgs/bullets.png");
@@ -195,6 +198,7 @@ void load_assets() { // Assets loaded at match start.
wav_roar_enraged = Mix_LoadWAV("data/sounds/roar_enraged.wav");
wav_door_open = Mix_LoadWAV("data/sounds/door_open.wav");
wav_door_close = Mix_LoadWAV("data/sounds/door_close.wav");
+ wav_heartbeat = Mix_LoadWAV("data/sounds/heartbeat.wav");
for (int i = 1; i <= NUM_SCREECHES; i++) {
char path[100];
diff --git a/src/game.c b/src/game.c
index 6081df1..de62746 100644
--- a/src/game.c
+++ b/src/game.c
@@ -107,8 +107,13 @@ void load_map() {
pathfinding_init();
- thread t = thread_start(pathfinding_thread, 0);
- thread_detach(&t);
+ // TODO: only need this on server?
+ thread t1 = thread_start(pathfinding_thread, 0);
+ thread_detach(&t1);
+ thread t2 = thread_start(pathfinding_thread, 0);
+ thread_detach(&t2);
+ thread t3 = thread_start(pathfinding_thread, 0);
+ thread_detach(&t3);
log_info("STATE: GAMESTATE_LOADING_ASSETS");
global_state.state = GAMESTATE_LOADING_ASSETS;
@@ -148,6 +153,7 @@ static void rotate_user(platform_window* window, protocol_user_look *message) {
log_info("Unknown user rotated");
return;
}
+ if (p->interact_state == INTERACT_DEAD) return;
p->gunx = p->playerx + message->gunx;
p->guny = p->playery - 0.5f + message->guny;
diff --git a/src/overlay.c b/src/overlay.c
index 2dfbb9c..75c465a 100644
--- a/src/overlay.c
+++ b/src/overlay.c
@@ -111,11 +111,11 @@ void draw_debug_stats(platform_window* window) {
count++;
}
- char fps_text[50];
- snprintf(fps_text, 50, "FPS: %d, MS: %.4f, USAGE: %.0f%%", (int)fps, update_delta*1000.0f, usage);
+ char fps_text[100];
+ snprintf(fps_text, 100, "FPS: %d, MS: %.4f, USAGE: %.0f%%", (int)fps, update_delta*1000.0f, usage);
- char update_text[50];
- snprintf(update_text, 50, "update: %.2fms, queue: %d", logic_update_time/1000000.0f, count);
+ char update_text[100];
+ snprintf(update_text, 100, "update: %.2fms, tcp queue: %d, pathfinding queue: %d", logic_update_time/1000000.0f, count, global_pathfinding_queue.length);
renderer->render_text(fnt_20, _global_camera.x, _global_camera.y + fnt_20->px_h*0, fps_text, rgb(0,0,0));
renderer->render_text(fnt_20, _global_camera.x, _global_camera.y + fnt_20->px_h*1, update_text, rgb(0,0,0));
@@ -160,6 +160,36 @@ static void draw_hurt_borders(platform_window* window) {
player* p = get_player_by_id(player_id);
if (!p) return;
+ if (p->max_health == p->health) return;
+ if (p->health == 0) return;
+
+ float freq = 1.0f * (p->health/(float)p->max_health);
+ static float heatbeat_timestamp = 0.0f;
+ heatbeat_timestamp += update_delta;
+
+ float opacity = 1.0f - (heatbeat_timestamp / freq);
+ int heart_size = window->width / 7;
+ color c = rgba(255,255,255,255*opacity);
+
+ renderer->render_image_tint(img_heart,
+ _global_camera.x + (window->width/2)-(heart_size/2),
+ _global_camera.y + (window->height/2)-(heart_size/2), heart_size, heart_size, c);
+
+ if (heatbeat_timestamp >= freq) {
+ heatbeat_timestamp = 0.0f;
+ play_sound(-1, wav_heartbeat);
+ }
+
+ float border_opacity = 1.0f - (p->health/(float)p->max_health);
+ int hurt_border_width = window->width / (6 - (border_opacity*3));
+ color border_color = rgba(255,255,255,255*border_opacity);
+
+ renderer->render_image_tint(img_hurt_overlay_left, _global_camera.x,
+ _global_camera.y, hurt_border_width, window->height, border_color);
+ renderer->render_image_tint(img_hurt_overlay_right, _global_camera.x + window->width - hurt_border_width,
+ _global_camera.y, hurt_border_width, window->height, border_color);
+
+ /*
int width = window->width * 0.1f;
float opacity = 1.0f - (p->health/(float)p->max_health);
if (opacity < 0.0f) opacity = 0.0f;
@@ -196,6 +226,7 @@ static void draw_hurt_borders(platform_window* window) {
_global_camera.x + window->width, _global_camera.y + window->height,
_global_camera.x + window->width, _global_camera.y + window->height - width,
top.tl, top.tr, top.bl, top.br, c);
+ */
}
void draw_overlay(platform_window* window) {
diff --git a/src/zombies.c b/src/zombies.c
index 3bad715..9826ec2 100644
--- a/src/zombies.c
+++ b/src/zombies.c
@@ -191,7 +191,7 @@ static void despawn_far_zombies_server()
float dist = 0.0f;
player p = get_closest_player_to_tile_x(o.position.x, o.position.y, &dist);
- if (dist >= MAX_DISTANCE_BETWEEN_ZOMBIE_AND_PLAYER)
+ if (dist >= MAX_DISTANCE_BETWEEN_ZOMBIE_AND_PLAYER && p.id != -1)
{
zombies[i].alive = 0;
_current_round.zombies++;
@@ -213,7 +213,7 @@ void update_spawners_server() {
float dist = 0.0f;
player p = get_closest_player_to_tile_x(spawner.position.x, spawner.position.y, &dist);
- if (dist >= MAX_DISTANCE_BETWEEN_ZOMBIE_AND_PLAYER) {
+ if (dist >= MAX_DISTANCE_BETWEEN_ZOMBIE_AND_PLAYER && p.id != -1) {
continue;
}