diff options
| -rw-r--r-- | build/zombies.exe | bin | 2110640 -> 2110879 bytes | |||
| -rw-r--r-- | include/math_helper.h | 12 | ||||
| -rw-r--r-- | include/players.h | 1 | ||||
| -rw-r--r-- | src/bullets.c | 2 | ||||
| -rw-r--r-- | src/drops.c | 2 | ||||
| -rw-r--r-- | src/map.c | 1 | ||||
| -rw-r--r-- | src/objects.c | 40 | ||||
| -rw-r--r-- | src/overlay.c | 1 | ||||
| -rw-r--r-- | src/players.c | 4 | ||||
| -rw-r--r-- | src/throwables.c | 2 | ||||
| -rw-r--r-- | src/wall_item.c | 3 | ||||
| -rw-r--r-- | src/zombie_chunk.c | 2 | ||||
| -rw-r--r-- | src/zombies.c | 2 |
13 files changed, 12 insertions, 60 deletions
diff --git a/build/zombies.exe b/build/zombies.exe Binary files differindex a3254e3..588716c 100644 --- a/build/zombies.exe +++ b/build/zombies.exe diff --git a/include/math_helper.h b/include/math_helper.h index c0a236a..cdb083f 100644 --- a/include/math_helper.h +++ b/include/math_helper.h @@ -7,14 +7,10 @@ #include "objects.h" #include "map.h" -#define MAP_RENDER_DEPTH renderer->set_render_depth(1); - -#define DROP_RENDER_DEPTH(_h) //renderer->set_render_depth(4 + ceil(_h)); -#define BULLET_RENDER_DEPTH(_h) //renderer->set_render_depth(5 + ceil(_h)); -#define THROWABLE_RENDER_DEPTH(_h) //renderer->set_render_depth(3 + ceil(_h)); -#define PLAYER_RENDER_DEPTH(_h) //renderer->set_render_depth(20 + ceil(_h)); -#define OBJECT_RENDER_DEPTH(_h) //renderer->set_render_depth(50 + ceil(_h)); -#define OVERLAY_RENDER_DEPTH() //renderer->set_render_depth(100); +#define RENDER_DEPTH_MAP 0 +#define RENDER_DEPTH_BEHIND_PLAYER 1 +#define RENDER_DEPTH_PLAYER 2 +#define RENDER_DEPTH_INFRONT_PLAYER 3 bool onSegment(vec2f p, vec2f q, vec2f r); int orientation(vec2f p, vec2f q, vec2f r); diff --git a/include/players.h b/include/players.h index 6aa5b88..5e512c5 100644 --- a/include/players.h +++ b/include/players.h @@ -9,7 +9,6 @@ #include "math_helper.h" #include "guns.h" #include "sprite.h" -#include "../include/players.h" #define MAX_PLAYERS 10 #define MAX_POINT_ANIMATIONS 10 diff --git a/src/bullets.c b/src/bullets.c index 516c34e..fb45cc6 100644 --- a/src/bullets.c +++ b/src/bullets.c @@ -267,8 +267,6 @@ void draw_bullets(platform_window* window) { b.position.z = p->gun_height; } - BULLET_RENDER_DEPTH((int)bullets[i].position.y); - float bullet_render_x = b.position.x*info.tile_width + (b.position.y*info.px_incline); float bullet_render_y = b.position.y*info.tile_height - (b.position.z*info.px_raised_per_h); diff --git a/src/drops.c b/src/drops.c index b97b8be..5bc7cef 100644 --- a/src/drops.c +++ b/src/drops.c @@ -44,8 +44,6 @@ void draw_drops(platform_window* window) { for (int i = 0; i < MAX_DROPS; i++) { drop b = drops[i]; if (!b.active) continue; - - DROP_RENDER_DEPTH((int)(b.position.y)); int alpha = 255; if (b.time_active >= DROP_MAX_DURATION - DROP_FADE_TIME) { @@ -356,7 +356,6 @@ void draw_grid(platform_window* window) { if (y > tilemap_render_max_y) continue; for (int x = 0; x < MAP_SIZE_X; x++) { - MAP_RENDER_DEPTH; if (x < tilemap_render_min_x) continue; if (x > tilemap_render_max_x) continue; diff --git a/src/objects.c b/src/objects.c index fc181c6..38670cc 100644 --- a/src/objects.c +++ b/src/objects.c @@ -56,6 +56,10 @@ object get_object_at_tile(float x, float y) { return (object){0}; } +int sort_objects(const void * obj1, const void* obj2) { + return (((object*)obj1)->position.y - ((object*)obj2)->position.y); +} + void add_object(object obj) { object existing_obj = get_object_at_tile(obj.position.x, obj.position.y); if (existing_obj.active) { @@ -70,6 +74,10 @@ void add_object(object obj) { map_to_load.objects[i].active = true; return; } + + // sort y-axis + qsort(map_to_load.objects, MAX_OBJECTS, sizeof(object), sort_objects); + log_info("Object limit reached."); } @@ -95,7 +103,6 @@ void draw_objects(platform_window* window) { for (int i = 0; i < MAX_OBJECTS; i++) { if (!loaded_map.objects[i].active) continue; object o = loaded_map.objects[i]; - OBJECT_RENDER_DEPTH((int)o.position.y); box box = get_box_of_object(window, o); @@ -104,41 +111,10 @@ void draw_objects(platform_window* window) { renderer->render_image(img, box.tl_u.x, box.tl_u.y, box.br_d.x - box.tl_d.x, box.br_d.y - box.tr_u.y); } - /* - render_quad_with_outline(box.tl_d, box.tr_d, box.bl_d, box.br_d, rgb(200,200,0)); - render_quad_with_outline(box.tl_u, box.tr_u, box.bl_u, box.br_u, rgb(200,200,0)); - 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)); - */ } } void create_objects() { - /* - // rechts naar links op map. - for (int i = MAP_SIZE_X-1; i >= 0; i--) { - create_box(i, 0, 0, OBJECT_COBBLESTONEWALL1); - create_box(i, MAP_SIZE_Y-1, 0, OBJECT_COBBLESTONEWALL1); - } - - for (int i = MAP_SIZE_Y-1; i >= 0; i--) { - create_box(0, i, 0, OBJECT_COBBLESTONEWALL1); - create_box(MAP_SIZE_X-1, i, 0, OBJECT_COBBLESTONEWALL1); - } - - create_box(16, 8, 0, OBJECT_PLANTBOX1); - create_box(14, 8, 0, OBJECT_PLANTBOX1); - create_box(11, 8, 0, OBJECT_PLANTBOX1); - create_box(10, 8, 0, OBJECT_PLANTBOX1); - - create_box(15, 10, 0, OBJECT_PLANTBOX1); - create_box(14, 10, 0, OBJECT_PLANTBOX1); - create_box(13, 10, 0, OBJECT_PLANTBOX1); - create_box(11, 10, 0, OBJECT_PLANTBOX1); - - create_spawner((vec2){15, 5}); - create_spawner((vec2){3, 8}); - */ create_spawner((vec2){11, 18}); create_wallitem((vec3f){14, 1, 0}, WALLITEM_GUN, (wall_item_data){.gun = GUN_NOVA}); }
\ No newline at end of file diff --git a/src/overlay.c b/src/overlay.c index 942b580..4a3b400 100644 --- a/src/overlay.c +++ b/src/overlay.c @@ -157,7 +157,6 @@ void draw_points(platform_window* window) { } void draw_overlay(platform_window* window) { - OVERLAY_RENDER_DEPTH(); draw_gun_info(window); draw_points(window); draw_leaderboard(window); diff --git a/src/players.c b/src/players.c index 52596dc..302c535 100644 --- a/src/players.c +++ b/src/players.c @@ -553,14 +553,10 @@ void draw_players(platform_window* window) { for (int i = 0; i < MAX_PLAYERS; i++) { if (!players[i].active) continue; - float height = get_height_of_tile_under_coords(players[i].playerx, players[i].playery); players[i].height = height; - BULLET_RENDER_DEPTH((int)(players[i].playery+size)); draw_player_bullet_cone(window, &players[i]); - - PLAYER_RENDER_DEPTH((int)(players[i].playery+size)); draw_player(window, &players[i], i); } } diff --git a/src/throwables.c b/src/throwables.c index 518502f..867a762 100644 --- a/src/throwables.c +++ b/src/throwables.c @@ -248,8 +248,6 @@ void draw_throwables(platform_window* window) { throwable t = throwables[i]; if (!t.active) continue; - THROWABLE_RENDER_DEPTH((int)t.position.y); - 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); diff --git a/src/wall_item.c b/src/wall_item.c index cdec496..ef656a6 100644 --- a/src/wall_item.c +++ b/src/wall_item.c @@ -60,8 +60,6 @@ void update_wallitems_server() { static float wallspace_entry_time = 0.0f; void draw_keybinding_for_wallitem_purchase(platform_window* window, wall_item item) { - OVERLAY_RENDER_DEPTH(); - map_info info = get_map_info(window); char purchase_text[50]; @@ -108,7 +106,6 @@ void draw_wallitems(platform_window* window) { if (!item.active) continue; { - OBJECT_RENDER_DEPTH((int)item.position.y); box box = get_render_box_of_square(window, item.position, (vec3f){1,1,2}); renderer->render_image(item.img, box.tl_u.x, box.tl_u.y, box.tr_u.x - box.tl_u.x, box.br_u.y - box.tr_u.y); } diff --git a/src/zombie_chunk.c b/src/zombie_chunk.c index 7073b37..fea1ce3 100644 --- a/src/zombie_chunk.c +++ b/src/zombie_chunk.c @@ -93,8 +93,6 @@ void draw_zombie_chunks(platform_window* window) { for (int i = 0; i < MAX_ZOMBIE_CHUNKS; i++) { if (!zombie_chunks[i].active) continue; - - DROP_RENDER_DEPTH((int)(zombie_chunks[i].position.y)); int alpha = 255; if (zombie_chunks[i].duration >= CHUNK_MAX_DURATION - CHUNK_FADE_TIME) { diff --git a/src/zombies.c b/src/zombies.c index 95c5827..c7d4c2d 100644 --- a/src/zombies.c +++ b/src/zombies.c @@ -310,8 +310,6 @@ void draw_zombies(platform_window* window) { zombie o = zombies[i]; if (!o.alive) continue; - OBJECT_RENDER_DEPTH((int)o.position.y); - box box = get_render_box_of_square(window, (vec3f){o.position.x, o.position.y, o.position.z}, o.size); render_quad_with_outline(box.tl_d, box.tr_d, box.bl_d, box.br_d, rgb(200,200,0)); render_quad_with_outline(box.tl_u, box.tr_u, box.bl_u, box.br_u, rgb(200,200,0)); |
