-
Notifications
You must be signed in to change notification settings - Fork 0
/
matrix.c
executable file
·70 lines (63 loc) · 1.99 KB
/
matrix.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* matrix.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jchapell <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/05/09 00:33:58 by jchapell #+# #+# */
/* Updated: 2023/06/01 04:44:15 by jchapell ### ########.fr */
/* */
/* ************************************************************************** */
#include "inc/proto.h"
void add_collision(t_level *l, t_vector pos, int nb_col)
{
t_vector *new_map;
int i;
i = 0;
set_vector(&pos, pos.x * l->tx.width, (pos.y + 1) * l->tx.width);
new_map = malloc(sizeof(t_vector) * (nb_col + 1));
if (nb_col > 1)
{
i = -1;
while (++i < nb_col)
new_map[i] = l->collision_map[i];
free(l->collision_map);
}
new_map[i] = pos;
l->collision_map = new_map;
}
void add_enemy(t_level *l, t_vector pos, int nb_en)
{
t_vector *new_map;
int i;
i = 0;
set_vector(&pos, pos.x * l->tx.width, (pos.y + 1) * l->tx.width);
new_map = malloc(sizeof(t_vector) * (nb_en + 1));
if (nb_en > 1)
{
i = -1;
while (++i < nb_en)
new_map[i] = l->enemy_map[i];
free(l->enemy_map);
}
new_map[i] = pos;
l->enemy_map = new_map;
}
void add_coins(t_level *l, t_vector pos, int nb_coins)
{
t_vector *new_map;
int i;
i = 0;
set_vector(&pos, pos.x * l->tx.width, (pos.y + 1) * l->tx.width);
new_map = malloc(sizeof(t_vector) * (nb_coins + 1));
if (nb_coins > 1)
{
i = -1;
while (++i < nb_coins - 1)
new_map[i] = l->map_c[i];
free(l->map_c);
}
new_map[i] = pos;
l->map_c = new_map;
}