fix: git merge conflict again

This commit is contained in:
Theo Champion 2025-08-18 13:13:42 +02:00
commit 4568124d3f
7 changed files with 52 additions and 27 deletions

View file

@ -6,7 +6,7 @@
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */ /* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/07/17 15:51:29 by kcolin #+# #+# */ /* Created: 2025/07/17 15:51:29 by kcolin #+# #+# */
/* Updated: 2025/07/29 13:28:08 by tchampio ### ########.fr */ /* Updated: 2025/08/13 15:31:17 by tchampio ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: tchampio <tchampio@student.42lehavre.fr> +#+ +:+ +#+ */ /* By: tchampio <tchampio@student.42lehavre.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/08/12 15:43:19 by tchampio #+# #+# */ /* Created: 2025/08/12 15:43:19 by tchampio #+# #+# */
/* Updated: 2025/08/14 21:24:03 by tchampio ### ########.fr */ /* Updated: 2025/08/18 12:55:21 by tchampio ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -25,6 +25,7 @@ t_sprite *create_sprite(t_cub3d_data *data, char *texture,
return (NULL); return (NULL);
sprite->x = x; sprite->x = x;
sprite->y = y; sprite->y = y;
sprite->sprite_type = OTHER;
sprite->image = load_single_texture(data, texture); sprite->image = load_single_texture(data, texture);
return (sprite); return (sprite);
} }

View file

@ -6,7 +6,7 @@
/* By: tchampio <tchampio@student.42lehavre.fr> +#+ +:+ +#+ */ /* By: tchampio <tchampio@student.42lehavre.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/08/05 12:59:44 by tchampio #+# #+# */ /* Created: 2025/08/05 12:59:44 by tchampio #+# #+# */
/* Updated: 2025/08/12 16:12:37 by tchampio ### ########.fr */ /* Updated: 2025/08/13 14:44:02 by tchampio ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -15,6 +15,14 @@
# include "../draw/img_data.h" # include "../draw/img_data.h"
typedef enum e_sprite_type
{
ZOMBIE,
PERK,
BOX,
OTHER
} t_sprite_type;
/* /*
* x - real position for the sprite * x - real position for the sprite
* y - real position for the sprite * y - real position for the sprite
@ -36,23 +44,24 @@
*/ */
typedef struct s_sprite typedef struct s_sprite
{ {
double x; double x;
double y; double y;
t_img_data *image; t_img_data *image;
int img_width; int img_width;
int img_height; int img_height;
double sprite_pos_x; double sprite_pos_x;
double sprite_pos_y; double sprite_pos_y;
double inv_det; double inv_det;
double transform_x; double transform_x;
double transform_y; double transform_y;
int sprite_screen_x; int sprite_screen_x;
int sprite_height; int sprite_height;
int sprite_draw_start_y; int sprite_draw_start_y;
int sprite_draw_end_y; int sprite_draw_end_y;
int sprite_width; int sprite_width;
int sprite_draw_start_x; int sprite_draw_start_x;
int sprite_draw_end_x; int sprite_draw_end_x;
t_sprite_type sprite_type;
} t_sprite; } t_sprite;
#endif // SPRITE_H #endif // SPRITE_H

View file

