manqueunefonctionnorme

This commit is contained in:
2024-01-29 20:26:06 +01:00
parent fcbbe51d52
commit 7d67dfd452
121 changed files with 996 additions and 2858 deletions

View File

@@ -6,7 +6,7 @@
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/12 17:49:42 by fgras-ca #+# #+# */
/* Updated: 2024/01/23 17:43:56 by fgras-ca ### ########.fr */
/* Updated: 2024/01/29 16:20:39 by fgras-ca ### ########.fr */
/* */
/* ************************************************************************** */
@@ -26,39 +26,39 @@ float correctfisheye(float distance, float ra, float playerAngle)
void init_base_params(t_base_params *params, t_structure_main *w)
{
params->tilesize = w->s_map.mapS;
params->tilesize = w->s_map.map_s;
params->numrays = NUMRAY;
params->FOV = FOVIEW * (PI / 180);
params->DR = params->FOV / params->numrays;
params->ra = w->s_player.pa - (params->FOV / 2);
params->fo_v = FOVIEW * (PI / 180);
params->d_r = params->fo_v / params->numrays;
params->ra = w->s_player.pa - (params->fo_v / 2);
draw_background(w);
}
void calculate_ray(t_base_params *base, t_ray_state *state,
t_ray_calc *calc, t_ray_params *rayparams)
{
if (state->disH < state->disV)
if (state->dis_h < state->dis_v)
{
rayparams->disT = state->disH;
rayparams->dis_t = state->dis_h;
calc->color = 0xFF0000;
rayparams->wallDir = state->hwalldir;
rayparams->wall_dir = state->hwalldir;
rayparams->rx = state->hx;
rayparams->ry = state->hy;
}
else
{
rayparams->disT = state->disV;
rayparams->dis_t = state->dis_v;
calc->color = 0x00FF00;
rayparams->wallDir = state->vwalldir;
rayparams->wall_dir = state->vwalldir;
rayparams->rx = state->vx;
rayparams->ry = state->vy;
}
rayparams->disT = correctfisheye(rayparams->disT,
rayparams->dis_t = correctfisheye(rayparams->dis_t,
base->ra, calc->w->s_player.pa);
rayparams->w = calc->w;
rayparams->tileSize = base->tilesize;
rayparams->tile_size = base->tilesize;
rayparams->r = calc->r;
rayparams->numRays = base->numrays;
rayparams->num_rays = base->numrays;
rayparams->color = calc->color;
}
@@ -73,16 +73,16 @@ void drawrays2d(t_structure_main *w)
{
params.base_params.ra = fmod(params.base_params.ra + 2 * PI, 2 * PI);
params.hrayparams = (t_ray_calc_params){w, params.base_params.ra,
&params.ray_state.disH, &params.ray_state.hx,
&params.ray_state.dis_h, &params.ray_state.hx,
&params.ray_state.hy, &params.ray_state.hwalldir};
params.vrayparams = (t_ray_calc_params){w, params.base_params.ra,
&params.ray_state.disV, &params.ray_state.vx,
&params.ray_state.dis_v, &params.ray_state.vx,
&params.ray_state.vy, &params.ray_state.vwalldir};
calculatehorizontalray(&params.hrayparams);
calculateverticalray(&params.vrayparams);
calculate_ray(&params.base_params, &params.ray_state,
&params.ray_calc, &params.rayparams);
drawray(&params.rayparams);
params.base_params.ra += params.base_params.DR;
params.base_params.ra += params.base_params.d_r;
}
}

View File

