Skip to content

Commit

Permalink
merged and fixed mini_map distortion issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Tsunghao-C committed Sep 3, 2024
1 parent 6a88d2f commit 6bd213d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
1 change: 0 additions & 1 deletion minilibx-linux
Submodule minilibx-linux deleted from 7dc53a
19 changes: 9 additions & 10 deletions srcs/map/map.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: tsuchen <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/15 12:13:17 by tsuchen #+# #+# */
/* Updated: 2024/09/03 19:05:33 by tsuchen ### ########.fr */
/* Updated: 2024/09/03 19:22:23 by tsuchen ### ########.fr */
/* */
/* ************************************************************************** */

Expand All @@ -19,25 +19,24 @@ void put_mini_map(t_data *data)
int map_x;
int map_y;

y = 0;
while (y < MINI_MAP_H)
y = -1;
while (++y < MINI_MAP_H)
{
x = 0;
while (x < MINI_MAP_W)
x = -1;
while (++x < MINI_MAP_W)
{
map_y = y * (data->map_bound) / MINI_MAP_H;
map_x = x * (data->map_width - 1) / MINI_MAP_W;
// map_x = x * (ft_strlen(data->map[map_y]) - 1) / MINI_MAP_W;
if ((map_x < ft_strlen(data->map[map_y]) - 1) && data->map[map_y][map_x] == '1')
if ((map_x < (int)(ft_strlen(data->map[map_y]) - 1))
&& data->map[map_y][map_x] == '1')
rc_mlx_pixel_put(&data->mini_map, x, y, 0x212529);
else if ((map_x < ft_strlen(data->map[map_y]) - 1) && data->map[map_y][map_x] == 'D')
else if ((map_x < (int)(ft_strlen(data->map[map_y]) - 1))
&& data->map[map_y][map_x] == 'D')
rc_mlx_pixel_put(&data->mini_map, x, y, 0xFFC300);
else
rc_mlx_pixel_put(&data->mini_map, x, y, 0xE9ECEF);
if ((int)data->p_pos.x == map_y && (int)data->p_pos.y == map_x)
rc_mlx_pixel_put(&data->mini_map, x, y, 0xD62828);
x++;
}
y++;
}
}

0 comments on commit 6bd213d

Please sign in to comment.