From 46536f02b8fa54592e45b8ef318bd4730e18e131 Mon Sep 17 00:00:00 2001 From: mehbark Date: Thu, 1 May 2025 18:00:27 -0400 Subject: [PATCH] zoom out to see board --- board.gd | 7 +++++++ main.gd | 12 +++++++++++- main.tscn | 7 +++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/board.gd b/board.gd index 4ba2a88..0949d33 100644 --- a/board.gd +++ b/board.gd @@ -9,6 +9,13 @@ extends Node3D # literally just linearly search to find pieces at a position # children +# for zooming out to see the whole puzzle +func top_left_aabb() -> AABB: + return AABB(position, Vector3.ONE*0.1) + +func bottom_right_aabb() -> AABB: + return AABB(position + Vector3(dims.x, 0, dims.y), Vector3.ONE*0.1) + # todo: Array[Piece] func pieces() -> Array: return get_children() diff --git a/main.gd b/main.gd index b9a8998..85ddb72 100644 --- a/main.gd +++ b/main.gd @@ -19,6 +19,7 @@ var player: Piece @onready var sound: AudioStreamPlayer = $Sound var sounds_hit := AudioStreamRandomizer.new() + func _ready() -> void: add_child(board) var wall_count := 0 @@ -38,9 +39,18 @@ func _ready() -> void: var file_name := hit_dir.get_next() while file_name != "": if file_name.ends_with("ogg"): - var stream := AudioStream.new() sounds_hit.add_stream(-1, load("res://sfx/hit/"+file_name)) file_name = hit_dir.get_next() + + $TopLeft.aabb = board.top_left_aabb() + $BottomRight.aabb = board.bottom_right_aabb() + print($TopLeft.position) + print(board.bottom_right_aabb()) + +func _process(delta: float) -> void: + if $TopLeft.is_on_screen() and $BottomRight.is_on_screen(): + return + camera.position.y += delta func _input(event: InputEvent) -> void: if event.is_action_pressed("u", true, true): diff --git a/main.tscn b/main.tscn index 10af992..b712a85 100644 --- a/main.tscn +++ b/main.tscn @@ -23,3 +23,10 @@ fov = 90.0 environment = SubResource("Environment_ig7tw") [node name="Sound" type="AudioStreamPlayer" parent="."] + +[node name="TopLeft" type="VisibleOnScreenNotifier3D" parent="."] +transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 0, 0) +aabb = AABB(0, 0, 0, 2, 2, 2) + +[node name="BottomRight" type="VisibleOnScreenNotifier3D" parent="."] +aabb = AABB(0, 0, 0, 2, 2, 2)