diff --git a/builds/draw.o b/builds/draw.o deleted file mode 100644 index 6bba90c..0000000 Binary files a/builds/draw.o and /dev/null differ diff --git a/builds/fdf.o b/builds/fdf.o deleted file mode 100644 index 035cb0c..0000000 Binary files a/builds/fdf.o and /dev/null differ diff --git a/builds/modifs.o b/builds/modifs.o deleted file mode 100644 index 63be9e5..0000000 Binary files a/builds/modifs.o and /dev/null differ diff --git a/builds/parse.o b/builds/parse.o deleted file mode 100644 index 8096ac1..0000000 Binary files a/builds/parse.o and /dev/null differ diff --git a/fdf b/fdf deleted file mode 100755 index 23e714f..0000000 Binary files a/fdf and /dev/null differ diff --git a/includes/fdf.h b/includes/fdf.h index d846853..676cdbc 100644 --- a/includes/fdf.h +++ b/includes/fdf.h @@ -45,8 +45,8 @@ void draw_image(t_fdf *fdf); void draw_pixel(t_fdf *fdf, int x, int y, int color); void draw_color_pixel(t_fdf *fdf, int new_x, int new_y, int z); int keypress(int keycode, t_fdf *fdf); -void rotation_state(t_fdf *fdf); -int **parse_map(t_fdf *fdf); +void position_state(t_fdf *fdf); +int **parse_map(t_fdf *fdf, char **av); int *new_coordinates(t_fdf *fdf, int i, int j); void draw_lines(t_fdf *fdf, int *start, int *end); void draw_grid(t_fdf *fdf, int i, int j); diff --git a/srcs/draw.c b/srcs/draw.c index 33a62b3..2cdc52a 100644 --- a/srcs/draw.c +++ b/srcs/draw.c @@ -18,7 +18,7 @@ void draw_image(t_fdf *fdf) draw_grid(fdf, i, j); } mlx_put_image_to_window(fdf->mlx_ptr, fdf->win_ptr, fdf->img_ptr, 0, 0); - rotation_state(fdf); + position_state(fdf); } void draw_grid(t_fdf *fdf, int i, int j) diff --git a/srcs/fdf.c b/srcs/fdf.c index f09fc25..99ab0ad 100644 --- a/srcs/fdf.c +++ b/srcs/fdf.c @@ -24,11 +24,11 @@ t_fdf *init_fdf(t_fdf *fdf) 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->rot_x = -30; + fdf->rot_y = -45; fdf->mov_x = 0; fdf->mov_y = 0; - fdf->zoom = 0; + fdf->zoom = -5; fdf->mlx_ptr = mlx_init(); fdf->win_ptr = mlx_new_window(fdf->mlx_ptr, fdf->win_size_x, fdf->win_size_y, "test"); @@ -44,10 +44,10 @@ int main(int ac, char **av) { t_fdf *fdf; - (void)ac; - (void)av; + if (ac != 1) + return (0); fdf = malloc(sizeof(t_fdf)); - fdf->map = parse_map(fdf); + fdf->map = parse_map(fdf, av); fdf = init_fdf(fdf); mlx_hook(fdf->win_ptr, 2, 1L << 0, keypress, fdf); mlx_hook(fdf->win_ptr, 17, 1L << 17, shut_down, fdf); diff --git a/srcs/modifs.c b/srcs/modifs.c index f0fd83f..d706e42 100644 --- a/srcs/modifs.c +++ b/srcs/modifs.c @@ -32,17 +32,17 @@ int keypress(int keycode, t_fdf *fdf) /* ** int[0] = x, int[1] = y, int[2] = z ** quick explanation : -** zoom : +** zoom : ** x = i * (fdf->offset + fdf->zoom); -** center before 3d rotation : +** center before 3d rotation : ** x -= (fdf->map_size_x + fdf->zoom * fdf->map_width) / 2; -** z changes according to zoom : +** z changes according to zoom : ** z += (z * fdf->zoom) / fdf->offset; -** deplacement : +** deplacement : ** point[0] += fdf->margin + fdf->mov_x; -** center zoom after : +** center zoom : ** point[0] -= ((fdf->map_size_x / 2) / fdf->offset) * fdf->zoom; -** center after 3d rotation : +** center after 3d rotation : ** point[0] += (fdf->map_size_x + fdf->zoom * fdf->map_width) / 2; */ int *new_coordinates(t_fdf *fdf, int i, int j) @@ -79,17 +79,25 @@ int print_keycode(int keycode) return (0); } -void rotation_state(t_fdf *fdf) +void position_state(t_fdf *fdf) { char *position; int x; int y; - x = fdf->img_size_x - 10; - y = fdf->img_size_y - 10; - position = ft_strjoinfree(ft_itoa(fdf->rot_x), ft_strdup(" | ")); + position = ft_strjoinfree(ft_strdup("zoom: "), ft_itoa(fdf->zoom)); + position = ft_strjoinfree(position, ft_strdup(" ")); + position = ft_strjoinfree(position, ft_strdup("deplacement: ")); + position = ft_strjoinfree(position, ft_itoa(fdf->mov_x)); + position = ft_strjoinfree(position, ft_strdup(" ")); + position = ft_strjoinfree(position, ft_itoa(fdf->mov_y)); + position = ft_strjoinfree(position, ft_strdup(" ")); + position = ft_strjoinfree(position, ft_strdup("rotation: ")); + position = ft_strjoinfree(position, ft_itoa(fdf->rot_x)); + position = ft_strjoinfree(position, ft_strdup(" ")); position = ft_strjoinfree(position, ft_itoa(fdf->rot_y)); - x -= ft_strlen(position) * 6; + x = fdf->img_size_x - 10 - ft_strlen(position) * 6; + y = fdf->img_size_y - 10; mlx_string_put(fdf->mlx_ptr, fdf->win_ptr, x, y, 0xffffff, position); free(position); } diff --git a/srcs/parse.c b/srcs/parse.c index 45f9f28..67c87a1 100644 --- a/srcs/parse.c +++ b/srcs/parse.c @@ -1,11 +1,12 @@ #include "fdf.h" -int **parse_map(t_fdf *fdf) +int **parse_map(t_fdf *fdf, char **av) { int **map; int i; int j; + (void)av; map = ft_calloc(10, sizeof(map)); i = -1; while (++i < 10)