@@ -6,32 +6,50 @@
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/12 17:35:53 by fgras-ca #+# #+# */
/* Updated: 2024/01/26 17:25:05 by fgras-ca ### ########.fr */
/* Updated: 2024/01/29 17:05:58 by fgras-ca ### ########.fr */
/* */
/* ************************************************************************** */
#include "../cub3d.h"
void init_line_params(t_line_params *lineparams, t_ray_params *rayParams)
static void calculate_line_height(t_ray_params *rayparams)
{
lineparams->w = rayParams->w;
lineparams->x0 = (int)rayParams->w->s_player.px;
lineparams->y0 = (int)rayParams->w->s_player.py;
lineparams->x1 = (int)rayParams->rx;
lineparams->y1 = (int)rayParams->ry;
lineparams->color = rayParams->color;
rayparams->line_h = (rayparams->tile_size * rayparams->max3d_height)
/ rayparams->dis_t;
if (rayparams->line_h > rayparams->max3d_height)
{
rayparams->line_h = rayparams->max3d_height;
}
rayparams->line_off = ((rayparams->max3d_height - rayparams->line_h) / 2);
}
void init_texture_params(t_texture_params *textureparams,
t_ray_params *rayParams)
static void calculate_deca(t_ray_params *rayparams, float *olineh, int *deca)
{
textureparams->w = rayParams->w;
textureparams->lineOff = rayParams->lineOff;
textureparams->lineH = rayParams->lineH;
textureparams->wallDir = rayParams->wallDir;
textureparams->rx = rayParams->rx + rayParams->backgroundOffsetX;
textureparams->ry = rayParams->ry;
textureparams->disT = rayParams->disT;
*olineh = (rayparams->w->s_map.map_s * rayparams->w->s_win.height)
/ rayparams->dis_t;
if (*olineh > rayparams->w->s_win.height)
{
*deca = *olineh - rayparams->w->s_win.height;
}
else
{
*deca = 0;
}
}
static void set_rayparams(t_ray_params *rayparams)
{
rayparams->start3d_height = 0;
rayparams->max3d_height = rayparams->w->s_win.height
+ rayparams->start3d_height;
}
static void set_texture_params(t_ray_params *rayparams,
t_texture_params *textureparams)
{
textureparams->start_x = rayparams->r * rayparams->raywidth
+ rayparams->background_off_setx;
textureparams->end_x = textureparams->start_x + rayparams->raywidth;
}
void drawray(t_ray_params *rayparams)
@@ -40,96 +58,23 @@ void drawray(t_ray_params *rayparams)
t_texture_params textureparams;
float olineh;
int deca;
int color;
rayparams->start3DHeight = 0;
rayparams->max3DHeight = rayparams->w->s_win.height
+ rayparams->start3DHeight;
rayparams->lineH = (rayparams->tileSize * rayparams->max3DHeight)
/ rayparams->disT;
if (rayparams->lineH > rayparams->max3DHeight)
{
rayparams->lineH = rayparams->max3DHeight;
}
rayparams->lineOff = ((rayparams->max3DHeight - rayparams->lineH) / 2);
olineh = (rayparams->w->s_map.mapS * rayparams->w->s_win.height) / rayparams->disT;
rayparams->backgroundOffsetX = BOV;
rayparams->raywidth = rayparams->w->s_win.width / rayparams->numRays;
textureparams.startX = rayparams->r * rayparams->raywidth
+ rayparams->backgroundOffsetX;
textureparams.endX = textureparams.startX + rayparams->raywidth;
set_rayparams(rayparams);
calculate_line_height(rayparams);
rayparams->raywidth = rayparams->w->s_win.width / rayparams->num_rays;
rayparams->background_off_setx = BOV;
calculate_deca(rayparams, &olineh, &deca);
set_texture_params(rayparams, &textureparams);
init_texture_params(&textureparams, rayparams);
init_line_params(&lineparams, rayparams);
draw_line(&lineparams);
if (olineh > rayparams->w->s_win.height)
deca = olineh - rayparams->w->s_win.height;
else
deca = 0;
draw_black_ground(rayparams, textureparams);
if (deca != 0)
{
draw_yolo(rayparams, &textureparams, deca);
}
else
{
draw_texture(&textureparams);
}
void draw_yolo(t_ray_params *rparams, t_texture_params *tparams, int deca)
{
int texturewidth;
int textureheight;
int i;
int y;
int x;
float perspectivefactor;
int texturex;
int color;
texturewidth = tparams->w->s_img.texture_width;
textureheight = tparams->w->s_img.texture_height;
i = 0;
for (y = rparams->lineOff; y < rparams->lineOff + rparams->lineH; y++) {
// La variable perspectiveFactor permet de mapper la texture en tenant compte de la perspective
perspectivefactor = (float)(y - rparams->lineOff) / rparams->lineH;
int textureY = perspectivefactor * (textureheight );
if (textureY >= textureheight) {
textureY = textureheight - 1;
}
//for (int x = startX; x < endX; x++) {
x = tparams->startX;
switch (tparams->wallDir) {
case NORTH:
case SOUTH:
// Assurez-vous que rx est normalisé correctement pour le mappage de texture
texturex = (int)(tparams->rx * texturewidth / tparams->w->s_map.mapS) % texturewidth;
break;
case WEST:
case EAST:
// Assurez-vous que ry est normalisé correctement pour le mappage de texture
texturex = (int)(tparams->ry * texturewidth / tparams->w->s_map.mapS) % texturewidth;
break;
}
if (texturex >= texturewidth) {
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);
// iii++;
int a = tparams->lineOff - deca / 2;
int b = tparams->lineH + (deca /2);
int c = tparams->lineH;
double step = (b - a)/(double)(c - 1);
//printf("%d %d %d\n", t ,td, merde);
put_pixel_img(tparams->w, x, (int)(a + i * step), color);
i++;
//}
}
}

