diff options
| -rw-r--r-- | build/zombies.exe | bin | 1655018 -> 1657718 bytes | |||
| -rw-r--r-- | bullets.c | 155 | ||||
| -rw-r--r-- | include/bullets.h | 23 | ||||
| -rw-r--r-- | include/map.h | 2 | ||||
| -rw-r--r-- | include/math_helper.h | 21 | ||||
| -rw-r--r-- | include/players.h | 13 | ||||
| -rw-r--r-- | main.c | 5 | ||||
| -rw-r--r-- | map.c | 15 | ||||
| -rw-r--r-- | math_helper.c | 102 | ||||
| -rw-r--r-- | objects.c | 25 | ||||
| -rw-r--r-- | players.c | 159 | ||||
| -rw-r--r-- | project-base.code-workspace | 4 | ||||
| -rw-r--r-- | zombies.c | 4 |
13 files changed, 333 insertions, 195 deletions
diff --git a/build/zombies.exe b/build/zombies.exe Binary files differindex 30bfe17..43a02d4 100644 --- a/build/zombies.exe +++ b/build/zombies.exe diff --git a/bullets.c b/bullets.c new file mode 100644 index 0000000..0b35e12 --- /dev/null +++ b/bullets.c @@ -0,0 +1,155 @@ +#include "include/bullets.h" + +void shoot(platform_window* window) { + map_info info = get_map_info(window); + float bullet_range = 100.0f; + + float hh = get_height_of_tile_under_coords(window, playerx, playery); + + float dirx = (_global_mouse.x - (window->width/2)); + float diry = (_global_mouse.y - (window->height/2)); + double length = sqrt(dirx * dirx + diry * diry); + dirx /= length; + diry /= length; + + float bulletx = playerx + (get_player_size_in_tile()/2); + float bullety = playery + (get_player_size_in_tile()/2); + float bullet_end_point_x = bulletx+dirx*bullet_range; + float bullet_end_point_y = bullety+diry*bullet_range; + + for (int i = 0; i < max_bullets; i++) { + bullet b = bullets[i]; + if (b.active) continue; + + bullets[i] = (bullet){true, bulletx, bullety, hh + 0.5, bullet_end_point_x, bullet_end_point_y}; + break; + } +} + +bool check_if_bullet_collided_with_section(bullet* b, float* dist_of_closest_intersect, vec2f bstart, vec2f bend, vec2f l1, vec2f l2) { + if (lines_intersect(bstart, bend, l1, l2)) { + vec2f intersect_point = get_intersection_point(bstart, bend, l1, l2); + + float dirx = (bstart.x - intersect_point.x); + float diry = (bstart.y - intersect_point.y); + double length_of_shot = sqrt(dirx * dirx + diry * diry); + + if (length_of_shot > *dist_of_closest_intersect) { + return false; + } + *dist_of_closest_intersect = length_of_shot; + + b->endy = intersect_point.y; + b->endx = intersect_point.x; + return true; + } + return false; +} + +bool check_if_bullet_collided_with_object(bullet* b, platform_window* window) { + map_info info = get_map_info(window); + float size = get_bullet_size_in_tile(window); + + vec2f bstart = (vec2f){b->position.x, b->position.y}; + vec2f bend = (vec2f){b->endx, b->endy}; + + bool result = false; + float dist_of_closest_intersect = __FLT_MAX__; + + for (int i = 0; i < max_objects; i++) { + object o = objects[i]; + if (!o.active) continue; + if (b->position.z <= o.h + o.size.z && b->position.z >= o.h) { + box obj_box = get_box_of_square(window, (vec3f){o.position.x, o.position.y, o.h}, o.size); + if (check_if_bullet_collided_with_section(b, &dist_of_closest_intersect, bstart, bend, obj_box.bl_b, obj_box.br_b)) { + result = true; + } + if (check_if_bullet_collided_with_section(b, &dist_of_closest_intersect, bstart, bend, obj_box.tl_b, obj_box.tr_b)) { + result = true; + } + if (check_if_bullet_collided_with_section(b, &dist_of_closest_intersect, bstart, bend, obj_box.tl_b, obj_box.bl_b)) { + result = true; + } + if (check_if_bullet_collided_with_section(b, &dist_of_closest_intersect, bstart, bend, obj_box.tr_b, obj_box.br_b)) { + result = true; + } + } + } + + return result; +} + +bool check_if_bullet_collided_with_zombie(bullet b, platform_window* window, bool kill_if_collided) { + map_info info = get_map_info(window); + float size = get_bullet_size_in_tile(window); + + for (int i = 0; i < max_zombies; i++) { + zombie o = zombies[i]; + if (!o.alive) continue; + + vec2f bstart = (vec2f){b.position.x, b.position.y}; + vec2f bend = (vec2f){b.endx, b.endy}; + + if (b.position.z <= o.position.z + o.size.z && b.position.z >= o.position.z) { + if (lines_intersect(bstart, bend, (vec2f){o.position.x, o.position.y+o.size.y}, (vec2f){o.position.x+o.size.x, o.position.y+o.size.y}) || // bottom + lines_intersect(bstart, bend, (vec2f){o.position.x, o.position.y}, (vec2f){o.position.x+o.size.x, o.position.y}) || // top + lines_intersect(bstart, bend, (vec2f){o.position.x, o.position.y}, (vec2f){o.position.x, o.position.y+o.size.y}) || // left + lines_intersect(bstart, bend, (vec2f){o.position.x+o.size.x, o.position.y}, (vec2f){o.position.x+o.size.x, o.position.y+o.size.y})) // right + { + if (kill_if_collided) { + zombies[i].alive = false; + } + return true; + } + } + } + + return false; +} + +void draw_bullets(platform_window* window) { + float size = get_bullet_size(window); + map_info info = get_map_info(window); + + for (int i = 0; i < max_bullets; i++) { + bullet b = bullets[i]; + if (!b.active) continue; + + /* + if (is_in_bounds(window, b.position.x, b.position.y)) { + tile t = get_tile_under_coords(window, b.position.x, b.position.y); + + float h = get_height_of_tile_under_coords(window, bullets[i].position.x, bullets[i].position.y); + if (h >= b.position.z) { + bullets[i].active = false; // hit the ground. + } + } + else { + bullets[i].active = false; + }*/ + + if (check_if_bullet_collided_with_object(&b, window)) { + bullets[i].endy = b.endy; + bullets[i].endx = b.endx; + } + + if (check_if_bullet_collided_with_zombie(b, window, true)) { + bullets[i].active = false; + } + + bullets[i].alive_time += update_delta; + if (bullets[i].alive_time > 0.03f) bullets[i].active = false; + + if (!b.active) continue; + + BULLET_RENDER_DEPTH(b.position.z); + + 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); + + float bullet_render_x_end = b.endx*info.tile_width + (b.endy*info.px_incline); + float bullet_render_y_end = b.endy*info.tile_height - (b.position.z*info.px_raised_per_h); + + renderer->render_line(bullet_render_x, bullet_render_y, bullet_render_x_end, bullet_render_y_end, 2, rgb(0,255,100)); + } +}
\ No newline at end of file diff --git a/include/bullets.h b/include/bullets.h new file mode 100644 index 0000000..e8ddb86 --- /dev/null +++ b/include/bullets.h @@ -0,0 +1,23 @@ +#ifndef INCLUDE_BULLETS +#define INCLUDE_BULLETS + +#include <projectbase/project_base.h> + +#include "players.h" +#include "objects.h" +#include "map.h" + +typedef struct t_bullet { + bool active; + vec3f position; + float endx; + float endy; + float alive_time; +} bullet; + +bullet bullets[500] = {0}; +int max_bullets = 500; + +void draw_bullets(platform_window* window); + +#endif
\ No newline at end of file diff --git a/include/map.h b/include/map.h index 735c106..80772b1 100644 --- a/include/map.h +++ b/include/map.h @@ -31,7 +31,7 @@ typedef struct t_map_info { int tile_width; int tile_height; int px_raised_per_h; - int px_incline; + float px_incline; } map_info; // data data that is stored on disk diff --git a/include/math_helper.h b/include/math_helper.h new file mode 100644 index 0000000..1b84ebf --- /dev/null +++ b/include/math_helper.h @@ -0,0 +1,21 @@ +#ifndef INCLUDE_MATH_HELPER +#define INCLUDE_MATH_HELPER + +#include <projectbase/project_base.h> + +#include "players.h" +#include "objects.h" +#include "map.h" + +#define MAP_RENDER_DEPTH renderer->set_render_depth(1); +#define BULLET_RENDER_DEPTH(_h) renderer->set_render_depth(4 + ceil(_h)); +#define OBJECT_RENDER_DEPTH(_h) renderer->set_render_depth(5 + ceil(_h)); + +bool onSegment(vec2f p, vec2f q, vec2f r); +int orientation(vec2f p, vec2f q, vec2f r); +bool lines_intersect(vec2f p1, vec2f q1, vec2f p2, vec2f q2); +vec2f get_intersection_point(vec2f A, vec2f B, vec2f C, vec2f D); +box get_render_box_of_square(platform_window* window, vec3f position, vec3f size); +box get_box_of_square(platform_window* window, vec3f position, vec3f size); + +#endif
\ No newline at end of file diff --git a/include/players.h b/include/players.h index 844cb17..ef94489 100644 --- a/include/players.h +++ b/include/players.h @@ -5,17 +5,8 @@ #include "map.h" #include "objects.h" - -typedef struct t_bullet { - bool active; - vec3f position; - float endx; - float endy; - float alive_time; -} bullet; - -bullet bullets[500] = {0}; -int max_bullets = 500; +#include "zombies.h" +#include "math_helper.h" float sec_since_last_shot = 10.0f; float playerx = 3; @@ -4,11 +4,15 @@ #include "include/objects.h" #include "include/map.h" #include "include/zombies.h" +#include "include/math_helper.h" +#include "include/bullets.h" #include "map.c" #include "players.c" #include "objects.c" #include "zombies.c" +#include "bullets.c" +#include "math_helper.c" #define CONFIG_DIRECTORY "zombieshooter" @@ -17,7 +21,6 @@ void update_func(platform_window* window) { draw_grid(window); draw_spawners(window); - draw_bullets(window); } void resize_func(platform_window* window, u32 change_x,u32 change_y) { @@ -155,7 +155,8 @@ inline int get_tile_height(platform_window* window) { bool is_in_bounds(platform_window* window, float x, float y) { int tile_width = get_tile_width(window); int tile_height = get_tile_height(window); - int xdiff_between_bottom_and_top = tile_width/3; + map_info info = get_map_info(window); + int xdiff_between_bottom_and_top = info.px_incline; return (x >= 0 && x <= MAP_SIZE_X && y >= 0 && y < MAP_SIZE_Y); } @@ -163,10 +164,11 @@ void draw_grid(platform_window* window) { map_info info = get_map_info(window); for (int y = 0; y < MAP_SIZE_Y; y++) { + MAP_RENDER_DEPTH; for (int x = MAP_SIZE_X-1; x >= 0; x--) { tile tile = map_loaded[y][x]; - int xdiff_between_bottom_and_top = info.tile_width/3; + int xdiff_between_bottom_and_top = info.px_incline; int render_x = (info.tile_width * x) + (xdiff_between_bottom_and_top * y); int render_y = info.tile_height * y; render_y -= tile.height*info.px_raised_per_h; @@ -231,6 +233,15 @@ void draw_grid(platform_window* window) { } inline map_info get_map_info(platform_window* window) { + /* + static float offset = 0.0f; + static bool dir = true; + if (dir) offset += 0.00001f; + else offset -= 0.00001f; + if (offset >= 0.5f) dir = false; + if (offset <= -0.5f) dir = true; + */ + map_info info; info.tile_width = get_tile_width(window); info.tile_height = get_tile_height(window); diff --git a/math_helper.c b/math_helper.c new file mode 100644 index 0000000..b6e0cb3 --- /dev/null +++ b/math_helper.c @@ -0,0 +1,102 @@ +#include "include/math_helper.h" + + +bool onSegment(vec2f p, vec2f q, vec2f r) +{ + if (q.x <= max(p.x, r.x) && q.x >= min(p.x, r.x) && + q.y <= max(p.y, r.y) && q.y >= min(p.y, r.y)) + return true; + + return false; +} + +int orientation(vec2f p, vec2f q, vec2f r) +{ + int val = (q.y - p.y) * (r.x - q.x) - + (q.x - p.x) * (r.y - q.y); + + if (val == 0) return 0; // collinear + + return (val > 0)? 1: 2; // clock or counterclock wise +} + +bool lines_intersect(vec2f p1, vec2f q1, vec2f p2, vec2f q2) +{ + int o1 = orientation(p1, q1, p2); + int o2 = orientation(p1, q1, q2); + int o3 = orientation(p2, q2, p1); + int o4 = orientation(p2, q2, q1); + + // General case + if (o1 != o2 && o3 != o4) + return true; + + // Special Cases + // p1, q1 and p2 are collinear and p2 lies on segment p1q1 + if (o1 == 0 && onSegment(p1, p2, q1)) return true; + + // p1, q1 and q2 are collinear and q2 lies on segment p1q1 + if (o2 == 0 && onSegment(p1, q2, q1)) return true; + + // p2, q2 and p1 are collinear and p1 lies on segment p2q2 + if (o3 == 0 && onSegment(p2, p1, q2)) return true; + + // p2, q2 and q1 are collinear and q1 lies on segment p2q2 + if (o4 == 0 && onSegment(p2, q1, q2)) return true; + + return false; // Doesn't fall in any of the above cases +} + +vec2f get_intersection_point(vec2f A, vec2f B, vec2f C, vec2f D) { + // Line AB represented as a1x + b1y = c1 + double a1 = B.y - A.y; + double b1 = A.x - B.x; + double c1 = a1*(A.x) + b1*(A.y); + + // Line CD represented as a2x + b2y = c2 + double a2 = D.y - C.y; + double b2 = C.x - D.x; + double c2 = a2*(C.x)+ b2*(C.y); + + double determinant = a1*b2 - a2*b1; + + if (determinant == 0) + { + // The lines are parallel. This is simplified + // by returning a pair of FLT_MAX + return (vec2f){__FLT_MAX__, __FLT_MAX__}; + } + else + { + double x = (b2*c1 - b1*c2)/determinant; + double y = (a1*c2 - a2*c1)/determinant; + return (vec2f){x, y}; + } +} + +box get_box_of_square(platform_window* window, vec3f position, vec3f size) { + map_info info = get_map_info(window); + vec2f rendertl = (vec2f){position.x, position.y}; + vec2f rendertr = (vec2f){position.x + size.x, position.y}; + vec2f renderbr = (vec2f){position.x + size.x, position.y + size.y}; + vec2f renderbl = (vec2f){position.x, position.y + size.y}; + + return (box){rendertl, rendertr, renderbl, renderbr, rendertl, rendertr, renderbl, renderbr}; +} + +box get_render_box_of_square(platform_window* window, vec3f position, vec3f size) { + map_info info = get_map_info(window); + float render_x = (info.tile_width * position.x) + (info.px_incline * position.y); + vec2f rendertl = (vec2f){render_x, info.tile_width * position.y - position.z*info.px_raised_per_h}; + vec2f rendertr = (vec2f){render_x + info.tile_width*size.x, info.tile_height * position.y - position.z*info.px_raised_per_h}; + vec2f renderbr = (vec2f){render_x + (info.px_incline+info.tile_width)*size.x, info.tile_height * position.y + info.tile_height*size.y - position.z*info.px_raised_per_h}; + vec2f renderbl = (vec2f){render_x + info.px_incline*size.x, info.tile_height * position.y + info.tile_height*size.y - position.z*info.px_raised_per_h}; + + position.z += size.z; + vec2f rendertl2 = (vec2f){render_x, info.tile_width * position.y - position.z*info.px_raised_per_h}; + vec2f rendertr2 = (vec2f){render_x + info.tile_width*size.x, info.tile_height * position.y - position.z*info.px_raised_per_h}; + vec2f renderbr2 = (vec2f){render_x + (info.px_incline+info.tile_width)*size.x, info.tile_height * position.y + info.tile_height*size.y - position.z*info.px_raised_per_h}; + vec2f renderbl2 = (vec2f){render_x + info.px_incline*size.x, info.tile_height * position.y + info.tile_height*size.y - position.z*info.px_raised_per_h}; + + return (box){rendertl, rendertr, renderbl, renderbr, rendertl2, rendertr2, renderbl2, renderbr2}; +}
\ No newline at end of file @@ -1,24 +1,7 @@ #include "include/objects.h" -box get_box_of_square(platform_window* window, vec3f position, vec3f size) { - map_info info = get_map_info(window); - float render_x = (info.tile_width * position.x) + (info.px_incline * position.y); - vec2f rendertl = (vec2f){render_x, info.tile_width * position.y - position.z*info.px_raised_per_h}; - vec2f rendertr = (vec2f){render_x + info.tile_width*size.x, info.tile_height * position.y - position.z*info.px_raised_per_h}; - vec2f renderbr = (vec2f){render_x + (info.px_incline+info.tile_width)*size.x, info.tile_height * position.y + info.tile_height*size.y - position.z*info.px_raised_per_h}; - vec2f renderbl = (vec2f){render_x + info.px_incline*size.x, info.tile_height * position.y + info.tile_height*size.y - position.z*info.px_raised_per_h}; - - position.z += size.z; - vec2f rendertl2 = (vec2f){render_x, info.tile_width * position.y - position.z*info.px_raised_per_h}; - vec2f rendertr2 = (vec2f){render_x + info.tile_width*size.x, info.tile_height * position.y - position.z*info.px_raised_per_h}; - vec2f renderbr2 = (vec2f){render_x + (info.px_incline+info.tile_width)*size.x, info.tile_height * position.y + info.tile_height*size.y - position.z*info.px_raised_per_h}; - vec2f renderbl2 = (vec2f){render_x + info.px_incline*size.x, info.tile_height * position.y + info.tile_height*size.y - position.z*info.px_raised_per_h}; - - return (box){rendertl, rendertr, renderbl, renderbr, rendertl2, rendertr2, renderbl2, renderbr2}; -} - box get_box_of_object(platform_window* window, object o) { - return get_box_of_square(window, (vec3f){o.position.x, o.position.y, o.h}, o.size); + return get_render_box_of_square(window, (vec3f){o.position.x, o.position.y, o.h}, o.size); } void render_quad_with_outline(vec2f tl, vec2f tr, vec2f bl, vec2f br) { @@ -53,12 +36,16 @@ void draw_objects_at_row(platform_window* window, int row) { for (int i = MAP_SIZE_X-1; i >= 0; i--) { object o = get_object_at_tile(i, row); - + if (row == y_of_player && x_of_player == i) { + OBJECT_RENDER_DEPTH(o.h); draw_player(window); } draw_zombies_at_tile(window, i, row); + + draw_bullets(window); + OBJECT_RENDER_DEPTH(o.h); if (!o.active) continue; box box = get_box_of_object(window, o); @@ -104,162 +104,3 @@ void draw_player(platform_window* window) { _global_camera.x = -(window->width / 2) + player_render_x; _global_camera.y = -(window->height / 2) + player_render_y; } - -void shoot(platform_window* window) { - map_info info = get_map_info(window); - float bullet_range = 100.0f; - - float hh = get_height_of_tile_under_coords(window, playerx, playery); - - float dirx = (_global_mouse.x - (window->width/2)); - float diry = (_global_mouse.y - (window->height/2)); - double length = sqrt(dirx * dirx + diry * diry); - dirx /= length; - diry /= length; - - float bulletx = playerx + (get_player_size_in_tile()/2); - float bullety = playery + (get_player_size_in_tile()/2); - float bullet_end_point_x = bulletx+dirx*bullet_range; - float bullet_end_point_y = bullety+diry*bullet_range; - - for (int i = 0; i < max_bullets; i++) { - bullet b = bullets[i]; - if (b.active) continue; - - bullets[i] = (bullet){true, bulletx, bullety, hh, bullet_end_point_x, bullet_end_point_y}; - break; - } -} - -bool onSegment(vec2f p, vec2f q, vec2f r) -{ - if (q.x <= max(p.x, r.x) && q.x >= min(p.x, r.x) && - q.y <= max(p.y, r.y) && q.y >= min(p.y, r.y)) - return true; - - return false; -} - -int orientation(vec2f p, vec2f q, vec2f r) -{ - int val = (q.y - p.y) * (r.x - q.x) - - (q.x - p.x) * (r.y - q.y); - - if (val == 0) return 0; // collinear - - return (val > 0)? 1: 2; // clock or counterclock wise -} - -bool lines_intersect(vec2f p1, vec2f q1, vec2f p2, vec2f q2) -{ - int o1 = orientation(p1, q1, p2); - int o2 = orientation(p1, q1, q2); - int o3 = orientation(p2, q2, p1); - int o4 = orientation(p2, q2, q1); - - // General case - if (o1 != o2 && o3 != o4) - return true; - - // Special Cases - // p1, q1 and p2 are collinear and p2 lies on segment p1q1 - if (o1 == 0 && onSegment(p1, p2, q1)) return true; - - // p1, q1 and q2 are collinear and q2 lies on segment p1q1 - if (o2 == 0 && onSegment(p1, q2, q1)) return true; - - // p2, q2 and p1 are collinear and p1 lies on segment p2q2 - if (o3 == 0 && onSegment(p2, p1, q2)) return true; - - // p2, q2 and q1 are collinear and q1 lies on segment p2q2 - if (o4 == 0 && onSegment(p2, q1, q2)) return true; - - return false; // Doesn't fall in any of the above cases -} - -bool check_if_bullet_collided_with_object(bullet b, platform_window* window) { - map_info info = get_map_info(window); - float size = get_bullet_size_in_tile(window); - - for (int i = 0; i < max_objects; i++) { - object o = objects[i]; - if (!o.active) continue; - if (b.position.x <= o.position.x + o.size.x && b.position.x + size >= o.position.x && - b.position.y <= o.position.y + o.size.y && b.position.y >= o.position.y && - b.position.z <= o.h + o.size.z && b.position.z >= o.h) { - return true; - } - } - - return false; -} - -bool check_if_bullet_collided_with_zombie(bullet b, platform_window* window, bool kill_if_collided) { - map_info info = get_map_info(window); - float size = get_bullet_size_in_tile(window); - - for (int i = 0; i < max_zombies; i++) { - zombie o = zombies[i]; - if (!o.alive) continue; - - vec2f bstart = (vec2f){b.position.x, b.position.y}; - vec2f bend = (vec2f){b.endx, b.endy}; - - if (b.position.z <= o.position.z + o.size.z && b.position.z >= o.position.z) { - if (lines_intersect(bstart, bend, (vec2f){o.position.x, o.position.y+o.size.y}, (vec2f){o.position.x+o.size.x, o.position.y+o.size.y}) || // bottom - lines_intersect(bstart, bend, (vec2f){o.position.x, o.position.y}, (vec2f){o.position.x+o.size.x, o.position.y}) || // top - lines_intersect(bstart, bend, (vec2f){o.position.x, o.position.y}, (vec2f){o.position.x, o.position.y+o.size.y}) || // left - lines_intersect(bstart, bend, (vec2f){o.position.x+o.size.x, o.position.y}, (vec2f){o.position.x+o.size.x, o.position.y+o.size.y})) // right - { - if (kill_if_collided) { - zombies[i].alive = false; - } - return true; - } - } - } - - return false; -} - -void draw_bullets(platform_window* window) { - float size = get_bullet_size(window); - map_info info = get_map_info(window); - - for (int i = 0; i < max_bullets; i++) { - bullet b = bullets[i]; - if (!b.active) continue; - - bullets[i].alive_time += update_delta; - if (bullets[i].alive_time > 0.03f) bullets[i].active = false; - - if (is_in_bounds(window, b.position.x, b.position.y)) { - tile t = get_tile_under_coords(window, b.position.x, b.position.y); - - float h = get_height_of_tile_under_coords(window, bullets[i].position.x, bullets[i].position.y); - if (h >= b.position.z) { - bullets[i].active = false; // hit the ground. - } - } - else { - bullets[i].active = false; - } - - //if (check_if_bullet_collided_with_object(b, window)) { - // bullets[i].active = false; - //} - if (check_if_bullet_collided_with_zombie(b, window, true)) { - bullets[i].active = false; - } - if (!b.active) continue; - - 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); - - float bullet_render_x_end = b.endx*info.tile_width + (b.endy*info.px_incline); - float bullet_render_y_end = b.endy*info.tile_height - (b.position.z*info.px_raised_per_h); - - renderer->render_line(bullet_render_x, bullet_render_y, bullet_render_x_end, bullet_render_y_end, 2, rgb(0,255,100)); - //renderer->render_rectangle(bullet_render_x - (size/2), bullet_render_y - (size/2), size, size, rgb(0,50,220)); - } -}
\ No newline at end of file diff --git a/project-base.code-workspace b/project-base.code-workspace index e30453c..45b030e 100644 --- a/project-base.code-workspace +++ b/project-base.code-workspace @@ -51,7 +51,9 @@ "string_view": "cpp", "objects.h": "c", "map.h": "c", - "zombies.h": "c" + "zombies.h": "c", + "math.h": "c", + "math_helper.h": "c" } } }
\ No newline at end of file @@ -1,6 +1,8 @@ #include "include/zombies.h" void spawn_zombie(int x, int y) { + return; + for (int i = 0; i < max_zombies; i++) { zombie o = zombies[i]; if (o.alive) continue; @@ -62,7 +64,7 @@ void draw_zombies_at_tile(platform_window* window, int x, int y) { zombies[i].position.y += diry*speed; zombies[i].position.z = height; - box box = get_box_of_square(window, (vec3f){o.position.x, o.position.y, height}, o.size); + box box = get_render_box_of_square(window, (vec3f){o.position.x, o.position.y, height}, o.size); render_quad_with_outline(box.tl_b, box.tr_b, box.bl_b, box.br_b); render_quad_with_outline(box.tl_u, box.tr_u, box.bl_u, box.br_u); render_quad_with_outline(box.tl_u, box.tl_b, box.bl_u, box.bl_b); |
