/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* create_sprite.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: kcolin +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/08/18 13:52:23 by kcolin #+# #+# */ /* Updated: 2025/09/15 14:36:47 by tchampio ### ########.fr */ /* */ /* ************************************************************************** */ #include "sprite.h" #include "../../libft/includes/libft.h" #include "../cub3d_data.h" #include "../utils/inits.h" t_sprite *create_sprite(t_cub3d_data *data, char *texture, double x, double y) { t_sprite *sprite; sprite = ft_calloc(sizeof(t_sprite), 1); if (!sprite) return (NULL); sprite->x = x; sprite->y = y; sprite->sprite_type = OTHER; sprite->image = load_single_texture(data, texture); return (sprite); } void create_zombie(t_cub3d_data *data, double x, double y) { if (data->sprite_counter > MAX_SPRITES - 1) return ; data->sprite_list[data->sprite_counter] = create_sprite(data, "ressources/zombie.xpm", x, y); data->sprite_list[data->sprite_counter]->sprite_type = ZOMBIE; data->sprite_list[data->sprite_counter]->health = 250; data->sprite_counter++; } t_sprite *place_right_sprite(t_cub3d_data *data, char c, double x, double y) { t_sprite *sprite; if (c == 'M') { sprite = create_sprite(data, MYSTERY_TEX, x + 0.5, y + 0.5); sprite->sprite_type = BOX; } if (c == 'Q') sprite = create_sprite(data, REV_TEX, x + 0.5, y + 0.5); if (c == 'J') sprite = create_sprite(data, JUGG_TEX, x + 0.5, y + 0.5); if (c == 'D') sprite = create_sprite(data, DBLTAP_TEX, x + 0.5, y + 0.5); if (c == 'z') { sprite = create_sprite(data, ZOMBIE_TEX, x + 0.5, y + 0.5); sprite->sprite_type = ZOMBIE; sprite->health = 250; } if (c == 'D' || c == 'Q' || c == 'J') sprite->sprite_type = PERK; return (sprite); }