From 02955219fd0a1bd42e3009f77911f5f258d59d34 Mon Sep 17 00:00:00 2001 From: salaaad2 Date: Mon, 9 Mar 2020 21:03:16 +0100 Subject: get next sprite --- src/ft_get_sprite.c | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) (limited to 'src/ft_get_sprite.c') diff --git a/src/ft_get_sprite.c b/src/ft_get_sprite.c index 10c6bdd..8174cae 100644 --- a/src/ft_get_sprite.c +++ b/src/ft_get_sprite.c @@ -14,6 +14,36 @@ #include #include + +void + ft_get_next_sprite(t_cub *clist, int s_n, char c) +{ + size_t x; + size_t y; + uint8_t i; + + x = 1; + y = 1; + i = 0; + while (clist->mlist.map[y]) + { + while (clist->mlist.map[y][x]) + { + if (clist->mlist.map[y][x] == c) + { + clist->mlist.sprite_nbr++; + clist->sprites[s_n][i].s_pos_x = x; + clist->sprites[s_n][i].s_pos_y = y; + i++; + ft_get_next_sprite(clist, s_n++, c + 1); + } + x++; + } + x = 1; + y++; + } +} + void ft_get_sprite_spawn(t_cub *clist) { @@ -31,9 +61,10 @@ void if (ft_ischarset("2", clist->mlist.map[y][x])) { clist->mlist.sprite_nbr++; - clist->sprites[i].s_pos_x = x; - clist->sprites[i].s_pos_y = y; + clist->sprites[0][i].s_pos_x = x; + clist->sprites[0][i].s_pos_y = y; i++; + ft_get_next_sprite(clist, 1, '3'); } x++; } -- cgit v1.2.3 From b780107eb1fdf57b65d9bd664613de6835f9b962 Mon Sep 17 00:00:00 2001 From: salaaad2 Date: Mon, 9 Mar 2020 21:11:08 +0100 Subject: small changez, supposed to work, TODO --- src/ft_get_sprite.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/ft_get_sprite.c') diff --git a/src/ft_get_sprite.c b/src/ft_get_sprite.c index 8174cae..c288b67 100644 --- a/src/ft_get_sprite.c +++ b/src/ft_get_sprite.c @@ -25,6 +25,7 @@ void x = 1; y = 1; i = 0; + clist->mlist.sprite_var++; while (clist->mlist.map[y]) { while (clist->mlist.map[y][x]) -- cgit v1.2.3 From ca5b3689894013365f617cb5513372e6031e8ae7 Mon Sep 17 00:00:00 2001 From: salaaad2 Date: Wed, 11 Mar 2020 20:42:12 +0100 Subject: gang_gang --- src/ft_get_sprite.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ft_get_sprite.c') diff --git a/src/ft_get_sprite.c b/src/ft_get_sprite.c index c288b67..68c4f75 100644 --- a/src/ft_get_sprite.c +++ b/src/ft_get_sprite.c @@ -25,7 +25,6 @@ void x = 1; y = 1; i = 0; - clist->mlist.sprite_var++; while (clist->mlist.map[y]) { while (clist->mlist.map[y][x]) @@ -43,6 +42,7 @@ void x = 1; y++; } + clist->mlist.sprite_var += (clist->sprites[s_n][i].s_pos_x != 0); } void -- cgit v1.2.3 From 176c86dde0c19ffed0d4845003dbcace3f00b9d2 Mon Sep 17 00:00:00 2001 From: salaaad2 Date: Thu, 12 Mar 2020 15:08:06 +0100 Subject: 3 sprites but gns needs work :^) --- src/ft_get_sprite.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'src/ft_get_sprite.c') diff --git a/src/ft_get_sprite.c b/src/ft_get_sprite.c index 68c4f75..8e22075 100644 --- a/src/ft_get_sprite.c +++ b/src/ft_get_sprite.c @@ -13,7 +13,7 @@ #include #include #include - +#include void ft_get_next_sprite(t_cub *clist, int s_n, char c) @@ -28,17 +28,17 @@ void while (clist->mlist.map[y]) { while (clist->mlist.map[y][x]) + { + if (clist->mlist.map[y][x] == c) { - if (clist->mlist.map[y][x] == c) - { - clist->mlist.sprite_nbr++; - clist->sprites[s_n][i].s_pos_x = x; - clist->sprites[s_n][i].s_pos_y = y; - i++; - ft_get_next_sprite(clist, s_n++, c + 1); - } - x++; + clist->mlist.sprite_nbr++; + clist->sprites[s_n][i].s_pos_x = x; + clist->sprites[s_n][i].s_pos_y = y; + i++; + ft_get_next_sprite(clist, s_n++, c + 1); } + x++; + } x = 1; y++; } @@ -65,7 +65,7 @@ void clist->sprites[0][i].s_pos_x = x; clist->sprites[0][i].s_pos_y = y; i++; - ft_get_next_sprite(clist, 1, '3'); + ft_get_next_sprite(clist, 1, '3'); } x++; } -- cgit v1.2.3 From 71d55e5448007f90239a65279d8dbb07ee7b092a Mon Sep 17 00:00:00 2001 From: salaaad2 Date: Thu, 12 Mar 2020 16:26:46 +0100 Subject: NORMED AND FIXED .......!!! --- src/ft_get_sprite.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'src/ft_get_sprite.c') diff --git a/src/ft_get_sprite.c b/src/ft_get_sprite.c index 8e22075..a158940 100644 --- a/src/ft_get_sprite.c +++ b/src/ft_get_sprite.c @@ -22,12 +22,12 @@ void size_t y; uint8_t i; - x = 1; - y = 1; + x = 0; + y = 0; i = 0; - while (clist->mlist.map[y]) + while (clist->mlist.map[++y]) { - while (clist->mlist.map[y][x]) + while (clist->mlist.map[y][++x]) { if (clist->mlist.map[y][x] == c) { @@ -35,14 +35,15 @@ void clist->sprites[s_n][i].s_pos_x = x; clist->sprites[s_n][i].s_pos_y = y; i++; - ft_get_next_sprite(clist, s_n++, c + 1); } - x++; } - x = 1; - y++; + x = 0; + } + if (clist->sprites[s_n][i - 1].s_pos_x != 0) + { + ft_get_next_sprite(clist, s_n + 1, c + 1); + clist->mlist.sprite_var++; } - clist->mlist.sprite_var += (clist->sprites[s_n][i].s_pos_x != 0); } void -- cgit v1.2.3