summaryrefslogtreecommitdiff
path: root/player_collect.c
blob: 7ba9df226e044de244d5e3ba0d56e400213e73d3 (plain)
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
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   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;
	}
}