ammo system implemented
This commit is contained in:
parent
819642bc90
commit
7bffb146ec
5
cub3d.h
5
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/06 00:37:18 by houtworm ######## odam.nl */
|
/* Updated: 2023/11/06 01:16:25 by houtworm ######## odam.nl */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -54,6 +54,8 @@ typedef struct s_varlist
|
|||||||
mlx_image_t *tstat;
|
mlx_image_t *tstat;
|
||||||
mlx_image_t *cstat;
|
mlx_image_t *cstat;
|
||||||
mlx_image_t *kstat;
|
mlx_image_t *kstat;
|
||||||
|
mlx_image_t *astat;
|
||||||
|
mlx_image_t *hstat;
|
||||||
mlx_image_t *wimg;
|
mlx_image_t *wimg;
|
||||||
mlx_texture_t *temptext;
|
mlx_texture_t *temptext;
|
||||||
mlx_texture_t **walltext;
|
mlx_texture_t **walltext;
|
||||||
@ -105,6 +107,7 @@ typedef struct s_varlist
|
|||||||
int ammo;
|
int ammo;
|
||||||
int weapon;
|
int weapon;
|
||||||
int reload;
|
int reload;
|
||||||
|
int hp;
|
||||||
} t_varlist;
|
} t_varlist;
|
||||||
|
|
||||||
// MAIN
|
// MAIN
|
||||||
|
@ -6,13 +6,13 @@
|
|||||||
/* 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/06 00:21:45 by houtworm ######## odam.nl */
|
/* Updated: 2023/11/06 01:17:31 by houtworm ######## odam.nl */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "../../cub3d.h"
|
#include "../../cub3d.h"
|
||||||
|
|
||||||
void ft_printstats(t_varlist *vl)
|
void ft_printgamestats(t_varlist *vl)
|
||||||
{
|
{
|
||||||
char *total;
|
char *total;
|
||||||
char *current;
|
char *current;
|
||||||
@ -36,3 +36,26 @@ void ft_printstats(t_varlist *vl)
|
|||||||
mlx_set_instance_depth(vl->cstat->instances, 3);
|
mlx_set_instance_depth(vl->cstat->instances, 3);
|
||||||
mlx_set_instance_depth(vl->kstat->instances, 4);
|
mlx_set_instance_depth(vl->kstat->instances, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ft_printplayerstats(t_varlist *vl)
|
||||||
|
{
|
||||||
|
char *current;
|
||||||
|
char *temp;
|
||||||
|
|
||||||
|
current = ft_itoa(vl->ammo);
|
||||||
|
temp = ft_vastrjoin(2, "Ammo: ", current);
|
||||||
|
vl->astat = mlx_put_string(vl->mlx, temp, 10, vl->h - 30);
|
||||||
|
ft_vafree(2, temp, current);
|
||||||
|
current = ft_itoa(vl->hp);
|
||||||
|
temp = ft_vastrjoin(2, "HP: ", current);
|
||||||
|
vl->hstat = mlx_put_string(vl->mlx, temp, 10, vl->h - 50);
|
||||||
|
ft_vafree(2, temp, current);
|
||||||
|
mlx_set_instance_depth(vl->astat->instances, 6);
|
||||||
|
mlx_set_instance_depth(vl->hstat->instances, 7);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ft_printstats(t_varlist *vl)
|
||||||
|
{
|
||||||
|
ft_printgamestats(vl);
|
||||||
|
ft_printplayerstats(vl);
|
||||||
|
}
|
||||||
|
@ -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/06 00:52:07 by houtworm ######## odam.nl */
|
/* Updated: 2023/11/06 01:05:43 by houtworm ######## odam.nl */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -31,10 +31,13 @@ void ft_processacro(t_varlist *vl, double movespeed)
|
|||||||
void ft_processguns(t_varlist *vl)
|
void ft_processguns(t_varlist *vl)
|
||||||
{
|
{
|
||||||
if (mlx_is_mouse_down(vl->mlx, MLX_MOUSE_BUTTON_LEFT) && vl->reload == 0)
|
if (mlx_is_mouse_down(vl->mlx, MLX_MOUSE_BUTTON_LEFT) && vl->reload == 0)
|
||||||
|
{
|
||||||
|
if (vl->ammo || !vl->weapon)
|
||||||
{
|
{
|
||||||
vl->anitime = vl->frametime;
|
vl->anitime = vl->frametime;
|
||||||
vl->reload = 1;
|
vl->reload = 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (mlx_is_mouse_down(vl->mlx, MLX_MOUSE_BUTTON_RIGHT))
|
if (mlx_is_mouse_down(vl->mlx, MLX_MOUSE_BUTTON_RIGHT))
|
||||||
ft_putendl("zoom");
|
ft_putendl("zoom");
|
||||||
}
|
}
|
||||||
|
@ -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/06 00:53:16 by houtworm ######## odam.nl */
|
/* Updated: 2023/11/06 01:18:00 by houtworm ######## odam.nl */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -97,6 +97,7 @@ void ft_initmainstuff(t_varlist *vl)
|
|||||||
vl->mgun = 0;
|
vl->mgun = 0;
|
||||||
vl->ggun = 0;
|
vl->ggun = 0;
|
||||||
vl->ammo = 10;
|
vl->ammo = 10;
|
||||||
|
vl->hp = 100;
|
||||||
vl->weapon = 0;
|
vl->weapon = 0;
|
||||||
vl->reload = 0;
|
vl->reload = 0;
|
||||||
vl->ccolor = 0;
|
vl->ccolor = 0;
|
||||||
|
@ -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/06 00:49:31 by houtworm ######## odam.nl */
|
/* Updated: 2023/11/06 01:15:49 by houtworm ######## odam.nl */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -19,6 +19,8 @@ void ft_replaceimage(t_varlist *vl)
|
|||||||
mlx_delete_image(vl->mlx, vl->cstat);
|
mlx_delete_image(vl->mlx, vl->cstat);
|
||||||
mlx_delete_image(vl->mlx, vl->kstat);
|
mlx_delete_image(vl->mlx, vl->kstat);
|
||||||
mlx_delete_image(vl->mlx, vl->tstat);
|
mlx_delete_image(vl->mlx, vl->tstat);
|
||||||
|
mlx_delete_image(vl->mlx, vl->astat);
|
||||||
|
mlx_delete_image(vl->mlx, vl->hstat);
|
||||||
mlx_delete_image(vl->mlx, vl->wimg);
|
mlx_delete_image(vl->mlx, vl->wimg);
|
||||||
vl->img = mlx_new_image(vl->mlx, vl->w, vl->h);
|
vl->img = mlx_new_image(vl->mlx, vl->w, vl->h);
|
||||||
vl->wimg = mlx_new_image(vl->mlx, 64, 64);
|
vl->wimg = mlx_new_image(vl->mlx, 64, 64);
|
||||||
@ -80,9 +82,13 @@ void ft_fireweapon(t_varlist *vl)
|
|||||||
vl->firetime = vl->anitime;
|
vl->firetime = vl->anitime;
|
||||||
vl->reload++;
|
vl->reload++;
|
||||||
if (vl->reload > 4)
|
if (vl->reload > 4)
|
||||||
|
{
|
||||||
|
if (vl->weapon)
|
||||||
|
vl->ammo--;
|
||||||
vl->reload = 0;
|
vl->reload = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user