This commit is contained in:
2024-01-28 22:59:54 +01:00
parent 50ff43445b
commit fcbbe51d52
26 changed files with 82445 additions and 291 deletions

View File

@@ -6,7 +6,7 @@
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/12 17:35:53 by fgras-ca #+# #+# */
/* Updated: 2024/01/25 14:58:34 by fgras-ca ### ########.fr */
/* Updated: 2024/01/26 17:25:05 by fgras-ca ### ########.fr */
/* */
/* ************************************************************************** */
@@ -65,7 +65,7 @@ void drawray(t_ray_params *rayparams)
deca = olineh - rayparams->w->s_win.height;
else
deca = 0;
//draw_black_ground(rayparams);
draw_black_ground(rayparams, textureparams);
if (deca != 0)
draw_yolo(rayparams, &textureparams, deca);
else
@@ -82,7 +82,7 @@ void draw_yolo(t_ray_params *rparams, t_texture_params *tparams, int deca)
float perspectivefactor;
int texturex;
int color;
texturewidth = tparams->w->s_img.texture_width;
textureheight = tparams->w->s_img.texture_height;
i = 0;
@@ -112,15 +112,15 @@ void draw_yolo(t_ray_params *rparams, t_texture_params *tparams, int deca)
texturex = texturewidth - 1;
}
//printf("%f %f\n",lineOff, lineOff/lineH);
color = get_texture_color(tparams->w, tparams->wallDir, texturex, y);
// BLOCK OK MEH
// float ww = ((720+merde)/lineH);
// //printf("%d %d %d\n", t ,td, merde);
// put_pixel_img(w, x, (int)(iii*ww)-merde/2, color);
// put_pixel_img(w, x, (int)(iii*ww)-merde/2, color);
// iii++;
int a = tparams->lineOff - deca / 2;

View File

@@ -6,7 +6,7 @@
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/11 23:19:39 by fgras-ca #+# #+# */
/* Updated: 2024/01/25 14:56:59 by fgras-ca ### ########.fr */
/* Updated: 2024/01/26 17:40:14 by fgras-ca ### ########.fr */
/* */
/* ************************************************************************** */
@@ -46,15 +46,15 @@ void draw_background(t_structure_main *w)
draw_sky_ground(&ground_params);
}
void draw_black_ground(t_ray_params *params)
void draw_black_ground(t_ray_params *params, t_texture_params tparams)
{
t_square_params square_params;
square_params.w = params->w;
square_params.y = params->texture.startX;
square_params.x = params->lineOff;
square_params.yo = params->texture.startX + 1;
square_params.xo = params->lineOff + params->lineH ;
square_params.x = tparams.startX;
square_params.y = params->lineOff;
square_params.xo = square_params.x + 1;
square_params.yo = params->lineOff + params->lineH ;
square_params.color = 0x000000;
draw_square_raw(&square_params);
}

View File

@@ -6,7 +6,7 @@
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/12 19:53:47 by fgras-ca #+# #+# */
/* Updated: 2024/01/14 18:34:26 by fgras-ca ### ########.fr */
/* Updated: 2024/01/25 20:37:32 by fgras-ca ### ########.fr */
/* */
/* ************************************************************************** */
@@ -32,22 +32,31 @@ void inithorizontalray(t_ray_calc_params *params)
handle_ra_equal_pi(params);
}
void update_ray_params(t_ray_calc_params *params, int mx, int my)
{
int mp;
void update_ray_params(t_ray_calc_params *params, int mx, int my) {
int mp = my * params->w->s_map.mapX + mx;
mp = my * params->w->s_map.mapX + mx;
if (mp >= 0 && mp < params->w->s_map.mapX * params->w->s_map.mapY
&& params->w->s_map.map[mp] == '1')
{
params->dof = DOF;
*params->disRay = dist(params->w->s_player.px, params->w->s_player.py,
*params->rx, *params->ry);
if (params->ra > PI)
*params->wallDir = NORTH;
else
*params->wallDir = SOUTH;
}
if (mp >= 0 && mp < params->w->s_map.mapX * params->w->s_map.mapY) {
char map_pos = params->w->s_map.map[mp];
if (map_pos == '1' || map_pos == '2') {
params->dof = DOF;
*params->disRay = dist(params->w->s_player.px, params->w->s_player.py,
*params->rx, *params->ry);
if (params->ra > PI)
*params->wallDir = NORTH;
else
*params->wallDir = SOUTH;
// Définir le type de mur actuel
if (map_pos == '2') {
params->w->current_wall_type = map_pos;
} else {
// Assurez-vous de réinitialiser pour les murs normaux
params->w->current_wall_type = '1';
}
}
}
}
void processhorizontalray(t_ray_calc_params *params)

View File

@@ -6,7 +6,7 @@
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/14 20:30:59 by fgras-ca #+# #+# */
/* Updated: 2024/01/20 11:12:22 by fgras-ca ### ########.fr */
/* Updated: 2024/01/25 20:34:50 by fgras-ca ### ########.fr */
/* */
/* ************************************************************************** */
@@ -36,6 +36,8 @@ void load_wall_textures(t_structure_main *w)
load_texture(w, w->t->south, (void **)&w->s_img.south_texture);
load_texture(w, w->t->west, (void **)&w->s_img.west_texture);
load_texture(w, w->t->east, (void **)&w->s_img.east_texture);
load_texture(w, "textures/door_close.xpm", (void **)&w->s_img.door_texture);
//load_texture(w, "textures/open_door.xpm", (void **)&w->s_img.open_door_texture);
}
void exit_error(t_structure_main *w)