93
draw/ft_3d_view_utils.c Normal file
View File

@@ -0,0 +1,93 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_3d_view_utils.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/29 17:00:21 by fgras-ca #+# #+# */
/* Updated: 2024/01/29 17:05:55 by fgras-ca ### ########.fr */
/* */
/* ************************************************************************** */
#include "../cub3d.h"
static void set_texture_coords(t_texture_params *tparams,
t_draw_params *dparams)
{
if (tparams->wall_dir == NORTH || tparams->wall_dir == SOUTH)
{
dparams->texturex = (int)(tparams->rx * dparams->texturewidth
/ tparams->w->s_map.map_s) % dparams->texturewidth;
}
else if (tparams->wall_dir == WEST || tparams->wall_dir == EAST)
{
dparams->texturex = (int)(tparams->ry * dparams->texturewidth
/ tparams->w->s_map.map_s) % dparams->texturewidth;
}
if (dparams->texturex >= dparams->texturewidth)
{
dparams->texturex = dparams->texturewidth - 1;
}
}
static void draw_texture_line(t_ray_params *rparams,
t_texture_params *tparams, t_draw_params *dparams, int deca)
{
int y;
int color;
float perspectivefactor;
y = rparams->line_off;
dparams->i = 0;
dparams->x = tparams->start_x;
while (y < rparams->line_off + rparams->line_h)
{
perspectivefactor = (float)(y - rparams->line_off) / rparams->line_h;
dparams->textureY = perspectivefactor * dparams->textureheight;
if (dparams->textureY >= dparams->textureheight)
dparams->textureY = dparams->textureheight - 1;
set_texture_coords(tparams, dparams);
color = get_texture_color(tparams->w,
tparams->wall_dir, dparams->texturex, y);
dparams->a = tparams->line_off - deca / 2;
dparams->b = tparams->line_h + (deca / 2);
dparams->c = tparams->line_h;
dparams->step = (dparams->b - dparams->a) / (double)(dparams->c - 1);
put_pixel_img(tparams->w, dparams->x,
(int)(dparams->a + dparams->i * dparams->step), color);
dparams->i++;
y++;
}
}
void draw_yolo(t_ray_params *rparams, t_texture_params *tparams, int deca)
{
t_draw_params dparams;
dparams.texturewidth = tparams->w->s_img.texture_width;
dparams.textureheight = tparams->w->s_img.texture_height;
draw_texture_line(rparams, tparams, &dparams, deca);
}
void init_line_params(t_line_params *lineparams, t_ray_params *rayParams)
{
lineparams->w = rayParams->w;
lineparams->x0 = (int)rayParams->w->s_player.px;
lineparams->y0 = (int)rayParams->w->s_player.py;
lineparams->x1 = (int)rayParams->rx;
lineparams->y1 = (int)rayParams->ry;
lineparams->color = rayParams->color;
}
void init_texture_params(t_texture_params *textureparams,
t_ray_params *rayParams)
{
textureparams->w = rayParams->w;
textureparams->line_off = rayParams->line_off;
textureparams->line_h = rayParams->line_h;
textureparams->wall_dir = rayParams->wall_dir;
textureparams->rx = rayParams->rx + rayParams->background_off_setx;
textureparams->ry = rayParams->ry;
textureparams->dis_t = rayParams->dis_t;
}

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/26 17:40:14 by fgras-ca ### ########.fr */
/* Updated: 2024/01/29 17:08:15 by fgras-ca ### ########.fr */
/* */
/* ************************************************************************** */
@@ -17,10 +17,10 @@ void draw_sky_ground(t_sky_ground_params *params)
t_square_params square_params;
square_params.w = params->w;
square_params.x = params->backgroundOffsetX;
square_params.y = params->startHeight;
square_params.xo = params->w->s_win.width + params->backgroundOffsetX;
square_params.yo = params->endHeight;
square_params.x = params->background_off_setx;
square_params.y = params->start_height;
square_params.xo = params->w->s_win.width + params->background_off_setx;
square_params.yo = params->end_height;
square_params.color = params->color;
draw_square_raw(&square_params);
}
@@ -33,16 +33,16 @@ void draw_background(t_structure_main *w)
backgroundoffsetx = BOV;
sky_params.w = w;
sky_params.startHeight = 0;
sky_params.endHeight = w->s_win.height / 2;
sky_params.start_height = 0;
sky_params.end_height = w->s_win.height / 2;
sky_params.color = w->t->ceil_color;
sky_params.backgroundOffsetX = backgroundoffsetx;
sky_params.background_off_setx = backgroundoffsetx;
draw_sky_ground(&sky_params);
ground_params.w = w;
ground_params.startHeight = w->s_win.height / 2;
ground_params.endHeight = w->s_win.height;
ground_params.start_height = w->s_win.height / 2;
ground_params.end_height = w->s_win.height;
ground_params.color = w->t->floor_color;
ground_params.backgroundOffsetX = backgroundoffsetx;
ground_params.background_off_setx = backgroundoffsetx;
draw_sky_ground(&ground_params);
}
@@ -51,10 +51,10 @@ void draw_black_ground(t_ray_params *params, t_texture_params tparams)
t_square_params square_params;
square_params.w = params->w;
square_params.x = tparams.startX;
square_params.y = params->lineOff;
square_params.x = tparams.start_x;
square_params.y = params->line_off;
square_params.xo = square_params.x + 1;
square_params.yo = params->lineOff + params->lineH ;
square_params.yo = params->line_off + params->line_h ;
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/11 22:38:28 by fgras-ca #+# #+# */
/* Updated: 2024/01/14 17:54:44 by fgras-ca ### ########.fr */
/* Updated: 2024/01/29 15:47:48 by fgras-ca ### ########.fr */
/* */
/* ************************************************************************** */
@@ -20,9 +20,9 @@ void draw_square(t_structure_main *w, int x, int y, int color)
int i;
int j;
xo = x * w->s_map.mapS;
yo = y * w->s_map.mapS;
size = w->s_map.mapS;
xo = x * w->s_map.map_s;
yo = y * w->s_map.map_s;
size = w->s_map.map_s;
i = 0;
while (i < size)
{

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/25 20:37:32 by fgras-ca ### ########.fr */
/* Updated: 2024/01/29 17:12:54 by fgras-ca ### ########.fr */
/* */
/* ************************************************************************** */
@@ -25,38 +25,37 @@ void inithorizontalray(t_ray_calc_params *params)
int tilesize;
atan = -1 / tan(params->ra);
tilesize = params->w->s_map.mapS;
tilesize = params->w->s_map.map_s;
if (params->ra != PI)
handle_ra_not_equal_pi(params, atan, tilesize);
else
handle_ra_equal_pi(params);
}
void update_ray_params(t_ray_calc_params *params, int mx, int my) {
int mp = my * params->w->s_map.mapX + mx;
void update_ray_params(t_ray_calc_params *params, int mx, int my)
{
int mp;
char map_pos;
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';
}
}
}
mp = my * params->w->s_map.map_x + mx;
if (mp >= 0 && mp < params->w->s_map.map_x * params->w->s_map.map_y)
{
map_pos = params->w->s_map.map[mp];
if (map_pos == '1' || map_pos == '2')
{
params->dof = DOF;
*params->dis_ray = dist(params->w->s_player.px,
params->w->s_player.py, *params->rx, *params->ry);
if (params->ra > PI)
*params->wall_dir = NORTH;
else
*params->wall_dir = SOUTH;
if (map_pos == '2')
params->w->current_wall_type = map_pos;
else
params->w->current_wall_type = '1';
}
}
}
void processhorizontalray(t_ray_calc_params *params)
@@ -65,8 +64,8 @@ void processhorizontalray(t_ray_calc_params *params)
int my;
int tilesize;
tilesize = params->w->s_map.mapS;
*params->disRay = DISRAY;
tilesize = params->w->s_map.map_s;
*params->dis_ray = DISRAY;
while (params->dof < DOF)
{
mx = (int)(*params->rx) / tilesize;

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/25 20:34:50 by fgras-ca ### ########.fr */
/* Updated: 2024/01/29 17:13:50 by fgras-ca ### ########.fr */
/* */
/* ************************************************************************** */
@@ -37,7 +37,6 @@ void load_wall_textures(t_structure_main *w)
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/25 20:34:32 by fgras-ca ### ########.fr */
/* Updated: 2024/01/29 17:17:21 by fgras-ca ### ########.fr */
/* */
/* ************************************************************************** */
@@ -20,19 +20,19 @@ void draw_texture_line(t_texture_params *params, float y, int textureY)
int color;
texturewidth = params->w->s_img.texture_width;
x = params->startX;
while (x < params->endX)
x = params->start_x;
while (x < params->end_x)
{
if (params->wallDir == NORTH || params->wallDir == SOUTH)
if (params->wall_dir == NORTH || params->wall_dir == SOUTH)
texturex = (int)(params->rx * texturewidth
/ params->w->s_map.mapS) % texturewidth;
/ params->w->s_map.map_s) % texturewidth;
else
texturex = (int)(params->ry * texturewidth
/ params->w->s_map.mapS) % texturewidth;
/ params->w->s_map.map_s) % texturewidth;
if (texturex >= texturewidth)
texturex = texturewidth - 1;
color = get_texture_color(params->w,
params->wallDir, texturex, textureY);
params->wall_dir, texturex, textureY);
put_pixel_img(params->w, x, y, color);
x++;
}
@@ -46,10 +46,10 @@ void draw_texture(t_texture_params *params)
int texturey;
textureheight = params->w->s_img.texture_height;
y = params->lineOff;
while (y < params->lineOff + params->lineH)
y = params->line_off;
while (y < params->line_off + params->line_h)
{
perspectivefactor = (y - params->lineOff) / params->lineH;
perspectivefactor = (y - params->line_off) / params->line_h;
texturey = perspectivefactor * textureheight;
if (texturey >= textureheight)
texturey = textureheight - 1;
@@ -58,14 +58,15 @@ void draw_texture(t_texture_params *params)
}
}
void *get_selected_texture(t_structure_main *w, WallDirection wallDir)
void *get_selected_texture(t_structure_main *w, t_WallDirection wallDir)
{
void *texture = NULL;
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
}*/
void *texture;
texture = NULL;
if (w->current_wall_type == '2')
{
return (w->s_img.door_texture);
}
else if (wallDir == NORTH)
return (w->s_img.north_texture);
else if (wallDir == SOUTH)
@@ -76,12 +77,12 @@ void *get_selected_texture(t_structure_main *w, WallDirection wallDir)
return (w->s_img.east_texture);
else
{
fprintf(stderr, "Invalid wall direction.\n");
printf("Invalid wall direction.\n");
exit_error(w);
return (NULL);
}
if (texture == NULL)
fprintf(stderr, "get_selected_texture: selected texture is NULL\n");
if (texture == NULL)
printf("get_selected_texture: selected texture is NULL\n");
else
printf("get_selected_texture: selected texture = %p\n", texture);
}
@@ -95,7 +96,7 @@ t_texture_data get_texture_data(void *texture)
return (texture_data);
}
int get_texture_color(t_structure_main *w, WallDirection wallDir,
int get_texture_color(t_structure_main *w, t_WallDirection wallDir,
int textureX, int textureY)
{
void *selected_texture;
@@ -108,7 +109,6 @@ int get_texture_color(t_structure_main *w, WallDirection wallDir,
fprintf(stderr, "No texture selected for color retrieval\n");
return (0);
}
texture_data = get_texture_data(selected_texture);
pixel_pos = (textureX + textureY * w->s_img.texture_width)
* (texture_data.bpp / 8);

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/25 20:37:08 by fgras-ca ### ########.fr */
/* Updated: 2024/01/29 17:22:00 by fgras-ca ### ########.fr */
/* */
/* ************************************************************************** */
@@ -18,35 +18,35 @@ void initverticalray(t_ray_calc_params *params)
int tilesize;
ntan = -tan(params->ra);
tilesize = params->w->s_map.mapS;
tilesize = params->w->s_map.map_s;
handle_ra_vertical(params, ntan, tilesize);
}
void update_vertical_ray_params(t_ray_calc_params *params, int mx, int my) {
int mp = my * params->w->s_map.mapX + mx;
void update_vertical_ray_params(t_ray_calc_params *params, int mx, int my)
{
int mp;
char map_pos;
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';
}
}
}
mp = my * params->w->s_map.map_x + mx;
if (mp >= 0 && mp < params->w->s_map.map_x * params->w->s_map.map_y)
{
map_pos = params->w->s_map.map[mp];
if (map_pos == '1' || map_pos == '2')
{
params->dof = DOF;
*params->dis_ray = dist(params->w->s_player.px,
params->w->s_player.py,
*params->rx, *params->ry);
if (params->ra > P2 && params->ra < P3)
*params->wall_dir = WEST;
else
*params->wall_dir = EAST;
if (map_pos == '2')
params->w->current_wall_type = map_pos;
else
params->w->current_wall_type = '1';
}
}
}
void processverticalray(t_ray_calc_params *params)
@@ -55,8 +55,8 @@ void processverticalray(t_ray_calc_params *params)
int my;
int tilesize;
tilesize = params->w->s_map.mapS;
*params->disRay = DISRAY;
tilesize = params->w->s_map.map_s;
*params->dis_ray = DISRAY;
while (params->dof < DOF)
{
mx = (int)(*params->rx) / tilesize;