aboutsummaryrefslogtreecommitdiff
path: root/src/state.c
diff options
context:
space:
mode:
authorCharles <sircharlesaze@gmail.com>2020-02-02 09:57:02 +0100
committerCharles <sircharlesaze@gmail.com>2020-02-02 09:57:02 +0100
commit628f82dbb9d44dfda7ebde0a54b6559b275e204c (patch)
treef41e8195ab7063d65142b37aefecad2b1e72535f /src/state.c
parent44e93a191badd8c23d0bb971665f335bbb38f177 (diff)
downloadcub3d-628f82dbb9d44dfda7ebde0a54b6559b275e204c.tar.gz
cub3d-628f82dbb9d44dfda7ebde0a54b6559b275e204c.tar.bz2
cub3d-628f82dbb9d44dfda7ebde0a54b6559b275e204c.zip
sprite kinda working but like walls (fml)
Diffstat (limited to 'src/state.c')
-rw-r--r--src/state.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/state.c b/src/state.c
index 11e1c65..267c6c9 100644
--- a/src/state.c
+++ b/src/state.c
@@ -6,7 +6,7 @@
/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/11/19 16:39:57 by cacharle #+# #+# */
-/* Updated: 2020/01/30 15:13:42 by cacharle ### ########.fr */
+/* Updated: 2020/02/02 09:13:06 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -42,6 +42,15 @@ t_state *state_new(t_state *state)
&state->window.depth, &state->window.size_line,
&state->window.endian);
printf("init mlx window image\n");
+ state->sprite_window.width = state->window.width;
+ state->sprite_window.height = state->window.height;
+ if ((state->sprite_window.id = mlx_new_image(state->mlx_ptr,
+ state->window.width, state->window.height)) == NULL)
+ return (state_destroy(state));
+ state->sprite_window.data = mlx_get_data_addr(state->sprite_window.id,
+ &state->sprite_window.depth, &state->sprite_window.size_line,
+ &state->sprite_window.endian);
+ printf("init mlx sprite image\n");
state_init_player(state);
printf("init player\n");
return (state);
@@ -75,6 +84,8 @@ t_state *state_new_empty(void)
return (NULL);
state->mlx_ptr = NULL;
state->window_ptr = NULL;
+ state->window.id = NULL;
+ state->sprite_window.id = NULL;
i = -1;
while (++i < TEXTURES_NUM)
{
@@ -105,6 +116,9 @@ void *state_destroy(t_state *state)
printf("free window image\n");
if (state->mlx_ptr != NULL && state->window.id != NULL)
mlx_destroy_image(state->mlx_ptr, state->window.id);
+ printf("free sprite window image\n");
+ if (state->mlx_ptr != NULL && state->sprite_window.id != NULL)
+ mlx_destroy_image(state->mlx_ptr, state->sprite_window.id);
printf("free window\n");
if (state->mlx_ptr && state->window_ptr)
mlx_destroy_window(state->mlx_ptr, state->window_ptr);