#include "fdf.h" int shut_down(t_fdf *fdf) { mlx_destroy_window(fdf->mlx_ptr, fdf->win_ptr); exit(0); free(fdf); return (0); } t_fdf *init_fdf(void) { t_fdf *fdf; fdf = malloc(sizeof(t_fdf)); fdf->offset = 50; fdf->margin = 50; fdf->altitude = 3; fdf->map = parse_map(fdf); fdf->win_size_x = fdf->map_size_x + 2 * fdf->margin; fdf->win_size_y = fdf->map_size_y + 2 * fdf->margin; fdf->img_size_x = fdf->win_size_x; fdf->img_size_y = fdf->win_size_y; fdf->rot_x = 0; fdf->rot_y = 0; fdf->mov_x = 0; fdf->mov_y = 0; fdf->zoom = 0; fdf->mlx_ptr = mlx_init(); fdf->win_ptr = mlx_new_window(fdf->mlx_ptr, fdf->win_size_x, fdf->win_size_y, "test"); fdf->img_ptr = mlx_new_image(fdf->mlx_ptr, fdf->img_size_x, fdf->img_size_y); fdf->img_addr = mlx_get_data_addr(fdf->img_ptr, &(fdf->img_bpp), &(fdf->img_sizel), &(fdf->img_endian)); draw_image(fdf); return (fdf); } int main(int ac, char **av) { t_fdf *fdf; (void)av; (void)ac; fdf = init_fdf(); mlx_hook(fdf->win_ptr, 2, 1L << 0, keypress, fdf); mlx_hook(fdf->win_ptr, 17, 1L << 17, shut_down, fdf); mlx_loop(fdf->mlx_ptr); return (0); } /* ** w forward 119 ** a left 97 ** s backward 115 ** d right 100 ** < 65361 ** > 65363 ** v 65364 ** ^ 65362 ** esc 65307 ** ** ** ** ** ** ** ** ** ** // x_event | x_mask | action ** // 2 | 1L << 0 | key press ** // 3 | 1L << 1 | key release ** // 4 | | mouse press ** // 5 | | mouse release ** // 6 | | mouse move ** // 12 | | expose event ** // 17 | 1L << 17 | x button press (red button) ** // | | ** ** ** ** FONCTIONS EXTERNES AUTORISEES : ** . open ** . close ** . read ** . write ** . malloc ** . free ** . perror ** . strerror ** . exit ** . math lib : ** -lm // needed at compilation to link the lib : ** gcc foo.c -o foo -lm ** man ** man 3 math ** . minilibx : ** minilibx_opengl.tgz ** minilibx_mms_20200219_beta.tgz ** // to open an archive.tgz : ** gzip -d archive.tgz --> turn it into archive.tar ** tar -xf archive.tar --> un-archive it ** // how to add a man directory to the manual : ** . cp man/man1 /usr/local/share/man/man1 ** (create man1 if necessary) ** . mandb ** // i didn't use any of both library above but the one for linux : ** https://github.com/42Paris/minilibx-linux ** there are pbm with their man pages */