2025-08-12 15:57:27 +02:00
|
|
|
/* ************************************************************************** */
|
|
|
|
|
/* */
|
|
|
|
|
/* ::: :::::::: */
|
|
|
|
|
/* create_sprite.c :+: :+: :+: */
|
|
|
|
|
/* +:+ +:+ +:+ */
|
|
|
|
|
/* By: tchampio <tchampio@student.42lehavre.fr> +#+ +:+ +#+ */
|
|
|
|
|
/* +#+#+#+#+#+ +#+ */
|
|
|
|
|
/* Created: 2025/08/12 15:43:19 by tchampio #+# #+# */
|
2025-08-18 13:04:13 +02:00
|
|
|
/* Updated: 2025/08/18 12:55:21 by tchampio ### ########.fr */
|
2025-08-12 15:57:27 +02:00
|
|
|
/* */
|
|
|
|
|
/* ************************************************************************** */
|
|
|
|
|
|
|
|
|
|
#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;
|
2025-08-13 14:57:06 +02:00
|
|
|
sprite->sprite_type = OTHER;
|
2025-08-12 15:57:27 +02:00
|
|
|
sprite->image = load_single_texture(data, texture);
|
|
|
|
|
return (sprite);
|
|
|
|
|
}
|
2025-08-12 16:15:02 +02:00
|
|
|
|
|
|
|
|
t_sprite *place_right_sprite(t_cub3d_data *data, char c, double x, double y)
|
|
|
|
|
{
|
|
|
|
|
t_sprite *sprite;
|
|
|
|
|
|
|
|
|
|
if (c == 'M')
|
2025-08-14 21:25:03 +02:00
|
|
|
sprite = create_sprite(data, MYSTERY_TEX, x + 0.5, y + 0.5);
|
2025-08-12 16:15:02 +02:00
|
|
|
if (c == 'Q')
|
|
|
|
|
sprite = create_sprite(data,
|
2025-08-14 21:25:03 +02:00
|
|
|
REV_TEX, x + 0.5, y + 0.5);
|
2025-08-12 16:15:02 +02:00
|
|
|
if (c == 'J')
|
|
|
|
|
sprite = create_sprite(data,
|
2025-08-14 21:25:03 +02:00
|
|
|
JUGG_TEX, x + 0.5, y + 0.5);
|
2025-08-12 16:15:02 +02:00
|
|
|
if (c == 'D')
|
|
|
|
|
sprite = create_sprite(data,
|
2025-08-14 21:25:03 +02:00
|
|
|
DBLTAP_TEX, x + 0.5, y + 0.5);
|
2025-08-12 16:15:02 +02:00
|
|
|
return (sprite);
|
|
|
|
|
}
|