-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreplace.c
More file actions
54 lines (49 loc) · 1.71 KB
/
Copy pathreplace.c
File metadata and controls
54 lines (49 loc) · 1.71 KB
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* replace.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: vbraeke <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/01/30 00:00:50 by vbraeke #+# #+# */
/* Updated: 2016/01/31 20:50:05 by vbraeke ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
#include "includes/all.h"
void replace_l(t_player *map, int i, int j)
{
if (j > 0 && map->map[i][j - 1] == 0)
{
map->map[i][j - 1] = map->map[i][j];
map->map[i][j] = 0;
return (replace_l(map, i, j - 1));
}
}
void replace_r(t_player *map, int i, int j)
{
if (j + 1 < map->size_map && map->map[i][j + 1] == 0)
{
map->map[i][j + 1] = map->map[i][j];
map->map[i][j] = 0;
return (replace_r(map, i, j + 1));
}
}
void replace_t(t_player *map, int i, int j)
{
if (i - 1 >= 0 && map->map[i - 1][j] == 0)
{
map->map[i - 1][j] = map->map[i][j];
map->map[i][j] = 0;
return (replace_t(map, i - 1, j));
}
}
void replace_b(t_player *map, int i, int j)
{
if (i + 1 < map->size_map && map->map[i + 1][j] == 0)
{
map->map[i + 1][j] = map->map[i][j];
map->map[i][j] = 0;
return (replace_b(map, i + 1, j));
}
}