summaryrefslogtreecommitdiff
path: root/player_collide.c
diff options
context:
space:
mode:
Diffstat (limited to 'player_collide.c')
-rw-r--r--player_collide.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/player_collide.c b/player_collide.c
new file mode 100644
index 0000000..f94046e
--- /dev/null
+++ b/player_collide.c
@@ -0,0 +1,30 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* player_collide.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: kdx <kdx @student.42angouleme.fr +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2022/10/11 00:32:12 by kdx #+# #+# */
+/* Updated: 2022/10/11 00:34:58 by kdx ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#include "player.h"
+#include "map.h"
+#include <math.h>
+
+int player_collide(t_map *map, double x, double y, int v)
+{
+ int tl[2];
+ int br[2];
+
+ tl[0] = round(x) + 1;
+ tl[1] = round(y) + 1;
+ br[0] = tl[0] + 13;
+ br[1] = tl[1] + 13;
+ return (map_get(map, tl[0], tl[1]) == v
+ || map_get(map, br[0], tl[1]) == v
+ || map_get(map, tl[0], br[1]) == v
+ || map_get(map, br[0], br[1]) == v);
+}