weapon selection is working
This commit is contained in:
parent
0c006f726b
commit
57b23d89f9
3
cub3d.h
3
cub3d.h
@ -6,7 +6,7 @@
|
||||
/* By: houtworm <codam@houtworm.net> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2023/10/26 10:46:35 by houtworm #+# #+# */
|
||||
/* Updated: 2023/11/05 11:52:12 by houtworm ######## odam.nl */
|
||||
/* Updated: 2023/11/05 21:40:56 by houtworm ######## odam.nl */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -94,6 +94,7 @@ typedef struct s_varlist
|
||||
int mgun;
|
||||
int ggun;
|
||||
int ammo;
|
||||
int weapon;
|
||||
} t_varlist;
|
||||
|
||||
// MAIN
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: houtworm <codam@houtworm.net> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2023/10/26 16:50:23 by houtworm #+# #+# */
|
||||
/* Updated: 2023/11/05 07:36:08 by houtworm ######## odam.nl */
|
||||
/* Updated: 2023/11/05 20:16:38 by houtworm ######## odam.nl */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: houtworm <codam@houtworm.net> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2023/10/26 16:50:23 by houtworm #+# #+# */
|
||||
/* Updated: 2023/11/05 19:21:34 by houtworm ######## odam.nl */
|
||||
/* Updated: 2023/11/05 20:42:52 by houtworm ######## odam.nl */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -14,57 +14,33 @@
|
||||
|
||||
void ft_moveforward(t_varlist *vl, double movespeed)
|
||||
{
|
||||
double distance;
|
||||
|
||||
if (vl->side)
|
||||
distance = vl->sidedisty - vl->deltadisty;
|
||||
else
|
||||
distance = vl->sidedistx - vl->deltadistx;
|
||||
if (vl->map[(int)(vl->posx + vl->dirx * movespeed)][(int)vl->posy] == '0' && distance > 0.4)
|
||||
if (vl->map[(int)(vl->posx + vl->dirx * movespeed)][(int)vl->posy] == '0')
|
||||
vl->posx += vl->dirx * movespeed;
|
||||
if (vl->map[(int)vl->posx][(int)(vl->posy + vl->diry * movespeed)] == '0' && distance > 0.4)
|
||||
if (vl->map[(int)vl->posx][(int)(vl->posy + vl->diry * movespeed)] == '0')
|
||||
vl->posy += vl->diry * movespeed;
|
||||
}
|
||||
|
||||
void ft_movebackward(t_varlist *vl, double movespeed)
|
||||
{
|
||||
double distance;
|
||||
|
||||
if (vl->side)
|
||||
distance = vl->sidedisty - vl->deltadisty;
|
||||
else
|
||||
distance = vl->sidedistx - vl->deltadistx;
|
||||
if (vl->map[(int)(vl->posx - vl->dirx * movespeed)][(int)vl->posy] == '0' && distance > 0.4)
|
||||
if (vl->map[(int)(vl->posx - vl->dirx * movespeed)][(int)vl->posy] == '0')
|
||||
vl->posx -= vl->dirx * movespeed;
|
||||
if (vl->map[(int)vl->posx][(int)(vl->posy - vl->diry * movespeed)] == '0' && distance > 0.4)
|
||||
if (vl->map[(int)vl->posx][(int)(vl->posy - vl->diry * movespeed)] == '0')
|
||||
vl->posy -= vl->diry * movespeed;
|
||||
}
|
||||
|
||||
void ft_moveleft(t_varlist *vl, double movespeed)
|
||||
{
|
||||
double distance;
|
||||
|
||||
if (vl->side)
|
||||
distance = vl->sidedisty - vl->deltadisty;
|
||||
else
|
||||
distance = vl->sidedistx - vl->deltadistx;
|
||||
if (vl->map[(int)(vl->posx - vl->dirx * movespeed)][(int)vl->posy] == '0' && distance > 0.4)
|
||||
if (vl->map[(int)(vl->posx - vl->dirx * movespeed)][(int)vl->posy] == '0')
|
||||
vl->posx -= vl->diry * movespeed;
|
||||
if (vl->map[(int)vl->posx][(int)(vl->posy + vl->diry * movespeed)] == '0' && distance > 0.4)
|
||||
if (vl->map[(int)vl->posx][(int)(vl->posy + vl->diry * movespeed)] == '0')
|
||||
vl->posy += vl->dirx * movespeed;
|
||||
}
|
||||
|
||||
void ft_moveright(t_varlist *vl, double movespeed)
|
||||
{
|
||||
double distance;
|
||||
|
||||
if (vl->side)
|
||||
distance = vl->sidedisty - vl->deltadisty;
|
||||
else
|
||||
distance = vl->sidedistx - vl->deltadistx;
|
||||
if (vl->map[(int)(vl->posx + vl->dirx * movespeed)][(int)vl->posy] == '0' && distance > 0.4)
|
||||
if (vl->map[(int)(vl->posx + vl->dirx * movespeed)][(int)vl->posy] == '0')
|
||||
vl->posx += vl->diry * movespeed;
|
||||
if (vl->map[(int)vl->posx][(int)(vl->posy - vl->diry * movespeed)] == '0' && distance > 0.4)
|
||||
if (vl->map[(int)vl->posx][(int)(vl->posy - vl->diry * movespeed)] == '0')
|
||||
vl->posy -= vl->dirx * movespeed;
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: houtworm <codam@houtworm.net> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2023/10/26 16:50:23 by houtworm #+# #+# */
|
||||
/* Updated: 2023/11/05 07:35:52 by houtworm ######## odam.nl */
|
||||
/* Updated: 2023/11/05 21:51:13 by houtworm ######## odam.nl */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -36,6 +36,54 @@ void ft_processguns(t_varlist *vl)
|
||||
ft_putendl("zoom");
|
||||
}
|
||||
|
||||
void ft_nextweapon(t_varlist *vl)
|
||||
{
|
||||
if (vl->weapon == 0)
|
||||
vl->weapon = 1;
|
||||
else if (vl->weapon == 1)
|
||||
{
|
||||
if (vl->mgun == 1)
|
||||
vl->weapon = 2;
|
||||
else if (vl->ggun == 1)
|
||||
vl->weapon = 3;
|
||||
else
|
||||
vl->weapon = 0;
|
||||
}
|
||||
else if (vl->weapon == 2)
|
||||
{
|
||||
if (vl->ggun == 1)
|
||||
vl->weapon = 3;
|
||||
else
|
||||
vl->weapon = 0;
|
||||
}
|
||||
else if (vl->weapon == 3)
|
||||
vl->weapon = 0;
|
||||
}
|
||||
|
||||
void ft_prevweapon(t_varlist *vl)
|
||||
{
|
||||
if (vl->weapon == 0)
|
||||
{
|
||||
if (vl->ggun == 1)
|
||||
vl->weapon = 3;
|
||||
else if (vl->mgun == 1)
|
||||
vl->weapon = 2;
|
||||
else
|
||||
vl->weapon = 1;
|
||||
}
|
||||
else if (vl->weapon == 1)
|
||||
vl->weapon = 0;
|
||||
else if (vl->weapon == 2)
|
||||
vl->weapon = 1;
|
||||
else if (vl->weapon == 3)
|
||||
{
|
||||
if (vl->mgun == 1)
|
||||
vl->weapon = 2;
|
||||
else
|
||||
vl->weapon = 1;
|
||||
}
|
||||
}
|
||||
|
||||
void scrollhook(double xdelta, double ydelta, void *param)
|
||||
{
|
||||
t_varlist *vl;
|
||||
@ -44,7 +92,7 @@ void scrollhook(double xdelta, double ydelta, void *param)
|
||||
vl = vl;
|
||||
xdelta++;
|
||||
if (ydelta > 0)
|
||||
ft_putendl("Previous Weapon");
|
||||
ft_prevweapon(vl);
|
||||
if (ydelta < 0)
|
||||
ft_putendl("Next Weapon");
|
||||
ft_nextweapon(vl);
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: houtworm <codam@houtworm.net> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2023/10/26 14:13:07 by houtworm #+# #+# */
|
||||
/* Updated: 2023/11/05 19:21:37 by houtworm ######## odam.nl */
|
||||
/* Updated: 2023/11/05 21:50:28 by houtworm ######## odam.nl */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -33,12 +33,22 @@ void ft_printmap(t_varlist *vl)
|
||||
}
|
||||
double movespeed;
|
||||
movespeed = vl->frametime * 3.0;
|
||||
printf("foreward: %c, %c\n", vl->map[(int)(vl->posx + vl->dirx * movespeed)][(int)vl->posy], vl->map[(int)vl->posx][(int)(vl->posy + vl->diry * movespeed)]);
|
||||
printf("backward: %c, %c\n", vl->map[(int)(vl->posx - vl->dirx * movespeed)][(int)vl->posy], vl->map[(int)vl->posx][(int)(vl->posy - vl->diry * movespeed)]);
|
||||
printf("leftward: %c, %c\n", vl->map[(int)(vl->posx - vl->dirx * movespeed)][(int)vl->posy], vl->map[(int)vl->posx][(int)(vl->posy + vl->diry * movespeed)]);
|
||||
printf("righward: %c, %c\n", vl->map[(int)(vl->posx + vl->dirx * movespeed)][(int)vl->posy], vl->map[(int)vl->posx][(int)(vl->posy - vl->diry * movespeed)]);
|
||||
printf("side: %d\n", vl->side);
|
||||
printf("raydirx: %lf\n", vl->raydirx);
|
||||
printf("raydiry: %lf\n", vl->raydiry);
|
||||
printf("forward: x: %c, y: %c\n", vl->map[(int)(vl->posx + vl->dirx * movespeed)][(int)vl->posy], vl->map[(int)vl->posx][(int)(vl->posy + vl->diry * movespeed)]);
|
||||
printf("backward: x: %c, y: %c\n", vl->map[(int)(vl->posx - vl->dirx * movespeed)][(int)vl->posy], vl->map[(int)vl->posx][(int)(vl->posy - vl->diry * movespeed)]);
|
||||
printf("left: x: %c, y: %c\n", vl->map[(int)(vl->posx - vl->dirx * movespeed)][(int)vl->posy], vl->map[(int)vl->posx][(int)(vl->posy + vl->diry * movespeed)]);
|
||||
printf("right: x: %c, y: %c\n", vl->map[(int)(vl->posx + vl->dirx * movespeed)][(int)vl->posy], vl->map[(int)vl->posx][(int)(vl->posy - vl->diry * movespeed)]);
|
||||
printf("weapon: %d\n", vl->weapon);
|
||||
}
|
||||
|
||||
/*void ft_drawweapon(t_varlist *vl)*/
|
||||
/*{*/
|
||||
|
||||
|
||||
/*}*/
|
||||
|
||||
void mainloop(void *param)
|
||||
{
|
||||
t_varlist *vl;
|
||||
@ -47,15 +57,15 @@ void mainloop(void *param)
|
||||
ft_replaceimage(vl);
|
||||
ft_drawmap(vl);
|
||||
ft_checkpickup(vl);
|
||||
/*ft_enemyaction(vl);*/
|
||||
ft_drawsprites(vl);
|
||||
/*ft_drawweapon(vl);*/
|
||||
/*ft_drawminimap(vl);*/
|
||||
vl->frametime = vl->mlx->delta_time;
|
||||
ft_printstats(vl);
|
||||
/*ft_enemyaction(vl);*/
|
||||
vl->frametime = vl->mlx->delta_time;
|
||||
ft_processinput(vl);
|
||||
/*ft_printmap(vl);*/
|
||||
ft_printmap(vl);
|
||||
if (!vl->img || (mlx_image_to_window(vl->mlx, vl->img, 0, 0) < 0))
|
||||
ft_errorexit("image to window failed ", "mainloop", 1);
|
||||
mlx_set_instance_depth(vl->img->instances, 1);
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: houtworm <codam@houtworm.net> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2023/10/26 16:54:20 by houtworm #+# #+# */
|
||||
/* Updated: 2023/11/05 11:30:18 by houtworm ######## odam.nl */
|
||||
/* Updated: 2023/11/05 21:27:51 by houtworm ######## odam.nl */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user