feat: added colors depending on cardinal facing

This commit is contained in:
Theo Champion 2025-07-31 11:24:23 +02:00
parent fb57ef253a
commit 3cc73fc8ce

View file

@ -3,10 +3,10 @@
/* ::: :::::::: */
/* render.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tchampio <tchampio@student.42lehavre.fr> +#+ +:+ +#+ */
/* By: freddy <freddy@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/07/30 12:50:10 by tchampio #+# #+# */
/* Updated: 2025/07/30 16:38:59 by tchampio ### ########.fr */
/* Updated: 2025/07/31 11:24:59 by tchampio ### ########.fr */
/* */
/* ************************************************************************** */
@ -32,6 +32,23 @@ int get_cardinal(t_ray *ray)
}
}
static int get_color(int dir)
{
int color;
if (dir == 0)
color = 0x0000ff;
else if (dir == 1)
color = 0x00ff00;
else if (dir == 2)
color = 0xff0000;
else if (dir == 3)
color = 0xffeb3b;
else
color = 0xff53ff;
return (color);
}
/*
* Dir values are:
* 0: North
@ -57,8 +74,7 @@ void render_walls(t_cub3d_data *data, t_ray *ray, int x)
while (ray->draw_start < ray->draw_end)
{
pos += step;
color = 0x0000ff;
(void)dir;
color = get_color(dir);
(void)pos;
data->screen_matrix[ray->draw_start][x] = color;
ray->draw_start++;