diff --git a/Makefile b/Makefile index 4476e9c..38f504b 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ # By: houtworm +#+ # # +#+ # # Created: 2023/10/26 10:46:29 by houtworm #+# #+# # -# Updated: 2023/10/27 14:45:10 by djonker ######## odam.nl # +# Updated: 2023/10/29 06:31:28 by houtworm ######## odam.nl # # # # **************************************************************************** # diff --git a/src/keys.c b/src/keys.c index bcdb357..660232a 100644 --- a/src/keys.c +++ b/src/keys.c @@ -6,7 +6,7 @@ /* By: houtworm +#+ */ /* +#+ */ /* Created: 2023/10/26 16:50:23 by houtworm #+# #+# */ -/* Updated: 2023/10/27 15:16:02 by djonker ######## odam.nl */ +/* Updated: 2023/10/29 06:34:27 by houtworm ######## odam.nl */ /* */ /* ************************************************************************** */ @@ -21,22 +21,56 @@ void ft_movementkeys(t_varlist *vl) ft_putendl("shoot"); if (mlx_is_key_down(vl->mlx, MLX_KEY_W)) { - if (vl->map[(int)vl->posx + (int)vl->dirx * (int)vl->movespeed][(int)vl->posy] == false) - vl->posx += vl->dirx * vl->movespeed; - if (vl->map[(int)vl->posx][(int)vl->posy + (int)vl->diry * (int)vl->movespeed] == false) + /*if (!vl->map[(int)vl->posx + (int)vl->dirx * (int)vl->movespeed][(int)vl->posy])*/ + /*{*/ vl->posx += vl->dirx * vl->movespeed; + vl->posy += vl->diry * vl->movespeed; + /*}*/ + /*if (!vl->map[(int)vl->posx][(int)vl->posy + (int)vl->diry * (int)vl->movespeed])*/ + /*{*/ + /*vl->posx += vl->dirx * vl->movespeed;*/ + /*vl->posy += vl->diry * vl->movespeed;*/ + /*}*/ } if (mlx_is_key_down(vl->mlx, MLX_KEY_A)) - ft_putendl("A is pressed"); + { + /*if (!vl->map[(int)vl->posx - (int)vl->dirx * (int)vl->movespeed][(int)vl->posy])*/ + /*{*/ + /*vl->posx -= vl->diry * vl->movespeed;*/ + /*vl->posy += vl->dirx * vl->movespeed;*/ + /*}*/ + /*if (!vl->map[(int)vl->posx][(int)vl->posy - (int)vl->diry * (int)vl->movespeed])*/ + /*{*/ + vl->posx -= vl->diry * vl->movespeed; + vl->posy += vl->dirx * vl->movespeed; + /*}*/ + } if (mlx_is_key_down(vl->mlx, MLX_KEY_S)) { - if (vl->map[(int)vl->posx - (int)vl->dirx * (int)vl->movespeed][(int)vl->posy] == false) - vl->posx -= vl->dirx * vl->movespeed; - if (vl->map[(int)vl->posx][(int)vl->posy - (int)vl->diry * (int)vl->movespeed] == false) + /*if (!vl->map[(int)vl->posx - (int)vl->dirx * (int)vl->movespeed][(int)vl->posy])*/ + /*{*/ + /*vl->posx -= vl->dirx * vl->movespeed;*/ + /*vl->posy -= vl->diry * vl->movespeed;*/ + /*}*/ + /*if (!vl->map[(int)vl->posx][(int)vl->posy - (int)vl->diry * (int)vl->movespeed])*/ + /*{*/ vl->posx -= vl->dirx * vl->movespeed; + vl->posy -= vl->diry * vl->movespeed; + /*}*/ } if (mlx_is_key_down(vl->mlx, MLX_KEY_D)) - ft_putendl("D is pressed"); + { + /*if (!vl->map[(int)vl->posx + (int)vl->dirx * (int)vl->movespeed][(int)vl->posy])*/ + /*{*/ + vl->posx += vl->diry * vl->movespeed; + vl->posy -= vl->dirx * vl->movespeed; + /*}*/ + /*if (!vl->map[(int)vl->posx][(int)vl->posy + (int)vl->diry * (int)vl->movespeed])*/ + /*{*/ + /*vl->posx += vl->diry * vl->movespeed;*/ + /*vl->posy -= vl->dirx * vl->movespeed;*/ + /*}*/ + } if (mlx_is_key_down(vl->mlx, MLX_KEY_LEFT)) { olddirx = vl->dirx; diff --git a/src/raycast.c b/src/raycast.c index f3bd164..2a37665 100644 --- a/src/raycast.c +++ b/src/raycast.c @@ -6,7 +6,7 @@ /* By: djonker +#+ */ /* +#+ */ /* Created: 2023/10/27 14:36:42 by djonker #+# #+# */ -/* Updated: 2023/10/27 15:02:06 by djonker ######## odam.nl */ +/* Updated: 2023/10/29 05:53:32 by houtworm ######## odam.nl */ /* */ /* ************************************************************************** */ @@ -38,7 +38,7 @@ void ft_raycast(t_varlist *vl) else { vl->stepx = 1; - vl->sidedistx = (vl->posx + 1.0 - vl->mapx) * vl->deltadistx; + vl->sidedistx = (vl->mapx + 1.0 - vl->posx) * vl->deltadistx; } if (vl->raydiry < 0) { @@ -48,7 +48,7 @@ void ft_raycast(t_varlist *vl) else { vl->stepy = 1; - vl->sidedisty = (vl->posy + 1.0 - vl->mapy) * vl->deltadisty; + vl->sidedisty = (vl->mapy + 1.0 - vl->posy) * vl->deltadisty; } while (vl->hit == 0) {