aboutsummaryrefslogtreecommitdiffstats
path: root/src/ft_key_loop.c
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-03-03 16:14:26 +0100
committerJozanLeClerc <bousset.rudy@gmail.com>2020-03-03 16:14:26 +0100
commitce43b1cd1caa539af687425f58a6999a20807878 (patch)
tree34631aef16b6eb1d5d650fe9e900916f9810215d /src/ft_key_loop.c
parentMakefile update (diff)
download42-cub3d-ce43b1cd1caa539af687425f58a6999a20807878.tar.gz
42-cub3d-ce43b1cd1caa539af687425f58a6999a20807878.tar.bz2
42-cub3d-ce43b1cd1caa539af687425f58a6999a20807878.tar.xz
42-cub3d-ce43b1cd1caa539af687425f58a6999a20807878.tar.zst
42-cub3d-ce43b1cd1caa539af687425f58a6999a20807878.zip
Going full stack is bav
Diffstat (limited to 'src/ft_key_loop.c')
-rw-r--r--src/ft_key_loop.c38
1 files changed, 19 insertions, 19 deletions
diff --git a/src/ft_key_loop.c b/src/ft_key_loop.c
index 0c759db..e2e2b5c 100644
--- a/src/ft_key_loop.c
+++ b/src/ft_key_loop.c
@@ -19,13 +19,13 @@ static uint64_t
ft_find_x(int32_t key, const t_player *pl)
{
if (key == 0)
- return (pl.pos_x + (pl.dir_y * FT_COLL_MULT));
+ return (pl->pos_x + (pl->dir_y * FT_COLL_MULT));
else if (key == 1)
- return (pl.pos_x + (pl.dir_x * (FT_COLL_MULT / 2)));
+ return (pl->pos_x + (pl->dir_x * (FT_COLL_MULT / 2)));
else if (key == 2)
- return (pl.pos_x - (pl.dir_y * FT_COLL_MULT));
+ return (pl->pos_x - (pl->dir_y * FT_COLL_MULT));
else if (key == 3)
- return (pl.pos_x - (pl.dir_x * (FT_COLL_MULT / 2)));
+ return (pl->pos_x - (pl->dir_x * (FT_COLL_MULT / 2)));
return (1);
}
@@ -33,13 +33,13 @@ static uint64_t
ft_find_y(int32_t key, const t_player *pl)
{
if (key == 0)
- return (pl.pos_y + (pl.dir_x * FT_COLL_MULT));
+ return (pl->pos_y + (pl->dir_x * FT_COLL_MULT));
else if (key == 1)
- return (pl.pos_y - (pl.dir_y * (FT_COLL_MULT / 2)));
+ return (pl->pos_y - (pl->dir_y * (FT_COLL_MULT / 2)));
else if (key == 2)
- return (pl.pos_y - (pl.dir_x * FT_COLL_MULT));
+ return (pl->pos_y - (pl->dir_x * FT_COLL_MULT));
else if (key == 3)
- return (pl.pos_y + (pl.dir_y * (FT_COLL_MULT / 2)));
+ return (pl->pos_y + (pl->dir_y * (FT_COLL_MULT / 2)));
return (1);
}
@@ -50,13 +50,13 @@ static void
uint64_t y;
t_player *pl;
- pl = cl.plist;
+ pl = &cl->plist;
x = ft_find_x(key, pl);
y = ft_find_y(key, pl);
- if (cl.mlist.map[y][x] == '1' || cl.mlist.map[y][x] == '2')
+ if (cl->mlist.map[y][x] == '1' || cl->mlist.map[y][x] == '2')
{
- pl.pos_y = old_y;
- pl.pos_x = old_x;
+ pl->pos_y = old_y;
+ pl->pos_x = old_x;
}
}
@@ -64,22 +64,22 @@ int
ft_key_loop(t_cub *cl)
{
uint8_t i;
- const float old_y = cl.plist.pos_y;
- const float old_x = cl.plist.pos_x;
+ const float old_y = cl->plist.pos_y;
+ const float old_x = cl->plist.pos_x;
i = 0;
- while (i < 5 && cl.key_input[i] != -1 && cl.key_input[i] <= 5)
+ while (i < 5 && cl->key_input[i] != -1 && cl->key_input[i] <= 5)
{
- cl.key_ptr[cl.key_input[i]](cl);
- ft_collision(old_y, old_x, cl.key_input[i], cl);
- if (cl.mlist.isnlvl)
+ cl->key_ptr[cl->key_input[i]](cl);
+ ft_collision(old_y, old_x, cl->key_input[i], cl);
+ if (cl->mlist.isnlvl)
{
if (ft_warp_level(cl) < 0)
return (ft_exit(FT_RET_FAILED_STRUCTS, cl));
}
i++;
}
- if (cl.key_input[0] != -1)
+ if (cl->key_input[0] != -1)
ft_draw_scene(cl);
return (0);
}