la carte saffiche bien et tourne bien

This commit is contained in:
hugogogo
2021-07-19 09:18:01 +02:00
parent fce788547a
commit cb655a75d5
4 changed files with 7 additions and 6 deletions

Binary file not shown.

BIN
fdf

Binary file not shown.

View File

@@ -53,7 +53,7 @@ typedef struct s_fdf
int img_size_y;
int map_size_x;
int map_size_y;
int map_length;
int map_width;
int map_height;
int rot_x;
int rot_y;

View File

@@ -25,16 +25,15 @@ void draw_image(t_fdf *fdf)
*(unsigned int*)(fdf->img_addr + i) = 0;
// draw image
j = -1;
while (++j < fdf->map_size_y)
while (++j < fdf->map_height)
{
i = -1;
while (++i < fdf->map_size_x)
while (++i < fdf->map_width)
{
x = i * fdf->offset;
y = j * fdf->offset;
// z = fdf->map[j][i];
z = 1;
z = fdf->map[j][i];
new_x = x * cos(fdf->rad_y) + y * sin(fdf->rad_y);
new_y = y * cos(fdf->rad_y) - x * sin(fdf->rad_y);
new_y = new_y * cos(fdf->rad_x) - z * sin(fdf->rad_x);
@@ -110,7 +109,7 @@ void draw_pixel(t_fdf *fdf, int x, int y, int color)
int ymax;
xmax = fdf->img_sizel / (fdf->img_bpp / 8);
ymax = fdf->map_size_y;
ymax = fdf->img_size_y;
if (x < 0 || y < 0 || x > xmax || y > ymax)
return ;
position = y * fdf->img_sizel + x * fdf->img_bpp / 8;
@@ -182,6 +181,8 @@ int **parse_map(t_fdf *fdf)
}
map[3][6] = 10;
// size map
fdf->map_width = j;
fdf->map_height = i;
fdf->map_size_x = --j * fdf->offset + 1;
fdf->map_size_y = --i * fdf->offset + 1;
return (map);