little cleanup
This commit is contained in:
parent
37b31d1e70
commit
b06ede9ae9
15
cub3d.h
15
cub3d.h
@ -6,7 +6,7 @@
|
|||||||
/* By: houtworm <codam@houtworm.net> +#+ */
|
/* By: houtworm <codam@houtworm.net> +#+ */
|
||||||
/* +#+ */
|
/* +#+ */
|
||||||
/* Created: 2023/10/26 10:46:35 by houtworm #+# #+# */
|
/* Created: 2023/10/26 10:46:35 by houtworm #+# #+# */
|
||||||
/* Updated: 2023/11/05 02:59:11 by houtworm ######## odam.nl */
|
/* Updated: 2023/11/05 04:15:30 by houtworm ######## odam.nl */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -49,7 +49,6 @@ typedef struct s_varlist
|
|||||||
mlx_texture_t *nazitext;
|
mlx_texture_t *nazitext;
|
||||||
t_sprite *sprite;
|
t_sprite *sprite;
|
||||||
int spritecount;
|
int spritecount;
|
||||||
int fpsrefresh;
|
|
||||||
int w;
|
int w;
|
||||||
int h;
|
int h;
|
||||||
char **map;
|
char **map;
|
||||||
@ -60,33 +59,23 @@ typedef struct s_varlist
|
|||||||
double diry;
|
double diry;
|
||||||
double planex;
|
double planex;
|
||||||
double planey;
|
double planey;
|
||||||
double camerax;
|
|
||||||
double cameray;
|
|
||||||
int vaim;
|
int vaim;
|
||||||
int jump;
|
int jump;
|
||||||
double raydirx;
|
double raydirx;
|
||||||
double raydiry;
|
double raydiry;
|
||||||
double movespeed;
|
|
||||||
double rotspeed;
|
|
||||||
int mapx;
|
|
||||||
int mapy;
|
|
||||||
double sidedistx;
|
double sidedistx;
|
||||||
double sidedisty;
|
double sidedisty;
|
||||||
double deltadistx;
|
double deltadistx;
|
||||||
double deltadisty;
|
double deltadisty;
|
||||||
double perpwalldist;
|
double perpwalldist;
|
||||||
int lineheight;
|
int lineheight;
|
||||||
int stepx;
|
|
||||||
int stepy;
|
|
||||||
int hit;
|
|
||||||
int side;
|
int side;
|
||||||
double run;
|
double run;
|
||||||
double oldmouseposx;
|
double oldmouseposx;
|
||||||
double oldmouseposy;
|
double oldmouseposy;
|
||||||
int32_t fcolor;
|
int32_t fcolor;
|
||||||
int32_t ccolor;
|
int32_t ccolor;
|
||||||
int resize;
|
int *distance;
|
||||||
int *zbuffer;
|
|
||||||
int treasure;
|
int treasure;
|
||||||
int tottreasure;
|
int tottreasure;
|
||||||
int enemies;
|
int enemies;
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/* By: houtworm <codam@houtworm.net> +#+ */
|
/* By: houtworm <codam@houtworm.net> +#+ */
|
||||||
/* +#+ */
|
/* +#+ */
|
||||||
/* Created: 2023/10/26 16:54:20 by houtworm #+# #+# */
|
/* Created: 2023/10/26 16:54:20 by houtworm #+# #+# */
|
||||||
/* Updated: 2023/11/05 03:05:46 by houtworm ######## odam.nl */
|
/* Updated: 2023/11/05 04:13:07 by houtworm ######## odam.nl */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -109,7 +109,7 @@ void ft_drawsprites(t_varlist *vl)
|
|||||||
while (x < drawendx)
|
while (x < drawendx)
|
||||||
{
|
{
|
||||||
texx = (int)(256 * (x - (-spritewidth / 2 + spritescreenx)) * 64 / spritewidth) / 256;
|
texx = (int)(256 * (x - (-spritewidth / 2 + spritescreenx)) * 64 / spritewidth) / 256;
|
||||||
if (transformy > 0 && x > 0 && x < vl->w && transformy < vl->zbuffer[x] + 0.7)
|
if (transformy > 0 && x > 0 && x < vl->w && transformy < vl->distance[x] + 0.7)
|
||||||
{
|
{
|
||||||
y = drawstarty;
|
y = drawstarty;
|
||||||
while (y < drawendy)
|
while (y < drawendy)
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/* By: houtworm <codam@houtworm.net> +#+ */
|
/* By: houtworm <codam@houtworm.net> +#+ */
|
||||||
/* +#+ */
|
/* +#+ */
|
||||||
/* Created: 2023/10/26 16:49:12 by houtworm #+# #+# */
|
/* Created: 2023/10/26 16:49:12 by houtworm #+# #+# */
|
||||||
/* Updated: 2023/11/05 02:59:50 by houtworm ######## odam.nl */
|
/* Updated: 2023/11/05 04:13:14 by houtworm ######## odam.nl */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -19,7 +19,7 @@ t_varlist initvarlist(void)
|
|||||||
vl.w = 800;
|
vl.w = 800;
|
||||||
vl.h = 600;
|
vl.h = 600;
|
||||||
vl.sprite = ft_calloc(4096, 8);
|
vl.sprite = ft_calloc(4096, 8);
|
||||||
vl.zbuffer = ft_calloc(4096, 8);
|
vl.distance = ft_calloc(4096, 8);
|
||||||
vl.spritecount = 0;
|
vl.spritecount = 0;
|
||||||
vl.vaim = 0;
|
vl.vaim = 0;
|
||||||
vl.jump = 0;
|
vl.jump = 0;
|
||||||
|
80
src/keys.c
80
src/keys.c
@ -6,7 +6,7 @@
|
|||||||
/* By: houtworm <codam@houtworm.net> +#+ */
|
/* By: houtworm <codam@houtworm.net> +#+ */
|
||||||
/* +#+ */
|
/* +#+ */
|
||||||
/* Created: 2023/10/26 16:50:23 by houtworm #+# #+# */
|
/* Created: 2023/10/26 16:50:23 by houtworm #+# #+# */
|
||||||
/* Updated: 2023/11/05 03:15:39 by houtworm ######## odam.nl */
|
/* Updated: 2023/11/05 04:05:51 by houtworm ######## odam.nl */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -16,7 +16,11 @@ void ft_movementkeys(t_varlist *vl)
|
|||||||
{
|
{
|
||||||
double temp;
|
double temp;
|
||||||
double distance;
|
double distance;
|
||||||
|
double movespeed;
|
||||||
|
double rotspeed;
|
||||||
|
|
||||||
|
movespeed = vl->frametime * 3.0;
|
||||||
|
rotspeed = vl->frametime * 3.0;
|
||||||
if (vl->side)
|
if (vl->side)
|
||||||
distance = vl->sidedisty - vl->deltadisty;
|
distance = vl->sidedisty - vl->deltadisty;
|
||||||
else
|
else
|
||||||
@ -26,80 +30,80 @@ void ft_movementkeys(t_varlist *vl)
|
|||||||
if (mlx_is_key_down(vl->mlx, MLX_KEY_SPACE) && vl->jump < 10)
|
if (mlx_is_key_down(vl->mlx, MLX_KEY_SPACE) && vl->jump < 10)
|
||||||
vl->jump = 200;
|
vl->jump = 200;
|
||||||
else if (vl->jump > 0)
|
else if (vl->jump > 0)
|
||||||
vl->jump = vl->jump - 150 * vl->movespeed;
|
vl->jump = vl->jump - 150 * movespeed;
|
||||||
if (mlx_is_key_down(vl->mlx, MLX_KEY_LEFT_CONTROL))
|
if (mlx_is_key_down(vl->mlx, MLX_KEY_LEFT_CONTROL))
|
||||||
vl->jump = -200;
|
vl->jump = -200;
|
||||||
else if (vl->jump < 0)
|
else if (vl->jump < 0)
|
||||||
vl->jump = vl->jump + 150 * vl->movespeed;
|
vl->jump = vl->jump + 150 * movespeed;
|
||||||
if (mlx_is_key_down(vl->mlx, MLX_KEY_W))
|
if (mlx_is_key_down(vl->mlx, MLX_KEY_W))
|
||||||
{
|
{
|
||||||
if (vl->map[(int)(vl->posx + vl->dirx * vl->movespeed)][(int)vl->posy] == '0' && distance > 0.4)
|
if (vl->map[(int)(vl->posx + vl->dirx * movespeed)][(int)vl->posy] == '0' && distance > 0.4)
|
||||||
{
|
{
|
||||||
vl->posx += vl->dirx * vl->movespeed * vl->run;
|
vl->posx += vl->dirx * movespeed * vl->run;
|
||||||
vl->posy += vl->diry * vl->movespeed * vl->run;
|
vl->posy += vl->diry * movespeed * vl->run;
|
||||||
}
|
}
|
||||||
if (vl->map[(int)vl->posx][(int)(vl->posy + vl->diry * vl->movespeed)] == '0' && distance > 0.4)
|
if (vl->map[(int)vl->posx][(int)(vl->posy + vl->diry * movespeed)] == '0' && distance > 0.4)
|
||||||
{
|
{
|
||||||
vl->posx += vl->dirx * vl->movespeed * vl->run;
|
vl->posx += vl->dirx * movespeed * vl->run;
|
||||||
vl->posy += vl->diry * vl->movespeed * vl->run;
|
vl->posy += vl->diry * movespeed * vl->run;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (mlx_is_key_down(vl->mlx, MLX_KEY_A))
|
if (mlx_is_key_down(vl->mlx, MLX_KEY_A))
|
||||||
{
|
{
|
||||||
if (vl->map[(int)(vl->posx - vl->dirx * vl->movespeed)][(int)vl->posy] == '0' && distance > 0.4)
|
if (vl->map[(int)(vl->posx - vl->dirx * movespeed)][(int)vl->posy] == '0' && distance > 0.4)
|
||||||
{
|
{
|
||||||
vl->posx -= vl->diry * vl->movespeed * vl->run;
|
vl->posx -= vl->diry * movespeed * vl->run;
|
||||||
vl->posy += vl->dirx * vl->movespeed * vl->run;
|
vl->posy += vl->dirx * movespeed * vl->run;
|
||||||
}
|
}
|
||||||
if (vl->map[(int)vl->posx][(int)(vl->posy - vl->diry * vl->movespeed)] == '0' && distance > 0.4)
|
if (vl->map[(int)vl->posx][(int)(vl->posy - vl->diry * movespeed)] == '0' && distance > 0.4)
|
||||||
{
|
{
|
||||||
vl->posx -= vl->diry * vl->movespeed * vl->run;
|
vl->posx -= vl->diry * movespeed * vl->run;
|
||||||
vl->posy += vl->dirx * vl->movespeed * vl->run;
|
vl->posy += vl->dirx * movespeed * vl->run;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (mlx_is_key_down(vl->mlx, MLX_KEY_S))
|
if (mlx_is_key_down(vl->mlx, MLX_KEY_S))
|
||||||
{
|
{
|
||||||
if (vl->map[(int)(vl->posx - vl->dirx * vl->movespeed)][(int)vl->posy] == '0' && distance > 0.4)
|
if (vl->map[(int)(vl->posx - vl->dirx * movespeed)][(int)vl->posy] == '0' && distance > 0.4)
|
||||||
{
|
{
|
||||||
vl->posx -= vl->dirx * vl->movespeed * vl->run;
|
vl->posx -= vl->dirx * movespeed * vl->run;
|
||||||
vl->posy -= vl->diry * vl->movespeed * vl->run;
|
vl->posy -= vl->diry * movespeed * vl->run;
|
||||||
}
|
}
|
||||||
if (vl->map[(int)vl->posx][(int)(vl->posy - vl->diry * vl->movespeed)] == '0' && distance > 0.4)
|
if (vl->map[(int)vl->posx][(int)(vl->posy - vl->diry * movespeed)] == '0' && distance > 0.4)
|
||||||
{
|
{
|
||||||
vl->posx -= vl->dirx * vl->movespeed * vl->run;
|
vl->posx -= vl->dirx * movespeed * vl->run;
|
||||||
vl->posy -= vl->diry * vl->movespeed * vl->run;
|
vl->posy -= vl->diry * movespeed * vl->run;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (mlx_is_key_down(vl->mlx, MLX_KEY_D))
|
if (mlx_is_key_down(vl->mlx, MLX_KEY_D))
|
||||||
{
|
{
|
||||||
if (vl->map[(int)(vl->posx + vl->dirx * vl->movespeed)][(int)vl->posy] == '0' && distance > 0.4)
|
if (vl->map[(int)(vl->posx + vl->dirx * movespeed)][(int)vl->posy] == '0' && distance > 0.4)
|
||||||
{
|
{
|
||||||
vl->posx += vl->diry * vl->movespeed * vl->run;
|
vl->posx += vl->diry * movespeed * vl->run;
|
||||||
vl->posy -= vl->dirx * vl->movespeed * vl->run;
|
vl->posy -= vl->dirx * movespeed * vl->run;
|
||||||
}
|
}
|
||||||
if (vl->map[(int)vl->posx][(int)(vl->posy + vl->diry * vl->movespeed)] == '0' && distance > 0.4)
|
if (vl->map[(int)vl->posx][(int)(vl->posy + vl->diry * movespeed)] == '0' && distance > 0.4)
|
||||||
{
|
{
|
||||||
vl->posx += vl->diry * vl->movespeed * vl->run;
|
vl->posx += vl->diry * movespeed * vl->run;
|
||||||
vl->posy -= vl->dirx * vl->movespeed * vl->run;
|
vl->posy -= vl->dirx * movespeed * vl->run;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (mlx_is_key_down(vl->mlx, MLX_KEY_LEFT))
|
if (mlx_is_key_down(vl->mlx, MLX_KEY_LEFT))
|
||||||
{
|
{
|
||||||
temp = vl->dirx;
|
temp = vl->dirx;
|
||||||
vl->dirx = temp * cos(vl->rotspeed) - vl->diry * sin(vl->rotspeed);
|
vl->dirx = temp * cos(rotspeed) - vl->diry * sin(rotspeed);
|
||||||
vl->diry = temp * sin(vl->rotspeed) + vl->diry * cos(vl->rotspeed);
|
vl->diry = temp * sin(rotspeed) + vl->diry * cos(rotspeed);
|
||||||
temp = vl->planex;
|
temp = vl->planex;
|
||||||
vl->planex = temp * cos(vl->rotspeed) - vl->planey * sin(vl->rotspeed);
|
vl->planex = temp * cos(rotspeed) - vl->planey * sin(rotspeed);
|
||||||
vl->planey = temp * sin(vl->rotspeed) + vl->planey * cos(vl->rotspeed);
|
vl->planey = temp * sin(rotspeed) + vl->planey * cos(rotspeed);
|
||||||
}
|
}
|
||||||
if (mlx_is_key_down(vl->mlx, MLX_KEY_RIGHT))
|
if (mlx_is_key_down(vl->mlx, MLX_KEY_RIGHT))
|
||||||
{
|
{
|
||||||
temp = vl->dirx;
|
temp = vl->dirx;
|
||||||
vl->dirx = temp * cos(-vl->rotspeed) - vl->diry * sin(-vl->rotspeed);
|
vl->dirx = temp * cos(-rotspeed) - vl->diry * sin(-rotspeed);
|
||||||
vl->diry = temp * sin(-vl->rotspeed) + vl->diry * cos(-vl->rotspeed);
|
vl->diry = temp * sin(-rotspeed) + vl->diry * cos(-rotspeed);
|
||||||
temp = vl->planex;
|
temp = vl->planex;
|
||||||
vl->planex = temp * cos(-vl->rotspeed) - vl->planey * sin(-vl->rotspeed);
|
vl->planex = temp * cos(-rotspeed) - vl->planey * sin(-rotspeed);
|
||||||
vl->planey = temp * sin(-vl->rotspeed) + vl->planey * cos(-vl->rotspeed);
|
vl->planey = temp * sin(-rotspeed) + vl->planey * cos(-rotspeed);
|
||||||
}
|
}
|
||||||
if (mlx_is_key_down(vl->mlx, MLX_KEY_LEFT_SHIFT))
|
if (mlx_is_key_down(vl->mlx, MLX_KEY_LEFT_SHIFT))
|
||||||
vl->run = 2;
|
vl->run = 2;
|
||||||
@ -142,12 +146,14 @@ void cursorhook(double xpos, double ypos, void *param)
|
|||||||
double olddirx;
|
double olddirx;
|
||||||
double oldplanex;
|
double oldplanex;
|
||||||
double speed;
|
double speed;
|
||||||
|
double rotspeed;
|
||||||
|
|
||||||
vl = param;
|
vl = param;
|
||||||
ypos++;
|
ypos++;
|
||||||
|
rotspeed = vl->frametime * 3.0;
|
||||||
if (xpos < vl->oldmouseposx)
|
if (xpos < vl->oldmouseposx)
|
||||||
{
|
{
|
||||||
speed = (vl->oldmouseposx - xpos) * vl->rotspeed / 20;
|
speed = (vl->oldmouseposx - xpos) * rotspeed / 20;
|
||||||
olddirx = vl->dirx;
|
olddirx = vl->dirx;
|
||||||
vl->dirx = vl->dirx * cos(speed) - vl->diry * sin(speed);
|
vl->dirx = vl->dirx * cos(speed) - vl->diry * sin(speed);
|
||||||
vl->diry = olddirx * sin(speed) + vl->diry * cos(speed);
|
vl->diry = olddirx * sin(speed) + vl->diry * cos(speed);
|
||||||
@ -157,7 +163,7 @@ void cursorhook(double xpos, double ypos, void *param)
|
|||||||
}
|
}
|
||||||
if (xpos > vl->oldmouseposx)
|
if (xpos > vl->oldmouseposx)
|
||||||
{
|
{
|
||||||
speed = (xpos - vl->oldmouseposx) * vl->rotspeed / 20;
|
speed = (xpos - vl->oldmouseposx) * rotspeed / 20;
|
||||||
olddirx = vl->dirx;
|
olddirx = vl->dirx;
|
||||||
vl->dirx = vl->dirx * cos(-speed) - vl->diry * sin(-speed);
|
vl->dirx = vl->dirx * cos(-speed) - vl->diry * sin(-speed);
|
||||||
vl->diry = olddirx * sin(-speed) + vl->diry * cos(-speed);
|
vl->diry = olddirx * sin(-speed) + vl->diry * cos(-speed);
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/* By: houtworm <codam@houtworm.net> +#+ */
|
/* By: houtworm <codam@houtworm.net> +#+ */
|
||||||
/* +#+ */
|
/* +#+ */
|
||||||
/* Created: 2023/10/26 14:13:07 by houtworm #+# #+# */
|
/* Created: 2023/10/26 14:13:07 by houtworm #+# #+# */
|
||||||
/* Updated: 2023/11/04 04:34:54 by houtworm ######## odam.nl */
|
/* Updated: 2023/11/05 04:01:49 by houtworm ######## odam.nl */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -40,8 +40,6 @@ void ft_frametime(t_varlist *vl)
|
|||||||
char *print;
|
char *print;
|
||||||
|
|
||||||
vl->frametime = vl->mlx->delta_time;
|
vl->frametime = vl->mlx->delta_time;
|
||||||
vl->movespeed = vl->frametime * 3.0;
|
|
||||||
vl->rotspeed = vl->frametime * 3.0;
|
|
||||||
itoa = ft_itoa(1 / vl->frametime);
|
itoa = ft_itoa(1 / vl->frametime);
|
||||||
print = ft_strjoin(itoa, " FPS");
|
print = ft_strjoin(itoa, " FPS");
|
||||||
vl->fps = mlx_put_string(vl->mlx, print, 10, 10);
|
vl->fps = mlx_put_string(vl->mlx, print, 10, 10);
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/* By: djonker <codam@houtworm.net> +#+ */
|
/* By: djonker <codam@houtworm.net> +#+ */
|
||||||
/* +#+ */
|
/* +#+ */
|
||||||
/* Created: 2023/10/27 14:36:42 by djonker #+# #+# */
|
/* Created: 2023/10/27 14:36:42 by djonker #+# #+# */
|
||||||
/* Updated: 2023/11/05 03:03:31 by houtworm ######## odam.nl */
|
/* Updated: 2023/11/05 04:12:59 by houtworm ######## odam.nl */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -14,57 +14,63 @@
|
|||||||
|
|
||||||
void ft_raycast(t_varlist *vl)
|
void ft_raycast(t_varlist *vl)
|
||||||
{
|
{
|
||||||
int x;
|
int x;
|
||||||
int drawstart;
|
int drawstart;
|
||||||
int drawend;
|
int drawend;
|
||||||
|
double camerax;
|
||||||
|
int mapx;
|
||||||
|
int mapy;
|
||||||
|
int stepx;
|
||||||
|
int stepy;
|
||||||
|
int hit;
|
||||||
|
|
||||||
x = 1;
|
x = 1;
|
||||||
while (x <= vl->w)
|
while (x <= vl->w)
|
||||||
{
|
{
|
||||||
vl->camerax = 2 * x / (double)vl->w - 1;
|
camerax = 2 * x / (double)vl->w - 1;
|
||||||
vl->raydirx = vl->dirx + vl->planex * vl->camerax;
|
vl->raydirx = vl->dirx + vl->planex * camerax;
|
||||||
vl->raydiry = vl->diry + vl->planey * vl->camerax;
|
vl->raydiry = vl->diry + vl->planey * camerax;
|
||||||
vl->mapx = (int)vl->posx;
|
mapx = (int)vl->posx;
|
||||||
vl->mapy = (int)vl->posy;
|
mapy = (int)vl->posy;
|
||||||
vl->deltadistx = fabs(1 / vl->raydirx);
|
vl->deltadistx = fabs(1 / vl->raydirx);
|
||||||
vl->deltadisty = fabs(1 / vl->raydiry);
|
vl->deltadisty = fabs(1 / vl->raydiry);
|
||||||
vl->hit = 0;
|
hit = 0;
|
||||||
if (vl->raydirx < 0)
|
if (vl->raydirx < 0)
|
||||||
{
|
{
|
||||||
vl->stepx = -1;
|
stepx = -1;
|
||||||
vl->sidedistx = (vl->posx - vl->mapx) * vl->deltadistx;
|
vl->sidedistx = (vl->posx - mapx) * vl->deltadistx;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
vl->stepx = 1;
|
stepx = 1;
|
||||||
vl->sidedistx = (vl->mapx + 1.0 - vl->posx) * vl->deltadistx;
|
vl->sidedistx = (mapx + 1.0 - vl->posx) * vl->deltadistx;
|
||||||
}
|
}
|
||||||
if (vl->raydiry < 0)
|
if (vl->raydiry < 0)
|
||||||
{
|
{
|
||||||
vl->stepy = -1;
|
stepy = -1;
|
||||||
vl->sidedisty = (vl->posy - vl->mapy) * vl->deltadisty;
|
vl->sidedisty = (vl->posy - mapy) * vl->deltadisty;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
vl->stepy = 1;
|
stepy = 1;
|
||||||
vl->sidedisty = (vl->mapy + 1.0 - vl->posy) * vl->deltadisty;
|
vl->sidedisty = (mapy + 1.0 - vl->posy) * vl->deltadisty;
|
||||||
}
|
}
|
||||||
while (vl->hit == 0)
|
while (hit == 0)
|
||||||
{
|
{
|
||||||
if (vl->sidedistx < vl->sidedisty)
|
if (vl->sidedistx < vl->sidedisty)
|
||||||
{
|
{
|
||||||
vl->sidedistx += vl->deltadistx;
|
vl->sidedistx += vl->deltadistx;
|
||||||
vl->mapx += vl->stepx;
|
mapx += stepx;
|
||||||
vl->side = 0;
|
vl->side = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
vl->sidedisty += vl->deltadisty;
|
vl->sidedisty += vl->deltadisty;
|
||||||
vl->mapy += vl->stepy;
|
mapy += stepy;
|
||||||
vl->side = 1;
|
vl->side = 1;
|
||||||
}
|
}
|
||||||
if (vl->map[vl->mapx][vl->mapy] == '1')
|
if (vl->map[mapx][mapy] == '1')
|
||||||
vl->hit = 1;
|
hit = 1;
|
||||||
}
|
}
|
||||||
if (vl->side == 0)
|
if (vl->side == 0)
|
||||||
vl->perpwalldist = (vl->sidedistx - vl->deltadistx);
|
vl->perpwalldist = (vl->sidedistx - vl->deltadistx);
|
||||||
@ -78,7 +84,7 @@ void ft_raycast(t_varlist *vl)
|
|||||||
if (drawend >= vl->h)
|
if (drawend >= vl->h)
|
||||||
drawend = vl->h - 1;
|
drawend = vl->h - 1;
|
||||||
ft_drawline(x, vl, drawstart, drawend);
|
ft_drawline(x, vl, drawstart, drawend);
|
||||||
vl->zbuffer[x] = vl->perpwalldist;
|
vl->distance[x] = vl->perpwalldist;
|
||||||
x++;
|
x++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user