aboutsummaryrefslogtreecommitdiff
path: root/src/helper.c
diff options
context:
space:
mode:
authorCharles <sircharlesaze@gmail.com>2020-02-04 03:40:05 +0100
committerCharles <sircharlesaze@gmail.com>2020-02-04 03:40:05 +0100
commitc8de182e9fa0c8a2674bf2f13d2ed9f500607ebd (patch)
tree57bee31b2c0d95b00aab160ed5c1ec7527a13d75 /src/helper.c
parent6309d5ffd30d97af666ca306fb0df293645fc7e4 (diff)
downloadcub3d-c8de182e9fa0c8a2674bf2f13d2ed9f500607ebd.tar.gz
cub3d-c8de182e9fa0c8a2674bf2f13d2ed9f500607ebd.tar.bz2
cub3d-c8de182e9fa0c8a2674bf2f13d2ed9f500607ebd.zip
Norming
Diffstat (limited to 'src/helper.c')
-rw-r--r--src/helper.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/helper.c b/src/helper.c
index 957a5de..ca0f879 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/02 22:16:14 by cacharle ### ########.fr */
+/* Updated: 2020/02/04 02:17:38 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -57,7 +57,6 @@ void helper_init_dir_plane(t_state *state, int y, int x)
state->plane = vector_rotate(state->dir, M_PI_2);
state->plane = vector_scale(state->plane, 1.0 / vector_norm(state->plane));
state->plane = vector_scale(state->plane, 0.66);
- state->plane = vector_apply(state->plane, &fabs);
}
t_bool state_init_sprites(t_state *state)
@@ -76,16 +75,15 @@ t_bool state_init_sprites(t_state *state)
counter++;
}
state->sprites_num = counter;
- if ((state->sprites = (t_sprite*)malloc(sizeof(t_sprite) * counter)) == NULL)
+ if ((state->sprites = malloc(sizeof(t_sprite) * counter)) == NULL)
return (FALSE);
- counter = 0;
- i = -1;
- while (++i < state->map_height)
+ while (i-- > 0)
{
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);
+ state->sprites[--counter].pos =
+ vector_new((double)j + 0.5, (double)i + 0.5);
}
return (TRUE);
}