layout, card, and design camera fixes

This commit is contained in:
2026-01-26 19:18:27 -05:00
parent cbe55820e9
commit 7ce6560225
14 changed files with 523 additions and 54 deletions

View File

@@ -9,45 +9,66 @@ extends Camera3D
@export var camera_height_offset: float = -4.0 # Offset to look slightly above center
# Smooth movement
@export var smooth_speed: float = 5.0
@export var smooth_speed: float = 3.0
var target_position: Vector3 = Vector3.ZERO
var target_look_at: Vector3 = Vector3.ZERO
var is_animating: bool = false
# Current player side (0 = positive Z, 1 = negative Z)
var current_player: int = 0
func _ready() -> void:
_setup_isometric_view()
_setup_for_player(0, false)
func _setup_isometric_view() -> void:
func _setup_for_player(player_index: int, animate: bool = true) -> void:
# Set perspective projection
projection = PROJECTION_PERSPECTIVE
fov = 50.0
# Calculate position - camera is positioned behind Player 1's side
var angle_rad = deg_to_rad(camera_angle)
current_player = player_index
# Height based on angle
var angle_rad = deg_to_rad(camera_angle)
var height = camera_distance * sin(angle_rad)
# Distance along Z axis (positive Z is toward Player 1)
var z_offset = camera_distance * cos(angle_rad)
# Position camera behind Player 1 (positive Z), looking toward center/opponent
position = Vector3(0, height, z_offset)
# Flip Z direction based on player
var side = 1 if player_index == 0 else -1
var new_position = Vector3(0, height, z_offset * side)
# Look at center of table
look_at(Vector3(0, camera_height_offset, 0), Vector3.UP)
target_look_at = Vector3(0, camera_height_offset, 0)
target_position = position
if animate:
target_position = new_position
is_animating = true
else:
position = new_position
target_position = new_position
look_at(target_look_at, Vector3.UP)
is_animating = false
func _process(delta: float) -> void:
# Smooth camera movement if needed
if position.distance_to(target_position) > 0.01:
if is_animating:
position = position.lerp(target_position, smooth_speed * delta)
look_at(Vector3(0, camera_height_offset, 0), Vector3.UP)
look_at(target_look_at, Vector3.UP)
if position.distance_to(target_position) < 0.05:
position = target_position
look_at(target_look_at, Vector3.UP)
is_animating = false
## Switch camera to view from a player's perspective
func switch_to_player(player_index: int) -> void:
if player_index != current_player:
_setup_for_player(player_index, true)
## Set camera to look at a specific point
func focus_on(point: Vector3) -> void:
var angle_rad = deg_to_rad(camera_angle)
var side = 1 if current_player == 0 else -1
target_position = point + Vector3(0, camera_distance * sin(angle_rad),
camera_distance * cos(angle_rad))
camera_distance * cos(angle_rad) * side)
is_animating = true
## Reset to default position
func reset_position() -> void:
_setup_isometric_view()
_setup_for_player(current_player, false)