-
Notifications
You must be signed in to change notification settings - Fork 0
/
map_init3.c
105 lines (95 loc) · 2.32 KB
/
map_init3.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* map_init3.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: zwalad <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/12/29 11:03:35 by zwalad #+# #+# */
/* Updated: 2023/01/05 02:04:00 by zwalad ### ########.fr */
/* */
/* ************************************************************************** */
#include "cub1d.h"
void check_last(t_big *p, int i)
{
int j;
j = 0;
while (p->map.map[i][j])
{
if (p->map.map[i][j] != '1' && p->map.map[i][j] != ' ')
ft_error("wrong map !");
j++;
}
}
void ckeck_zero(t_big *p)
{
int i;
int j;
i = 0;
while (p->map.map[i + 1])
{
j = -1;
while (p->map.map[i][++j])
{
if (p->map.map[i][j] == '0')
{
if (i == 0 || j == 0 || j == ft_strlen(p->map.map[i]) - 1
|| j >= ft_strlen(p->map.map[i + 1]))
ft_error("wrong map !");
else if (check_zerov2(p->map.map[i + 1][j])
|| check_zerov2(p->map.map[i - 1][j])
|| check_zerov2(p->map.map[i][j + 1])
|| check_zerov2(p->map.map[i][j - 1]))
ft_error("wrong map !");
}
}
i++;
}
check_last(p, i);
}
int ft_isalnum(int c)
{
if ((c >= '0' && c <= '9') || (c >= 'a' && c <= 'z')
|| (c >= 'A' && c <= 'Z'))
{
return (1);
}
return (0);
}
void check_path(char *str, const char *s)
{
int i;
int j;
i = ft_strlen(str) - 4;
if (i < 1)
ft_error("wrong format !");
j = 0;
while (str[i] || s[j])
{
if (str[i] != s[j])
ft_error("wrong format !");
i++;
j++;
}
}
void mini_map(t_big *p)
{
int i;
int j;
i = 33;
read_map(p, -1, -4);
while (i < 44)
{
j = 33;
while (j < 44)
mlx_pixel_put(p->mlx.mlx_ptr, p->mlx.win_ptr, i, j++, 0x5FCDD9);
i++;
}
i = 0;
while (i < 11)
{
mlx_pixel_put(p->mlx.mlx_ptr, p->mlx.win_ptr, 37 + \
(i * cos(p->player.pa)), 37 + (i * sin(p->player.pa)), RED);
i++;
}
}