aboutsummaryrefslogtreecommitdiffstats
path: root/src/ft_set_minimap_scale.c
blob: ac464dd05c1ae561d2583c8023621dec8ced37d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   ft_set_minimap_scale.c                             :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2020/02/14 17:28:59 by rbousset          #+#    #+#             */
/*   Updated: 2020/02/14 17:28:59 by rbousset         ###   ########lyon.fr   */
/*                                                                            */
/* ************************************************************************** */

#include <cub3d.h>

void
	ft_set_minimap_scale(t_cub *clist)
{
	t_map	*ml;

	ml = &clist->mlist;
	if (ml->map_w > ml->map_h)
	{
		ml->scale = (clist->wlist.x_size / (uint16_t)ml->map_w);
		ml->scale = (clist->wlist.x_size < (ml->map_w * ml->scale))
			? ((clist->wlist.x_size / (uint16_t)ml->map_w) - 1) : (ml->scale);
	}
	else
	{
		ml->scale = (clist->wlist.y_size / (uint16_t)ml->map_h);
		ml->scale = (clist->wlist.y_size < (ml->map_h * ml->scale))
			? ((clist->wlist.y_size / (uint16_t)ml->map_h) - 1) : (ml->scale);
	}
	ml->scale = ((ml->scale - 1) < 1) ? (1) : (ml->scale);
	ml->scale = (ml->scale >= 10) ? (ml->scale / 4) : (ml->scale);
}