# Rendering a raycasting view

I am trying to reproduce the raycasting of the game Wolf3D. I read this tutorial, but I am struggling to understand how to code the intersection between the rays and the walls by using angles and pixels.

I have coded something but my approach to the concept seems quite wrong:

void    ray_cast(t_wolf3d *w)
{
int         wall_hit; // tell us if a ray hits a wall so we can stop the algorithm
t_ray       ray;    // add the ray if we don't hit a wall
double      angle_s; // will be a part of the FOV (subsequent column)
int         rayAdvance = 0;

int         x; // for each pixels ont the screen

angle_s = 0.0;
x = -1;
while (++x < W_M) //W_M represents the width of the map
{
while (angle_s < FOV / 2) // cast rays
{
while (++rayAdvance <= (277 / cos(angle_s * M_PI / 180.0))) //comparing distance for every pixels in the ray to the ray distance
{
ray.x = w->posx + rayAdvance * cos(angle_s * M_PI / 180.0); // converting degrees to radians inside cosine and sine
ray.y = w->posy + rayAdvance * sin(angle_s * M_PI / 180.0);
if (ray.x < w->map->h && ray.y < w->map->h && w->map->board[(int)ray.y][(int)ray.x] != 0)
{
printf("ray.x = %f, ray.y = %f\n, rayAdvance = %d\n", ray.x, ray.y, rayAdvance);
wall_hit = 1;
break;
}
}
if (wall_hit == 1)