Map size and camera bounds
This commit is contained in:
@@ -112,6 +112,12 @@ func draw_room_walls() -> void:
|
||||
wall_renderer.draw_walls_for_layout(map_layout)
|
||||
|
||||
|
||||
func get_map_rect() -> Rect2:
|
||||
if not map_layout:
|
||||
return Rect2()
|
||||
return Rect2(Vector2.ZERO, Vector2(map_layout.size) * TILE_SIZE)
|
||||
|
||||
|
||||
func load_from_layout() -> void:
|
||||
if not map_layout:
|
||||
return
|
||||
|
||||
@@ -28,8 +28,10 @@ func _ready() -> void:
|
||||
layout.rooms = [room_a, room_b]
|
||||
# Opening between (2,1) in room_a and (3,1) in room_b
|
||||
layout.openings = [Vector2i(2, 1), Vector2i(3, 1)]
|
||||
layout.size = Vector2i(6, 3)
|
||||
|
||||
combat_map.apply_layout(layout)
|
||||
camera.set_map_bounds(combat_map.get_map_rect())
|
||||
# -- End test room layout --
|
||||
|
||||
player_controller.combat_requested.connect(_on_combat_requested)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
class_name MapLayout extends Resource
|
||||
|
||||
@export var size: Vector2i = Vector2i.ZERO
|
||||
@export var rooms: Array[Room]
|
||||
## Openings are stored as a flat array of pairs: [from1, to1, from2, to2, ...].
|
||||
## Each consecutive pair of Vector2i values represents a bidirectional doorway
|
||||
|
||||
@@ -3,3 +3,10 @@ class_name CameraController extends Camera2D
|
||||
|
||||
func apply_drag(delta: Vector2) -> void:
|
||||
position += delta / zoom
|
||||
|
||||
|
||||
func set_map_bounds(rect: Rect2) -> void:
|
||||
limit_left = int(rect.position.x)
|
||||
limit_top = int(rect.position.y)
|
||||
limit_right = int(rect.position.x + rect.size.x)
|
||||
limit_bottom = int(rect.position.y + rect.size.y)
|
||||
|
||||
Reference in New Issue
Block a user