summaryrefslogtreecommitdiff
path: root/src/map_utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/map_utils.c')
-rw-r--r--src/map_utils.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/map_utils.c b/src/map_utils.c
new file mode 100644
index 0000000..54577a8
--- /dev/null
+++ b/src/map_utils.c
@@ -0,0 +1,31 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* map_utils.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: dkaiser <dkaiser@student.42heilbronn.de +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2024/05/14 13:19:34 by dkaiser #+# #+# */
+/* Updated: 2024/05/14 13:50:23 by dkaiser ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#include "so_long.h"
+
+t_vector grid_to_screen_pos(t_ivector grid_pos, t_ivector tile_size)
+{
+ t_vector screen_pos;
+
+ screen_pos.x = grid_pos.x * tile_size.x;
+ screen_pos.y = grid_pos.y * tile_size.y;
+ return (screen_pos);
+}
+
+t_ivector screen_to_grid_pos(t_vector screen_pos, t_ivector tile_size)
+{
+ t_ivector grid_pos;
+
+ grid_pos.x = screen_pos.x / tile_size.x;
+ grid_pos.y = screen_pos.y / tile_size.y;
+ return (grid_pos);
+}