diff --git a/Makefile b/Makefile index f625170..0c18e57 100644 --- a/Makefile +++ b/Makefile @@ -69,6 +69,9 @@ fclean: clean bonus: CFLAGS += -D BONUS=1 bonus: all +bonus-sane: CFLAGS += -D BONUS=1 $(SANITIZERS) +bonus-sane: all + sane: CFLAGS += $(SANITIZERS) sane: all diff --git a/src/main.c b/src/main.c index 473f269..ce5941f 100644 --- a/src/main.c +++ b/src/main.c @@ -6,7 +6,7 @@ /* By: kcolin +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/07/17 14:14:30 by kcolin #+# #+# */ -/* Updated: 2025/09/10 15:34:15 by tchampio ### ########.fr */ +/* Updated: 2025/09/14 16:41:00 by tchampio ### ########.fr */ /* */ /* ************************************************************************** */ @@ -36,11 +36,10 @@ void handle_shooting(t_cub3d_data *data) { - if (!data->keypresses.is_space_pressed) - return ; - else + if (data->keypresses.is_space_pressed) { - + if (!data->player.weapon.is_auto) + data->keypresses.is_space_pressed = false; } } @@ -53,6 +52,7 @@ int game_loop(t_cub3d_data *data) data->last_tick = get_milliseconds(); reset_matrix(data); move_player(data); + handle_shooting(data); move_sprites(data); raycaster(data, &ray); sprite_caster(data); diff --git a/src/raycast/ray.c b/src/raycast/ray.c index bcbfb7c..688d1b5 100644 --- a/src/raycast/ray.c +++ b/src/raycast/ray.c @@ -6,7 +6,7 @@ /* By: kcolin +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/07/31 11:55:41 by kcolin #+# #+# */ -/* Updated: 2025/09/09 14:07:24 by tchampio ### ########.fr */ +/* Updated: 2025/09/14 17:40:53 by tchampio ### ########.fr */ /* */ /* ************************************************************************** */ @@ -19,6 +19,7 @@ #include #include #include "../map/collision.h" +#include "../../libft/includes/libft.h" void init_ray(t_ray *ray, int pos_x, t_player *player) { @@ -55,10 +56,23 @@ void ray_calculate_step(t_ray *ray, t_player *player) } } -void calculate_wall_dist(t_ray *ray, t_mapdata *map) +void calculate_wall_dist(t_ray *ray, int x, t_cub3d_data *data) { + int i; while (true) { + if (x == WIDTH / 2) + { + i = 0; + while (i < data->sprite_counter) + { + if (data->sprite_list[i]->sprite_type == ZOMBIE && ray->map_x == (int)data->sprite_list[i]->x && ray->map_y == (int)data->sprite_list[i]->y) + { + ft_printf("Zombie found\n"); + } + i++; + } + } if (ray->side_dist_x < ray->side_dist_y) { ray->side_dist_x += ray->delta_dist_x; @@ -71,7 +85,7 @@ void calculate_wall_dist(t_ray *ray, t_mapdata *map) ray->map_y += ray->step_y; ray->side = SOUTH; } - if (blocks_view(map, ray->map_x, ray->map_y)) + if (blocks_view(data->map, ray->map_x, ray->map_y)) break ; } if (ray->side == NORTH) @@ -107,7 +121,7 @@ void raycaster(t_cub3d_data *data, t_ray *ray) { init_ray(ray, x, &data->player); ray_calculate_step(ray, &data->player); - calculate_wall_dist(ray, data->map); + calculate_wall_dist(ray, x, data); calculate_wall_height(ray, &data->player); check_barricades(ray, data); render_walls(data, ray, x); diff --git a/src/utils/hooks.c b/src/utils/hooks.c index 7877b4d..3be647e 100644 --- a/src/utils/hooks.c +++ b/src/utils/hooks.c @@ -6,7 +6,7 @@ /* By: kcolin +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/07/17 14:22:57 by kcolin #+# #+# */ -/* Updated: 2025/09/10 15:33:38 by tchampio ### ########.fr */ +/* Updated: 2025/09/14 15:57:54 by tchampio ### ########.fr */ /* */ /* ************************************************************************** */