2025-08-05 13:22:06 +02:00
|
|
|
/* ************************************************************************** */
|
|
|
|
|
/* */
|
|
|
|
|
/* ::: :::::::: */
|
|
|
|
|
/* sprite.h :+: :+: :+: */
|
|
|
|
|
/* +:+ +:+ +:+ */
|
|
|
|
|
/* By: tchampio <tchampio@student.42lehavre.fr> +#+ +:+ +#+ */
|
|
|
|
|
/* +#+#+#+#+#+ +#+ */
|
|
|
|
|
/* Created: 2025/08/05 12:59:44 by tchampio #+# #+# */
|
2025-08-13 14:57:06 +02:00
|
|
|
/* Updated: 2025/08/13 14:44:02 by tchampio ### ########.fr */
|
2025-08-05 13:22:06 +02:00
|
|
|
/* */
|
|
|
|
|
/* ************************************************************************** */
|
|
|
|
|
|
|
|
|
|
#ifndef SPRITE_H
|
|
|
|
|
# define SPRITE_H
|
|
|
|
|
|
2025-08-06 14:06:15 +02:00
|
|
|
# include "../draw/img_data.h"
|
|
|
|
|
|
2025-08-13 14:57:06 +02:00
|
|
|
typedef enum e_sprite_type
|
|
|
|
|
{
|
|
|
|
|
ZOMBIE,
|
|
|
|
|
PERK,
|
|
|
|
|
BOX,
|
|
|
|
|
OTHER
|
|
|
|
|
} t_sprite_type;
|
|
|
|
|
|
2025-08-07 12:59:43 +02:00
|
|
|
/*
|
|
|
|
|
* x - real position for the sprite
|
|
|
|
|
* y - real position for the sprite
|
|
|
|
|
* image - texture
|
|
|
|
|
* img_width - width of texture
|
|
|
|
|
* img_height - height of texture
|
|
|
|
|
* sprite_pos_x - Position of the sprite relative to the player
|
|
|
|
|
* sprite_pos_y - Position of the sprite relative to the player
|
|
|
|
|
* inv_det - Inversion of the matrix (playerpos and spritepos)
|
|
|
|
|
* transform_x - Result of the inversion
|
|
|
|
|
* transform_y - Result of the inversion
|
|
|
|
|
* sprite_screen_x - Position of the sprite on screen (horizontal)
|
|
|
|
|
* sprite_height - height of the sprite on screen
|
|
|
|
|
* sprite_draw_start_y - for the while loop when rendering (col)
|
|
|
|
|
* sprite_draw_end_y - for the while loop when rendering (col)
|
|
|
|
|
* sprite_width - width of the sprite on screen
|
|
|
|
|
* sprite_draw_start_x - for the while loop when rendering (row)
|
|
|
|
|
* sprite_draw_end_x - for the while loop when rendering (row)
|
|
|
|
|
*/
|
2025-08-05 13:22:06 +02:00
|
|
|
typedef struct s_sprite
|
|
|
|
|
{
|
2025-08-13 14:57:06 +02:00
|
|
|
double x;
|
|
|
|
|
double y;
|
|
|
|
|
t_img_data *image;
|
|
|
|
|
int img_width;
|
|
|
|
|
int img_height;
|
|
|
|
|
double sprite_pos_x;
|
|
|
|
|
double sprite_pos_y;
|
|
|
|
|
double inv_det;
|
|
|
|
|
double transform_x;
|
|
|
|
|
double transform_y;
|
|
|
|
|
int sprite_screen_x;
|
|
|
|
|
int sprite_height;
|
|
|
|
|
int sprite_draw_start_y;
|
|
|
|
|
int sprite_draw_end_y;
|
|
|
|
|
int sprite_width;
|
|
|
|
|
int sprite_draw_start_x;
|
|
|
|
|
int sprite_draw_end_x;
|
|
|
|
|
t_sprite_type sprite_type;
|
2025-08-05 13:22:06 +02:00
|
|
|
} t_sprite;
|
|
|
|
|
|
|
|
|
|
#endif // SPRITE_H
|