working updates

This commit is contained in:
2026-01-26 16:14:57 -05:00
parent b1e99fa952
commit c8228f200d
8055 changed files with 142307 additions and 867 deletions

View File

@@ -1,7 +1,7 @@
class_name TableSetup
extends Node3D
## TableSetup - Sets up the 3D game table with all zones
## TableSetup - Sets up the 3D game table with two play mats and all zones
signal card_clicked(card_instance: CardInstance, zone_type: Enums.ZoneType, player_index: int)
@@ -12,32 +12,42 @@ var player_zones: Array[Dictionary] = [{}, {}]
var deck_indicators: Array[MeshInstance3D] = [null, null]
var deck_count_labels: Array[Label3D] = [null, null]
# Table dimensions
const TABLE_WIDTH: float = 16.0
const TABLE_DEPTH: float = 12.0
# Table dimensions (scaled up for card readability)
const TABLE_WIDTH: float = 20.0
const TABLE_DEPTH: float = 16.0
# Zone positions (relative to table center)
# Play mat dimensions (each player gets one)
const MAT_WIDTH: float = 18.0
const MAT_DEPTH: float = 7.0
const MAT_MARGIN: float = 0.3 # Gap between mats and from table center
# Zone positions (relative to table center, for Player 1)
# Player 1 sits at +Z looking toward -Z
# Player's left = +X, Player's right = -X
const ZONE_POSITIONS = {
"deck": Vector3(5.5, 0.1, 3.5),
"damage": Vector3(3.5, 0.1, 3.5),
"backups": Vector3(0.0, 0.1, 3.5),
"break": Vector3(-3.5, 0.1, 3.5),
"forwards": Vector3(0.0, 0.1, 1.5),
"hand": Vector3(0.0, 0.5, 5.5)
"damage": Vector3(7.0, 0.1, 1.5), # Front-left (player's left)
"deck": Vector3(-7.0, 0.1, 1.5), # Front-right (player's right)
"break": Vector3(-7.0, 0.1, 4.0), # Right side, behind deck
"forwards": Vector3(0.0, 0.1, 2.0), # Center, front row
"backups": Vector3(0.0, 0.1, 5.0), # Center, back row
"hand": Vector3(0.0, 0.5, 7.5) # Not used on table (2D overlay)
}
# Components
var table_mesh: MeshInstance3D
var player_mat_meshes: Array[MeshInstance3D] = [null, null]
var camera: TableCamera
func _ready() -> void:
_create_table()
_create_table_base()
_create_camera()
_create_lighting()
_create_zones()
_create_deck_indicators()
_generate_mats()
func _create_table() -> void:
func _create_table_base() -> void:
# Base table surface (dark, slightly larger than mats)
table_mesh = MeshInstance3D.new()
add_child(table_mesh)
@@ -45,18 +55,41 @@ func _create_table() -> void:
plane.size = Vector2(TABLE_WIDTH, TABLE_DEPTH)
table_mesh.mesh = plane
# Create table material
var mat = StandardMaterial3D.new()
mat.albedo_color = Color(0.15, 0.2, 0.15) # Dark green felt
# Try to load playmat texture
if ResourceLoader.exists("res://assets/table/playmat.webp"):
var texture = load("res://assets/table/playmat.webp")
if texture:
mat.albedo_texture = texture
mat.albedo_color = Color(0.08, 0.10, 0.08) # Very dark green base
table_mesh.material_override = mat
# PlaneMesh in Godot 4 is already horizontal (facing up), no rotation needed
func _create_player_mat(player_idx: int, texture: ImageTexture) -> void:
var mat_mesh = MeshInstance3D.new()
add_child(mat_mesh)
var plane = PlaneMesh.new()
plane.size = Vector2(MAT_WIDTH, MAT_DEPTH)
mat_mesh.mesh = plane
var mat = StandardMaterial3D.new()
mat.albedo_texture = texture
mat_mesh.material_override = mat
# Position each mat on its half of the table
var mat_center_z = MAT_DEPTH / 2.0 + MAT_MARGIN
if player_idx == 0:
mat_mesh.position = Vector3(0, 0.01, mat_center_z) # Player 1: positive Z
else:
mat_mesh.position = Vector3(0, 0.01, -mat_center_z) # Player 2: negative Z
mat_mesh.rotation.y = deg_to_rad(180) # Rotate 180 so labels face Player 2
player_mat_meshes[player_idx] = mat_mesh
func _generate_mats() -> void:
var renderer = PlaymatRenderer.new()
add_child(renderer)
var texture = await renderer.render()
renderer.queue_free()
# Apply texture to both player mats
_create_player_mat(0, texture)
_create_player_mat(1, texture)
func _create_camera() -> void:
camera = TableCamera.new()
@@ -128,7 +161,7 @@ func _create_deck_indicators() -> void:
add_child(deck_mesh)
var box = BoxMesh.new()
box.size = Vector3(0.63, 0.3, 0.88) # Card size with thickness for deck
box.size = Vector3(1.26, 0.3, 1.76) # Card size with thickness for deck
deck_mesh.mesh = box
var mat = StandardMaterial3D.new()
@@ -162,7 +195,7 @@ func _create_zone(zone_type: Enums.ZoneType, player_idx: int, pos: Vector3, rot:
# Configure based on zone type
match zone_type:
Enums.ZoneType.FIELD_FORWARDS, Enums.ZoneType.FIELD_BACKUPS:
zone.card_spacing = 0.8
zone.card_spacing = 1.5
Enums.ZoneType.DAMAGE, Enums.ZoneType.BREAK:
zone.stack_offset = 0.02