diff --git a/builds/draw_bonus.o b/builds/draw_bonus.o index 2eed6e9..a1b8052 100644 Binary files a/builds/draw_bonus.o and b/builds/draw_bonus.o differ diff --git a/builds/fdf.o b/builds/fdf.o index adebeb9..101d3c5 100644 Binary files a/builds/fdf.o and b/builds/fdf.o differ diff --git a/builds/keypress_bonus.o b/builds/keypress_bonus.o index 1085807..6559acf 100644 Binary files a/builds/keypress_bonus.o and b/builds/keypress_bonus.o differ diff --git a/builds/modifs.o b/builds/modifs.o index a613194..e52e207 100644 Binary files a/builds/modifs.o and b/builds/modifs.o differ diff --git a/builds/parse.o b/builds/parse.o index c92ea48..f849edb 100644 Binary files a/builds/parse.o and b/builds/parse.o differ diff --git a/fdf b/fdf index 018bcd4..9c8fcb3 100755 Binary files a/fdf and b/fdf differ diff --git a/includes/fdf.h b/includes/fdf.h index 84e94bd..17be47e 100644 --- a/includes/fdf.h +++ b/includes/fdf.h @@ -71,7 +71,10 @@ int **parse_map(t_fdf *fdf, int fd); // steps size for the hight transform with p and o // must be > 0 // 100 is small, 1 is the biggest -# define Z_HIGHT 10 +# define Z_HEIGHT 10 + +// color for altitude +# define Z_COLOR 0xffffff; # define ESCAPE 65307 # define UP 65362 diff --git a/srcs/draw_bonus.c b/srcs/draw_bonus.c index d89679f..faee580 100644 --- a/srcs/draw_bonus.c +++ b/srcs/draw_bonus.c @@ -72,15 +72,20 @@ void draw_lines(t_fdf *fdf, int *start, int *end) void draw_color_pixel(t_fdf *fdf, int new_x, int new_y, int z) { int color; + int height; - color = 0xffffff; - z -= (z * fdf->zoom) / fdf->offset; - if (z > 0) - z /= fdf->altitude; - if (z > fdf->min_z && fdf->z_amplitude) + color = Z_COLOR; + height = z; + if (height != 0) + height /= fdf->altitude; + //height -= (height * fdf->zoom) / fdf->offset; + height -= height / fdf->offset; + if (height > fdf->min_z && fdf->z_amplitude) { - color = color ^ (((0xff / fdf->z_amplitude) * (z - fdf->min_z)) << 16); - color = color ^ (((0xff / fdf->z_amplitude) * (z - fdf->min_z)) << 0); + color = color ^ (((0xff) * (height - fdf->min_z)) << 16); + color = color ^ (((0xff) * (height - fdf->min_z)) << 0); + //color = color ^ (((0xff / fdf->z_amplitude) * (height - fdf->min_z)) << 16); + //color = color ^ (((0xff / fdf->z_amplitude) * (height - fdf->min_z)) << 0); } draw_pixel(fdf, new_x, new_y, color); } diff --git a/srcs/keypress_bonus.c b/srcs/keypress_bonus.c index d6121dd..726b499 100644 --- a/srcs/keypress_bonus.c +++ b/srcs/keypress_bonus.c @@ -30,7 +30,7 @@ void keypress_more(int keycode, t_fdf *fdf) else if (keycode == O) fdf->altitude++; else if (keycode == P) - if (fdf->altitude > 0) + //if (fdf->altitude > 0) fdf->altitude--; } diff --git a/srcs/modifs.c b/srcs/modifs.c index f18fa2e..176b8a5 100644 --- a/srcs/modifs.c +++ b/srcs/modifs.c @@ -21,6 +21,7 @@ int *new_coordinates(t_fdf *fdf, int i, int j) int x; int y; int z; + int height; int *point; point = ft_calloc(3, sizeof(int)); @@ -28,14 +29,12 @@ int *new_coordinates(t_fdf *fdf, int i, int j) y = j * (fdf->offset + fdf->zoom); x -= (fdf->map_size_x + fdf->zoom * fdf->map_width) / 2; y -= (fdf->map_size_y + fdf->zoom * fdf->map_height) / 2; - if (fdf->altitude > 0) - z = fdf->map[j][i] * fdf->altitude; - else if (fdf->altitude == 0) - z = 0; - else - z = fdf->map[j][i]; + z = fdf->map[j][i] * fdf->altitude; z += (z * fdf->zoom) / fdf->offset; - z /= Z_HIGHT; + height = Z_HEIGHT; + if (height == 0) + height = 1; + z /= height; point[0] = x * cos(fdf->rad_x) + y * sin(fdf->rad_x); point[1] = y * cos(fdf->rad_x) - x * sin(fdf->rad_x); point[1] = point[1] * cos(fdf->rad_y) - -z * sin(fdf->rad_y);