diff options
Diffstat (limited to 'player_collect.c')
-rw-r--r-- | player_collect.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/player_collect.c b/player_collect.c new file mode 100644 index 0000000..7ba9df2 --- /dev/null +++ b/player_collect.c @@ -0,0 +1,29 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* player_collect.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: kdx <kdx @student.42angouleme.fr +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/10/14 02:51:33 by kdx #+# #+# */ +/* Updated: 2022/10/14 14:37:15 by kdx ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "player.h" +#include "map.h" +#include "game.h" +#include <math.h> + +void player_collect(t_game *game, t_player *player, t_map *map) +{ + int pos[2]; + + pos[0] = round(player->pos[0]) + 8; + pos[1] = round(player->pos[1]) + 8; + if (map_get(map, pos[0], pos[1]) == TILE_COLLECTIBLE) + { + map_set(map, pos[0], pos[1], TILE_NONE); + game->collectibles -= 1; + } +} |