summaryrefslogtreecommitdiff
path: root/stage
diff options
context:
space:
mode:
Diffstat (limited to 'stage')
-rw-r--r--stage/tile_map_layer.gd15
-rw-r--r--stage/tile_map_layer.tscn4
2 files changed, 18 insertions, 1 deletions
diff --git a/stage/tile_map_layer.gd b/stage/tile_map_layer.gd
new file mode 100644
index 0000000..456cfaa
--- /dev/null
+++ b/stage/tile_map_layer.gd
@@ -0,0 +1,15 @@
+extends TileMapLayer
+
+
+func is_wall(collision_point: Vector2):
+ var map_coordinates := local_to_map(collision_point)
+ var tile = get_cell_tile_data(map_coordinates)
+
+ return tile.get_collision_polygons_count(0) > 0
+
+
+func is_ledge(collision_point: Vector2):
+ var map_coordinates := local_to_map(collision_point)
+ var tile = get_cell_tile_data(map_coordinates)
+
+ return tile.get_collision_polygons_count(1) > 0
diff --git a/stage/tile_map_layer.tscn b/stage/tile_map_layer.tscn
index 4e9583e..3e2ce48 100644
--- a/stage/tile_map_layer.tscn
+++ b/stage/tile_map_layer.tscn
@@ -1,6 +1,7 @@
-[gd_scene load_steps=4 format=3 uid="uid://dfioemvleakyt"]
+[gd_scene load_steps=5 format=3 uid="uid://dfioemvleakyt"]
[ext_resource type="Texture2D" uid="uid://4sbg8fnguw48" path="res://stage/assets/tileset-01.png" id="1_kgkhx"]
+[ext_resource type="Script" path="res://stage/tile_map_layer.gd" id="2_m3i7n"]
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_kmxxx"]
texture = ExtResource("1_kgkhx")
@@ -124,3 +125,4 @@ sources/0 = SubResource("TileSetAtlasSource_kmxxx")
[node name="TileMapLayer" type="TileMapLayer"]
texture_filter = 1
tile_set = SubResource("TileSet_277cy")
+script = ExtResource("2_m3i7n")