dev: improved sprites by creating a create_sprite function

This commit is contained in:
Theo Champion 2025-08-12 15:57:27 +02:00
parent 09ff569a31
commit 00e8a73d14
4 changed files with 60 additions and 31 deletions

View file

@ -0,0 +1,30 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* create_sprite.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tchampio <tchampio@student.42lehavre.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/08/12 15:43:19 by tchampio #+# #+# */
/* Updated: 2025/08/12 15:53:05 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->image = load_single_texture(data, texture);
return (sprite);
}