moving around now works perfectly
This commit is contained in:
parent
3131eb717f
commit
d6f462f9bf
2
Makefile
2
Makefile
@ -6,7 +6,7 @@
|
||||
# By: houtworm <codam@houtworm.net> +#+ #
|
||||
# +#+ #
|
||||
# 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 #
|
||||
# #
|
||||
# **************************************************************************** #
|
||||
|
||||
|
52
src/keys.c
52
src/keys.c
@ -6,7 +6,7 @@
|
||||
/* By: houtworm <codam@houtworm.net> +#+ */
|
||||
/* +#+ */
|
||||
/* 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;
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: djonker <codam@houtworm.net> +#+ */
|
||||
/* +#+ */
|
||||
/* 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)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user