solve merge conflict
This commit is contained in:
BIN
builds/draw.o
BIN
builds/draw.o
Binary file not shown.
BIN
builds/fdf.o
BIN
builds/fdf.o
Binary file not shown.
BIN
builds/modifs.o
BIN
builds/modifs.o
Binary file not shown.
BIN
builds/parse.o
BIN
builds/parse.o
Binary file not shown.
@@ -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);
|
||||
|
||||
@@ -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)
|
||||
|
||||
12
srcs/fdf.c
12
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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user