aboutsummaryrefslogtreecommitdiff
path: root/src/helper.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/helper.c')
-rw-r--r--src/helper.c32
1 files changed, 31 insertions, 1 deletions
diff --git a/src/helper.c b/src/helper.c
index 6fa7ffe..957a5de 100644
--- a/src/helper.c
+++ b/src/helper.c
@@ -6,7 +6,7 @@
/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/01/11 07:32:20 by cacharle #+# #+# */
-/* Updated: 2020/02/01 11:32:15 by cacharle ### ########.fr */
+/* Updated: 2020/02/02 22:16:14 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -59,3 +59,33 @@ void helper_init_dir_plane(t_state *state, int y, int x)
state->plane = vector_scale(state->plane, 0.66);
state->plane = vector_apply(state->plane, &fabs);
}
+
+t_bool state_init_sprites(t_state *state)
+{
+ int i;
+ int j;
+ int counter;
+
+ counter = 0;
+ i = -1;
+ while (++i < state->map_height)
+ {
+ j = -1;
+ while (++j < state->map_width)
+ if (state->map[i][j] == CELL_ITEM)
+ counter++;
+ }
+ state->sprites_num = counter;
+ if ((state->sprites = (t_sprite*)malloc(sizeof(t_sprite) * counter)) == NULL)
+ return (FALSE);
+ counter = 0;
+ i = -1;
+ while (++i < state->map_height)
+ {
+ j = -1;
+ while (++j < state->map_width)
+ if (state->map[i][j] == CELL_ITEM)
+ state->sprites[counter++].pos = vector_new((double)j + 0.5, (double)i + 0.5);
+ }
+ return (TRUE);
+}