mirror of
https://codeberg.org/ACME-Corporation/cub3d.git
synced 2025-12-06 01:48:08 +01:00
feat: added colors depending on cardinal facing
This commit is contained in:
parent
fb57ef253a
commit
3cc73fc8ce
1 changed files with 20 additions and 4 deletions
|
|
@ -3,10 +3,10 @@
|
||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* render.c :+: :+: :+: */
|
/* render.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: tchampio <tchampio@student.42lehavre.fr> +#+ +:+ +#+ */
|
/* By: freddy <freddy@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/07/30 12:50:10 by tchampio #+# #+# */
|
/* 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:
|
* Dir values are:
|
||||||
* 0: North
|
* 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)
|
while (ray->draw_start < ray->draw_end)
|
||||||
{
|
{
|
||||||
pos += step;
|
pos += step;
|
||||||
color = 0x0000ff;
|
color = get_color(dir);
|
||||||
(void)dir;
|
|
||||||
(void)pos;
|
(void)pos;
|
||||||
data->screen_matrix[ray->draw_start][x] = color;
|
data->screen_matrix[ray->draw_start][x] = color;
|
||||||
ray->draw_start++;
|
ray->draw_start++;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue