even better camera positioning
This commit is contained in:
parent
46536f02b8
commit
cb2e88bf3e
2 changed files with 7 additions and 15 deletions
15
main.gd
15
main.gd
|
@ -22,16 +22,12 @@ var sounds_hit := AudioStreamRandomizer.new()
|
|||
|
||||
func _ready() -> void:
|
||||
add_child(board)
|
||||
var wall_count := 0
|
||||
var wall_pos_sum := Vector2.ZERO
|
||||
for piece in board.pieces():
|
||||
if piece.type == Piece.Type.Player:
|
||||
player = piece
|
||||
elif piece.type == Piece.Type.Wall:
|
||||
wall_count += 1
|
||||
wall_pos_sum += Vector2(piece.position.x, piece.position.z)
|
||||
var wall_pos_mean := wall_pos_sum / wall_count
|
||||
camera.position = Vector3(wall_pos_mean.x, camera.position.y, wall_pos_mean.y)
|
||||
$TopLeft.aabb = board.top_left_aabb()
|
||||
$BottomRight.aabb = board.bottom_right_aabb()
|
||||
camera.position = Vector3(player.position.x, camera.position.y, player.position.z)
|
||||
|
||||
sounds_hit.random_pitch = 1.1
|
||||
var hit_dir := DirAccess.open("res://sfx/hit")
|
||||
|
@ -41,11 +37,6 @@ func _ready() -> void:
|
|||
if file_name.ends_with("ogg"):
|
||||
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():
|
||||
|
|
|
@ -16,7 +16,7 @@ sky = SubResource("Sky_0xm2m")
|
|||
script = ExtResource("1_ig7tw")
|
||||
|
||||
[node name="Camera" type="Camera3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 5, 0)
|
||||
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 1.5, 0)
|
||||
fov = 90.0
|
||||
|
||||
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
|
||||
|
@ -25,8 +25,9 @@ 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)
|
||||
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, -0.5, 0, -0.25)
|
||||
aabb = AABB(-0.25, 0, -0.25, 2, 2, 2)
|
||||
|
||||
[node name="BottomRight" type="VisibleOnScreenNotifier3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.25, 0, 0.25)
|
||||
aabb = AABB(0, 0, 0, 2, 2, 2)
|
||||
|
|
Loading…
Reference in a new issue