View File

@@ -6,7 +6,7 @@
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/12 17:39:11 by fgras-ca #+# #+# */
/* Updated: 2024/01/23 21:21:04 by fgras-ca ### ########.fr */
/* Updated: 2024/01/25 20:34:32 by fgras-ca ### ########.fr */
/* */
/* ************************************************************************** */
@@ -61,7 +61,12 @@ void draw_texture(t_texture_params *params)
void *get_selected_texture(t_structure_main *w, WallDirection wallDir)
{
void *texture = NULL;
if (wallDir == NORTH)
if (w->current_wall_type == '2') {
return w->s_img.door_texture; // Texture pour porte fermée
} /*else if (w->current_wall_type == '3') {
return w->s_img.open_door_texture; // Texture pour porte ouverte
}*/
else if (wallDir == NORTH)
return (w->s_img.north_texture);
else if (wallDir == SOUTH)
return (w->s_img.south_texture);
@@ -100,6 +105,7 @@ int get_texture_color(t_structure_main *w, WallDirection wallDir,
selected_texture = get_selected_texture(w, wallDir);
if (selected_texture == NULL)
{
fprintf(stderr, "No texture selected for color retrieval\n");
return (0);
}

View File

@@ -6,7 +6,7 @@
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/12 20:03:21 by fgras-ca #+# #+# */
/* Updated: 2024/01/14 18:39:19 by fgras-ca ### ########.fr */
/* Updated: 2024/01/25 20:37:08 by fgras-ca ### ########.fr */
/* */
/* ************************************************************************** */
@@ -22,22 +22,31 @@ void initverticalray(t_ray_calc_params *params)
handle_ra_vertical(params, ntan, tilesize);
}
void update_vertical_ray_params(t_ray_calc_params *params, int mx, int my)
{
int mp;
void update_vertical_ray_params(t_ray_calc_params *params, int mx, int my) {
int mp = my * params->w->s_map.mapX + mx;
mp = my * params->w->s_map.mapX + mx;
if (mp >= 0 && mp < params->w->s_map.mapX * params->w->s_map.mapY
&& params->w->s_map.map[mp] == '1')
{
params->dof = DOF;
*params->disRay = dist(params->w->s_player.px, params->w->s_player.py,
*params->rx, *params->ry);
if (params->ra > P2 && params->ra < P3)
*params->wallDir = WEST;
else
*params->wallDir = EAST;
}
if (mp >= 0 && mp < params->w->s_map.mapX * params->w->s_map.mapY) {
char map_pos = params->w->s_map.map[mp];
if (map_pos == '1' || map_pos == '2') {
params->dof = DOF;
*params->disRay = dist(params->w->s_player.px, params->w->s_player.py,
*params->rx, *params->ry);
if (params->ra > P2 && params->ra < P3)
*params->wallDir = WEST;
else
*params->wallDir = EAST;
// Définir le type de mur actuel
if (map_pos == '2') {
params->w->current_wall_type = map_pos;
} else {
// Assurez-vous de réinitialiser pour les murs normaux
params->w->current_wall_type = '1';
}
}
}
}
void processverticalray(t_ray_calc_params *params)