diff options
author | Daniel Weipert <git@mail.dweipert.de> | 2024-10-13 11:14:43 +0200 |
---|---|---|
committer | Daniel Weipert <git@mail.dweipert.de> | 2024-10-13 11:14:43 +0200 |
commit | e82990eeafdf0be5d42d8aaa9b7fb6091e0d8435 (patch) | |
tree | ced53c3ec6168c68e63ae1083f6c6a34f99f4fa1 /Game/States/Build | |
parent | 0697f674ec33f8381ba68cf064732ee40e6e584f (diff) |
next commit
Diffstat (limited to 'Game/States/Build')
-rw-r--r-- | Game/States/Build/BuilderElement.gd | 5 | ||||
-rw-r--r-- | Game/States/Build/build_grid.gd | 21 |
2 files changed, 17 insertions, 9 deletions
diff --git a/Game/States/Build/BuilderElement.gd b/Game/States/Build/BuilderElement.gd index eb5ae12..38417ff 100644 --- a/Game/States/Build/BuilderElement.gd +++ b/Game/States/Build/BuilderElement.gd @@ -88,10 +88,9 @@ func can_build(): if area.get_overlapping_bodies().size() > 0: return false - - if Client.current_stage.has_method("can_build"): - return Client.current_stage.can_build() + #if Client.current_stage.has_method("can_build"): + #return Client.current_stage.can_build() return true diff --git a/Game/States/Build/build_grid.gd b/Game/States/Build/build_grid.gd index 766c79b..67c962e 100644 --- a/Game/States/Build/build_grid.gd +++ b/Game/States/Build/build_grid.gd @@ -1,21 +1,30 @@ extends Node2D +@onready var camera: Camera = get_viewport().get_camera_2d() + + +func _ready() -> void: + camera.zoomed.connect(func(_zoom): + queue_redraw() + ) + + func _draw(): var area = Client.current_stage.map.get_used_rect() var cell_size = Client.current_stage.map.tile_set.tile_size var offset = area.position for row in range(0, area.size.y + 1): draw_line( - Vector2(offset.x * cell_size.x, offset.y + row * cell_size.y), - Vector2(offset.x * cell_size.x + area.size.x * cell_size.x, offset.y + row * cell_size.y), + Vector2(offset.x * cell_size.x, offset.y * cell_size.y + row * cell_size.y), + Vector2(offset.x * cell_size.x + area.size.x * cell_size.x, offset.y * cell_size.y + row * cell_size.y), Color(1, 1, 1, 0.25), - 1.0 + 1.0 / camera.zoom.x ) for column in range(0, area.size.x + 1): draw_line( - Vector2(offset.x * cell_size.x + column * cell_size.x, offset.y), - Vector2(offset.x * cell_size.x + column * cell_size.x, offset.y + area.size.y * cell_size.y), + Vector2(offset.x * cell_size.x + column * cell_size.x, offset.y * cell_size.y), + Vector2(offset.x * cell_size.x + column * cell_size.x, offset.y * cell_size.y + area.size.y * cell_size.y), Color(1, 1, 1, 0.25), - 1.0 + 1.0 / camera.zoom.x ) |