diff options
| author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-03-16 16:46:55 +0100 | 
|---|---|---|
| committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-03-16 16:46:55 +0100 | 
| commit | a67bc79504a399ad0194d104aa250725bf6280b1 (patch) | |
| tree | 11baea826121a1295b48fd084357577b7d0dbfac | |
| parent | Added bonus rule (diff) | |
| download | 42-cub3d-a67bc79504a399ad0194d104aa250725bf6280b1.tar.gz 42-cub3d-a67bc79504a399ad0194d104aa250725bf6280b1.tar.bz2 42-cub3d-a67bc79504a399ad0194d104aa250725bf6280b1.tar.xz 42-cub3d-a67bc79504a399ad0194d104aa250725bf6280b1.tar.zst 42-cub3d-a67bc79504a399ad0194d104aa250725bf6280b1.zip | |
Debug in progress
Diffstat (limited to '')
| -rw-r--r-- | Makefile | 1 | ||||
| -rw-r--r-- | inc/cub3d.h | 1 | ||||
| -rw-r--r-- | inc/cub3d_structs.h | 2 | ||||
| -rw-r--r-- | src/ft_init_lists.c | 10 | ||||
| -rw-r--r-- | src/ft_init_sprites.c | 35 | 
5 files changed, 40 insertions, 9 deletions
| @@ -97,6 +97,7 @@ SRCS_NAME	+= ft_sfx_trap.c  SRCS_NAME	+= ft_sfx_new_level.c  SRCS_NAME	+= ft_death_screen.c  SRCS_NAME	+= ft_death_hooks.c +SRCS_NAME	+= ft_init_sprites.c  #--------------------------------------------------------------------------------------------------#  SRCS		= $(addprefix ${SRCS_DIR},${SRCS_NAME})  #--------------------------------------------------------------------------------------------------# diff --git a/inc/cub3d.h b/inc/cub3d.h index 6c9a010..b524b9a 100644 --- a/inc/cub3d.h +++ b/inc/cub3d.h @@ -35,6 +35,7 @@ t_bmp_file		ft_init_bmp(void);  t_bmp_info		ft_init_bmp_info(void);  t_rgb			ft_hex_to_og_rgb(uint32_t color);  int8_t			ft_init_sfx(t_sfx *sfx); +t_sprite		**ft_init_sprites(void);  /*  ** ====== HOOKS ====== diff --git a/inc/cub3d_structs.h b/inc/cub3d_structs.h index 7545f3b..9ea3d08 100644 --- a/inc/cub3d_structs.h +++ b/inc/cub3d_structs.h @@ -243,7 +243,7 @@ typedef struct			s_cub  	struct s_rgb		f_rgb;  	struct s_rgb		c_rgb;  	struct s_img		tlist[16]; -	struct s_sprite		sprites[8][4096]; +	struct s_sprite		**sprites;  	struct s_sprite		traps[512];  	struct s_sfx		sfx;  }						t_cub; diff --git a/src/ft_init_lists.c b/src/ft_init_lists.c index 3e4dc96..fa862ae 100644 --- a/src/ft_init_lists.c +++ b/src/ft_init_lists.c @@ -11,7 +11,6 @@  /* ************************************************************************** */  #include <libft.h> -#include <mlx.h>  #include <cub3d.h>  #include <stddef.h>  #include <stdlib.h> @@ -85,22 +84,17 @@ static int8_t  	cl->walltexgood = 0;  	ft_init_funptr(cl);  	ft_init_ref(cl); +	if (!(cl->sprites = ft_init_sprites())) +		return (-1);  	return (0);  }  int8_t  	ft_init_cub3d(t_cub *clist)  { -	uint8_t	i;  	if (ft_init_cub(clist) < 0)  		return (-1);  	if (ft_init_win(&clist->wlist) < 0)  		return (-1); -	i = 0; -	while (i < 9) -	{ -		ft_bzero(clist->sprites[i], 4096); -		i++; -	}  	return (0);  } diff --git a/src/ft_init_sprites.c b/src/ft_init_sprites.c new file mode 100644 index 0000000..4fa21bf --- /dev/null +++ b/src/ft_init_sprites.c @@ -0,0 +1,35 @@ +/* ************************************************************************** */ +/*                                                                            */ +/*                                                        :::      ::::::::   */ +/*   ft_init_lists.c                                    :+:      :+:    :+:   */ +/*                                                    +:+ +:+         +:+     */ +/*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */ +/*                                                +#+#+#+#+#+   +#+           */ +/*   Created: 2020/02/14 17:28:53 by rbousset          #+#    #+#             */ +/*   Updated: 2020/02/14 17:28:53 by rbousset         ###   ########lyon.fr   */ +/*                                                                            */ +/* ************************************************************************** */ + +#include <libft.h> +#include <cub3d.h> +#include <stddef.h> +#include <stdlib.h> +#include <stdint.h> + +t_sprite +	**ft_init_sprites(void) +{ +	t_sprite	**sprites; +	uint8_t		i; + +	if (!(sprites = (t_sprite**)ft_calloc(8, sizeof(t_sprite*)))) +		return (NULL); +	i = 0; +	while (i < 9) +	{ +		if (!(sprites[i] = (t_sprite*)ft_calloc(4096, sizeof(t_sprite)))) +			return (NULL); +		i++; +	} +	return (sprites); +} | 
