mirror of
https://codeberg.org/ACME-Corporation/cub3d.git
synced 2025-12-06 01:48:08 +01:00
48 lines
1.7 KiB
C
48 lines
1.7 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* create_sprite.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: tchampio <tchampio@student.42lehavre.fr> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2025/08/12 15:43:19 by tchampio #+# #+# */
|
|
/* Updated: 2025/08/14 21:24:03 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);
|
|
}
|
|
|
|
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);
|
|
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);
|
|
return (sprite);
|
|
}
|