aboutsummaryrefslogtreecommitdiff
path: root/game/addons/zylann.hterrain/tools/minimap/minimap_overlay.gd
diff options
context:
space:
mode:
author Gone2Daly <71726742+Gone2Daly@users.noreply.github.com>2023-07-22 21:05:42 +0200
committer Gone2Daly <71726742+Gone2Daly@users.noreply.github.com>2023-07-22 21:05:42 +0200
commit71b3cd829f80de4c2cd3972d8bfd5ee470a5d180 (patch)
treeb4280fde6eef2ae6987648bc7bf8e00e9011bb7f /game/addons/zylann.hterrain/tools/minimap/minimap_overlay.gd
parentce9022d0df74d6c33db3686622be2050d873ab0b (diff)
init_testtest3d
Diffstat (limited to 'game/addons/zylann.hterrain/tools/minimap/minimap_overlay.gd')
-rw-r--r--game/addons/zylann.hterrain/tools/minimap/minimap_overlay.gd24
1 files changed, 24 insertions, 0 deletions
diff --git a/game/addons/zylann.hterrain/tools/minimap/minimap_overlay.gd b/game/addons/zylann.hterrain/tools/minimap/minimap_overlay.gd
new file mode 100644
index 0000000..93c6695
--- /dev/null
+++ b/game/addons/zylann.hterrain/tools/minimap/minimap_overlay.gd
@@ -0,0 +1,24 @@
+@tool
+extends Control
+
+
+@export var cursor_texture : Texture
+@export var out_of_range_texture : Texture
+
+@onready var _sprite : Sprite2D = $Cursor
+
+var _pos := Vector2()
+var _rot := 0.0
+
+
+func set_cursor_position_normalized(pos_norm: Vector2, dir: Vector2):
+ if Rect2(0, 0, 1, 1).has_point(pos_norm):
+ _sprite.texture = cursor_texture
+ else:
+ pos_norm.x = clampf(pos_norm.x, 0.0, 1.0)
+ pos_norm.y = clampf(pos_norm.y, 0.0, 1.0)
+ _sprite.texture = out_of_range_texture
+
+ _sprite.position = pos_norm * size
+ _sprite.rotation = dir.angle()
+