@ -6,7 +6,7 @@
/* By: tchampio <tchampio@student.42lehavre.fr> +#+ +:+ +#+ */ /* By: tchampio <tchampio@student.42lehavre.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/08/05 15:51:01 by tchampio #+# #+# */ /* Created: 2025/08/05 15:51:01 by tchampio #+# #+# */
/* Updated: 2025/08/07 16:57:29 by tchampio ### ########.fr */ /* Updated: 2025/08/13 15:30:55 by tchampio ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -15,8 +15,8 @@
#include "../renderer/render.h" #include "../renderer/render.h"
#include "sort_sprites.h" #include "sort_sprites.h"
#include <math.h> #include <math.h>
#include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include "../../libft/includes/libft.h"
static void calculate_pos_and_transform(t_cub3d_data *data, t_sprite *sprite, static void calculate_pos_and_transform(t_cub3d_data *data, t_sprite *sprite,
int i) int i)
@ -109,6 +109,17 @@ void sprite_caster(t_cub3d_data *data)
if (!data->sprite_list) if (!data->sprite_list)
return ; return ;
sort_sprites(data->sprite_order, data->sprite_distances, data); sort_sprites(data->sprite_order, data->sprite_distances, data);
if (data->sprite_distances[3] <= 1.5)
{
if (data->sprite_list[data->sprite_order[3]]->sprite_type == PERK)
{
if (data->keypresses.is_f_pressed)
{
data->keypresses.is_f_pressed = false;
ft_printf("🎵You need a little revive🎵\n");
}
}
}
i = 0; i = 0;
while (data->sprite_list[i] && i < MAX_SPRITES) while (data->sprite_list[i] && i < MAX_SPRITES)
{ {

View file

@ -6,7 +6,7 @@
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */ /* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/07/17 14:22:57 by kcolin #+# #+# */ /* Created: 2025/07/17 14:22:57 by kcolin #+# #+# */
/* Updated: 2025/07/29 13:35:29 by tchampio ### ########.fr */ /* Updated: 2025/08/13 15:25:04 by tchampio ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -31,6 +31,8 @@ int keypress_handler(int keycode, t_cub3d_data *data)
data->keypresses.is_s_pressed = true; data->keypresses.is_s_pressed = true;
if (keycode == XK_d) if (keycode == XK_d)
data->keypresses.is_d_pressed = true; data->keypresses.is_d_pressed = true;
if (keycode == XK_f)
data->keypresses.is_f_pressed = true;
if (keycode == XK_Left) if (keycode == XK_Left)
data->keypresses.is_left_pressed = true; data->keypresses.is_left_pressed = true;
if (keycode == XK_Right) if (keycode == XK_Right)
@ -48,6 +50,8 @@ int keyrelease_handler(int keycode, t_cub3d_data *data)
data->keypresses.is_s_pressed = false; data->keypresses.is_s_pressed = false;
if (keycode == XK_d) if (keycode == XK_d)
data->keypresses.is_d_pressed = false; data->keypresses.is_d_pressed = false;
if (keycode == XK_f)
data->keypresses.is_f_pressed = false;
if (keycode == XK_Left) if (keycode == XK_Left)
data->keypresses.is_left_pressed = false; data->keypresses.is_left_pressed = false;
if (keycode == XK_Right) if (keycode == XK_Right)

View file

@ -6,7 +6,7 @@
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */ /* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/07/31 13:43:05 by kcolin #+# #+# */ /* Created: 2025/07/31 13:43:05 by kcolin #+# #+# */
/* Updated: 2025/08/14 21:45:19 by tchampio ### ########.fr */ /* Updated: 2025/08/18 13:13:22 by tchampio ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -65,8 +65,7 @@ void place_base_sprites(t_cub3d_data *data, char **map)
x = 0; x = 0;
while (x < (int)ft_strlen(map[y])) while (x < (int)ft_strlen(map[y]))
{ {
if (map[y][x] == 'M' || map[y][x] == 'Q' if (ft_strchr("MQJD", map[y][x]))
|| map[y][x] == 'J' || map[y][x] == 'D')
{ {
if (data->sprite_counter < MAX_SPRITES) if (data->sprite_counter < MAX_SPRITES)
data->sprite_list[data->sprite_counter++] data->sprite_list[data->sprite_counter++]

View file

@ -6,7 +6,7 @@
/* By: tchampio <tchampio@student.42lehavre. +#+ +:+ +#+ */ /* By: tchampio <tchampio@student.42lehavre. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/07/29 13:42:39 by tchampio #+# #+# */ /* Created: 2025/07/29 13:42:39 by tchampio #+# #+# */
/* Updated: 2025/07/29 20:09:30 by tchampio ### ########.fr */ /* Updated: 2025/08/13 15:22:54 by tchampio ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -21,6 +21,7 @@ typedef struct s_keypresses
bool is_d_pressed; bool is_d_pressed;
bool is_left_pressed; bool is_left_pressed;
bool is_right_pressed; bool is_right_pressed;
bool is_f_pressed;
} t_keypresses; } t_keypresses;
#endif // KEYPRESSES_H #endif // KEYPRESSES_H