diff options
| -rw-r--r-- | build.zip | bin | 16555725 -> 0 bytes | |||
| -rw-r--r-- | data/maps/map1.dat | bin | 8322408 -> 8322408 bytes | |||
| -rw-r--r-- | include/objects.h | 7 | ||||
| -rw-r--r-- | include/players.h | 2 | ||||
| -rw-r--r-- | include/zombies.h | 2 | ||||
| -rw-r--r-- | src/drops.c | 4 | ||||
| -rw-r--r-- | src/editor.c | 8 | ||||
| -rw-r--r-- | src/game.c | 12 | ||||
| -rw-r--r-- | src/map.c | 2 | ||||
| -rw-r--r-- | src/objects.c | 40 | ||||
| -rw-r--r-- | src/pathfinding.c | 1 | ||||
| -rw-r--r-- | src/players.c | 3 | ||||
| -rw-r--r-- | src/wall_item.c | 2 | ||||
| -rw-r--r-- | src/zombie_chunk.c | 2 | ||||
| -rw-r--r-- | src/zombies.c | 10 |
15 files changed, 58 insertions, 37 deletions
diff --git a/build.zip b/build.zip Binary files differdeleted file mode 100644 index ae1f86d..0000000 --- a/build.zip +++ /dev/null diff --git a/data/maps/map1.dat b/data/maps/map1.dat Binary files differindex 0b01ded..90f5b7d 100644 --- a/data/maps/map1.dat +++ b/data/maps/map1.dat diff --git a/include/objects.h b/include/objects.h index 4444253..ef53d78 100644 --- a/include/objects.h +++ b/include/objects.h @@ -49,7 +49,7 @@ typedef struct t_box { // @NEWOBJECT object object_dict[OBJECT_END] = { - {0,(vec3f){0, 0, 0},{1,3,1},OBJECT_SPACE_CONTROL_PANEL}, + {0,(vec3f){0, 0, 0},{1,3,0.5f},OBJECT_SPACE_CONTROL_PANEL}, {0,(vec3f){0, 0, 0},{1,1,2},OBJECT_SPACE_WINDOW}, {0,(vec3f){0, 0, 0},{1,1,1},OBJECT_METAL_WALL}, {0,(vec3f){0, 0, 0},{1,1,1},OBJECT_METAL_WALL2}, @@ -62,7 +62,8 @@ void create_objects(); void add_object(object obj); void draw_objects(platform_window* window); box get_box_of_object(platform_window* window, object o); -void render_quad_with_outline(vec2f tl, vec2f tr, vec2f bl, vec2f br, color c); -void render_box_with_outline(box box, color c); +void render_fill_quad_with_outline(vec2f tl, vec2f tr, vec2f bl, vec2f br, color c); +void render_fill_box_with_outline(box box, color c); +void render_box_outline(box box, color c); #endif
\ No newline at end of file diff --git a/include/players.h b/include/players.h index ccf91b9..d97b978 100644 --- a/include/players.h +++ b/include/players.h @@ -100,7 +100,7 @@ player players[MAX_PLAYERS] = {0}; int get_player_count(); player* get_player_by_id(u32 id); -void draw_players(platform_window* window); +void draw_players(platform_window* window, uint32_t ystart, uint32_t yend); void draw_bullets(platform_window* window); object check_if_player_collided_with_object(player p); float get_player_size(platform_window* window); diff --git a/include/zombies.h b/include/zombies.h index ec80135..5c6d252 100644 --- a/include/zombies.h +++ b/include/zombies.h @@ -52,7 +52,7 @@ zombie zombies[SERVER_MAX_ZOMBIES] = {0}; bool hit_zombie(int index, int damage); void create_spawner(vec2 position); void draw_spawners(platform_window* window); -void draw_zombies(platform_window* window); +void draw_zombies(platform_window* window, uint32_t ystart, uint32_t yend); void spawn_zombie(int x, int y); u32 number_of_zombies_active(); diff --git a/src/drops.c b/src/drops.c index 5bc7cef..8db2e88 100644 --- a/src/drops.c +++ b/src/drops.c @@ -56,11 +56,11 @@ void draw_drops(platform_window* window) { b.position.y += 0.2f; b.position.x -= 0.07f; box shadow_box = get_render_box_of_square(window, b.position, b.size); - render_box_with_outline(shadow_box, rgba(0,0,0,alpha * (120.0f/255.0f))); + render_fill_box_with_outline(shadow_box, rgba(0,0,0,alpha * (120.0f/255.0f))); b = drops[i]; box full_box = get_render_box_of_square(window, b.position, b.size); - //render_box_with_outline(full_box, rgba(218,112,214, alpha)); + //render_fill_box_with_outline(full_box, rgba(218,112,214, alpha)); renderer->render_image_tint(img_drop, 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, rgba(218,112,214, alpha)); diff --git a/src/editor.c b/src/editor.c index c506cbc..de9a33f 100644 --- a/src/editor.c +++ b/src/editor.c @@ -143,10 +143,10 @@ void draw_placing_rectangle(platform_window* window) { tile t = loaded_map.heightmap[mouse_tile_y][mouse_tile_x]; box box = get_render_box_of_square(window, (vec3f){mouse_tile_x, mouse_tile_y, 0}, (vec3f){1,1,t.height}); - render_quad_with_outline(box.tl_d, box.tr_d, box.bl_d, box.br_d, rgba(255,0,0, 70)); - render_quad_with_outline(box.tl_u, box.tr_u, box.bl_u, box.br_u, rgba(255,0,0, 70)); - render_quad_with_outline(box.tl_u, box.tl_d, box.bl_u, box.bl_d, rgba(255,0,0, 70)); - render_quad_with_outline(box.bl_u, box.br_u, box.bl_d, box.br_d, rgba(255,0,0, 70)); + render_fill_quad_with_outline(box.tl_d, box.tr_d, box.bl_d, box.br_d, rgba(255,0,0, 70)); + render_fill_quad_with_outline(box.tl_u, box.tr_u, box.bl_u, box.br_u, rgba(255,0,0, 70)); + render_fill_quad_with_outline(box.tl_u, box.tl_d, box.bl_u, box.bl_d, rgba(255,0,0, 70)); + render_fill_quad_with_outline(box.bl_u, box.br_u, box.bl_d, box.br_d, rgba(255,0,0, 70)); } static bool push_icon_button(int x, int y, int w, image* img, bool isSelected) { @@ -385,22 +385,12 @@ void update_game(platform_window* window) { take_player_input(window); draw_grid(window); + draw_objects(window); draw_wallitems(window); draw_zombie_chunks(window); draw_drops(window); draw_bullets(window); draw_throwables(window); - - #ifdef MODE_DEBUG - if (!is_editing_map) - #endif - draw_zombies(window); - - #ifdef MODE_DEBUG - if (!is_editing_map) - #endif - - draw_players(window); draw_round(window); draw_spawners(window); draw_overlay(window); @@ -434,8 +434,6 @@ void draw_grid(platform_window* window) { loaded_map.heightmap[y][x].br = bottomright; } } - - draw_objects(window); } inline map_info get_map_info(platform_window* window) { diff --git a/src/objects.c b/src/objects.c index 213879c..d5dc0ce 100644 --- a/src/objects.c +++ b/src/objects.c @@ -5,17 +5,32 @@ box get_box_of_object(platform_window* window, object o) { return get_render_box_of_square(window, (vec3f){o.position.x, o.position.y, o.position.z}, o.size); } -void render_box_with_outline(box box, color c) { - render_quad_with_outline(box.tl_d, box.tr_d, box.bl_d, box.br_d, c); // down - render_quad_with_outline(box.tl_u, box.tr_u, box.bl_u, box.br_u, c); // up +void render_fill_box_with_outline(box box, color c) { + render_fill_quad_with_outline(box.tl_d, box.tr_d, box.bl_d, box.br_d, c); // down + render_fill_quad_with_outline(box.tl_u, box.tr_u, box.bl_u, box.br_u, c); // up - render_quad_with_outline(box.tr_u, box.tr_d, box.br_u, box.br_d, c); // right - render_quad_with_outline(box.tl_u, box.tl_d, box.bl_u, box.bl_d, c); // left - render_quad_with_outline(box.bl_u, box.br_u, box.bl_d, box.br_d, c); // bottom + render_fill_quad_with_outline(box.tr_u, box.tr_d, box.br_u, box.br_d, c); // right + render_fill_quad_with_outline(box.tl_u, box.tl_d, box.bl_u, box.bl_d, c); // left + render_fill_quad_with_outline(box.bl_u, box.br_u, box.bl_d, box.br_d, c); // bottom } -void render_quad_with_outline(vec2f tl, vec2f tr, vec2f bl, vec2f br, color c) { +void render_quad_outline(vec2f tl, vec2f tr, vec2f bl, vec2f br, color c) { + renderer->render_line(tl.x, tl.y, tr.x, tr.y, 1, rgba(0,0,255, c.a)); // top + renderer->render_line(tl.x, tl.y, bl.x, bl.y, 1, rgba(0,0,255, c.a)); // left + renderer->render_line(tr.x, tr.y, br.x, br.y, 1, rgba(0,0,255, c.a)); // right + renderer->render_line(bl.x, bl.y, br.x, br.y, 1, rgba(0,0,255, c.a)); // bottom +} +void render_box_outline(box box, color c) { + render_quad_outline(box.tl_d, box.tr_d, box.bl_d, box.br_d, c); // down + render_quad_outline(box.tl_u, box.tr_u, box.bl_u, box.br_u, c); // up + + render_quad_outline(box.tr_u, box.tr_d, box.br_u, box.br_d, c); // right + render_quad_outline(box.tl_u, box.tl_d, box.bl_u, box.bl_d, c); // left + render_quad_outline(box.bl_u, box.br_u, box.bl_d, box.br_d, c); // bottom +} + +void render_fill_quad_with_outline(vec2f tl, vec2f tr, vec2f bl, vec2f br, color c) { renderer->render_quad( tl.x, tl.y, bl.x, bl.y, @@ -97,6 +112,7 @@ image* get_image_from_objecttype(object_type tile) { void draw_objects(platform_window* window) { map_info info = get_map_info(window); + uint32_t prev_y = 0; for (int i = 0; i < MAX_OBJECTS; i++) { if (!loaded_map.objects[i].active) continue; object o = loaded_map.objects[i]; @@ -108,7 +124,17 @@ 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_box_outline(box, rgb(255,0,0)); + + if (prev_y < o.position.y) { + prev_y = o.position.y; + draw_zombies(window, prev_y, prev_y); + draw_players(window, prev_y, prev_y); + } } + + draw_zombies(window, prev_y, MAP_SIZE_Y); + draw_players(window, prev_y, MAP_SIZE_Y); } void create_objects() { diff --git a/src/pathfinding.c b/src/pathfinding.c index 70b084b..939adbe 100644 --- a/src/pathfinding.c +++ b/src/pathfinding.c @@ -219,6 +219,7 @@ bool find_path_to(vec2f start_pos, vec2f end_pos, array *to_fill, pathfinding_re vec2f get_open_tile_next_to_target(float x, float y) { vec2f adjecent[8] = { {0, -1}, {0, 1}, {-1, 0}, {1, 0}, {-1, -1}, {-1, 1}, {1, -1}, {1, 1} }; + //vec2f adjecent[4] = { {0, -1}, {0, 1}, {-1, 0}, {1, 0}}; vec2f v_s; v_s.x = x; diff --git a/src/players.c b/src/players.c index cb7842e..2454c28 100644 --- a/src/players.c +++ b/src/players.c @@ -603,11 +603,12 @@ void draw_player(platform_window* window, player* p, int index) { } } -void draw_players(platform_window* window) { +void draw_players(platform_window* window, uint32_t ystart, uint32_t yend) { float size = get_player_size_in_tile(); for (int i = 0; i < MAX_PLAYERS; i++) { if (!players[i].active) continue; + if (!((int)players[i].playery >= ystart && (int)players[i].playery <= yend+1)) continue; float height = get_height_of_tile_under_coords(players[i].playerx, players[i].playery); players[i].height = height; diff --git a/src/wall_item.c b/src/wall_item.c index ef656a6..12b5ce7 100644 --- a/src/wall_item.c +++ b/src/wall_item.c @@ -80,7 +80,7 @@ void draw_keybinding_for_wallitem_purchase(platform_window* window, wall_item it key_box.tl_u.y -= KEY_INSET; key_box.bl_u.y -= KEY_INSET; key_box.tr_u.x -= KEY_INSET; key_box.br_u.x -= KEY_INSET; key_box.tr_u.y -= KEY_INSET; key_box.br_u.y -= KEY_INSET; - render_box_with_outline(key_box, rgb(255,255,255)); + render_fill_box_with_outline(key_box, rgb(255,255,255)); int surface_w = key_box.tr_u.x - key_box.tl_u.x; int surface_h = key_box.br_u.y - key_box.tr_u.y; diff --git a/src/zombie_chunk.c b/src/zombie_chunk.c index fea1ce3..87cb65f 100644 --- a/src/zombie_chunk.c +++ b/src/zombie_chunk.c @@ -101,7 +101,7 @@ void draw_zombie_chunks(platform_window* window) { if (alpha < 0) alpha = 0; box box = get_render_box_of_square(window, zombie_chunks[i].position, (vec3f){0.6f, 0.6f, 0.6f}); - //render_box_with_outline(box, rgba(200, 50, 50, alpha)); + //render_fill_box_with_outline(box, rgba(200, 50, 50, alpha)); renderer->render_set_rotation(zombie_chunks[i].rotation); renderer->render_image_tint(get_chunk_image_from_type(zombie_chunks[i].type), box.tl_d.x, box.tl_d.y, box.tr_d.x - box.tl_d.x, box.br_d.y - box.tr_d.y, rgba(255,255,255,alpha)); diff --git a/src/zombies.c b/src/zombies.c index c128a0c..04253b8 100644 --- a/src/zombies.c +++ b/src/zombies.c @@ -430,17 +430,21 @@ void update_zombies_server(platform_window* window) { } } -void draw_zombies(platform_window* window) { +void draw_zombies(platform_window* window, uint32_t ystart, uint32_t yend) { map_info info = get_map_info(window); for (int i = 0; i < SERVER_MAX_ZOMBIES; i++) { zombie o = zombies[i]; if (!o.alive) continue; + if (!((int)o.position.y >= ystart && (int)o.position.y <= yend+1)) continue; + + float zombie_size = o.size.x * get_tile_width(window); + o.position.x -=o.size.x/2.0f; + o.position.y -=o.size.x/2.0f; sprite_frame frame = sprite_get_frame(img_alien_run, &o.sprite_run); box box = get_render_box_of_square(window, (vec3f){o.position.x, o.position.y, o.position.z}, o.size); vec2f zombie_pos = world_pos_to_screen_pos(window, o.position.x, o.position.y, o.position.z); - float zombie_size = o.size.x * get_tile_width(window); float rads = -atan2(o.dir.x, o.dir.y); if (rads >= 0.0f) { @@ -472,7 +476,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); } } |
