summaryrefslogtreecommitdiff
path: root/UI/Camera.gd
diff options
context:
space:
mode:
Diffstat (limited to 'UI/Camera.gd')
-rw-r--r--UI/Camera.gd12
1 files changed, 11 insertions, 1 deletions
diff --git a/UI/Camera.gd b/UI/Camera.gd
index 1fd9361..b736e3a 100644
--- a/UI/Camera.gd
+++ b/UI/Camera.gd
@@ -13,6 +13,10 @@ var edge := Vector2.ZERO
@export var speed := 25
+@export_group("Limit", "limit")
+@export var limit_map: TileMapLayer
+@export var limit_margin: int
+
@export_group("Zoom", "zoom")
@export var zoom_min: float = 0.5
@export var zoom_max: float = 3
@@ -33,6 +37,11 @@ func _ready():
zoomed.emit(zoom)
)
+ limit_left = limit_map.get_used_rect().position.x * limit_map.tile_set.tile_size.x - limit_margin * limit_map.tile_set.tile_size.x
+ limit_right = limit_map.get_used_rect().end.x * limit_map.tile_set.tile_size.x + limit_margin * limit_map.tile_set.tile_size.x
+ limit_top = limit_map.get_used_rect().position.y * limit_map.tile_set.tile_size.y - (limit_margin + 1) * limit_map.tile_set.tile_size.y
+ limit_bottom = limit_map.get_used_rect().end.y * limit_map.tile_set.tile_size.y + limit_margin * limit_map.tile_set.tile_size.y
+
#Input.mouse_mode = Input.MOUSE_MODE_CONFINED
@@ -63,7 +72,8 @@ func _input(event):
Input.set_default_cursor_shape(Input.CURSOR_MOVE)
elif event.is_action_released("camera_drag"):
is_in_drag_mode = false
- Input.set_default_cursor_shape(Input.CURSOR_ARROW)
+ if Input.get_current_cursor_shape() == Input.CURSOR_MOVE:
+ Input.set_default_cursor_shape(Input.CURSOR_ARROW)
if event is InputEventMouseMotion: