-
Notifications
You must be signed in to change notification settings - Fork 0
/
cub3d_parse_map_resolution.c
executable file
·51 lines (46 loc) · 1.86 KB
/
cub3d_parse_map_resolution.c
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* cub3d_parse_map_resolution.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mg <mg@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/09/14 17:05:38 by mg #+# #+# */
/* Updated: 2020/10/06 00:19:07 by mg ### ########.fr */
/* */
/* ************************************************************************** */
#include "cub3d.h"
void c3d_parse_map_resolution(char *line, t_param *cub3d)
{
char *resolution;
resolution = ft_strnew(0);
while (!ft_isdigit(*line))
++line;
while (ft_isdigit(*line))
ft_strappend_xo_chr(&resolution, *line++);
cub3d->window.width = ft_atoi(resolution);
*resolution = '\0';
while (!ft_isdigit(*line))
++line;
while (ft_isdigit(*line))
ft_strappend_xo_chr(&resolution, *line++);
cub3d->window.height = ft_atoi(resolution);
c3d_parse_map_resolution_validaiton(cub3d);
free(resolution);
}
void c3d_parse_map_resolution_validaiton(t_param *cub3d)
{
int screen_height;
int screen_width;
int i;
i = 0;
mlx_get_screen_size(cub3d->mlx, &screen_width, &screen_height);
if (cub3d->window.width > screen_width || cub3d->window.width == 0)
if (++i)
cub3d->window.width = screen_width;
if (cub3d->window.height > screen_height || cub3d->window.height == 0)
if (++i)
cub3d->window.height = screen_height;
if (i)
perror("INVALID RESOLUTON - RESIZE TO FIT SCREEN");
}