/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* fdf_commands.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: narnaud +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2021/11/05 13:59:02 by narnaud #+# #+# */ /* Updated: 2022/02/22 10:43:07 by narnaud ### ########.fr */ /* */ /* ************************************************************************** */ #include "fdf.h" void key_hook_third(int keycode, t_datas *datas) { if (keycode == KEY_1) datas->map->z_mult /= 2; else if (keycode == KEY_2) datas->map->z_mult *= 2; else if (keycode == KEY_3 && datas->cam->zoom >= 0.5) datas->cam->zoom /= 2; else if (keycode == KEY_4) datas->cam->zoom *= 2; else if (keycode == KEY_ECHAP) clean_exit(datas); } void key_hook_second(int keycode, t_datas *datas) { if (keycode == KEY_A) datas->cam->ang.yaw.raw += 3.1415 / 36; else if (keycode == KEY_D) datas->cam->ang.yaw.raw -= 3.1415 / 36; else if (keycode == KEY_W) datas->cam->ang.pitch.raw += 3.1415 / 36; else if (keycode == KEY_S) datas->cam->ang.pitch.raw -= 3.1415 / 36; else return (key_hook_third(keycode, datas)); datas->cam->ang.yaw.cos = cos(datas->cam->ang.yaw.raw); datas->cam->ang.yaw.sin = sin(datas->cam->ang.yaw.raw); datas->cam->ang.pitch.cos = cos(datas->cam->ang.pitch.raw); datas->cam->ang.pitch.sin = sin(datas->cam->ang.pitch.raw); } int key_hook_primary(int keycode, void *param) { t_datas *datas; datas = (t_datas *)param; if (keycode == KEY_ARROW_UP) datas->cam->center.y -= 20; else if (keycode == KEY_ARROW_DOWN) datas->cam->center.y += 20; else if (keycode == KEY_ARROW_LEFT) datas->cam->center.x -= 20; else if (keycode == KEY_ARROW_RIGHT) datas->cam->center.x += 20; else key_hook_second(keycode, datas); draw_map(datas); return (1); }