game updates
This commit is contained in:
@@ -26,19 +26,24 @@ const MAT_MARGIN: float = 0.3 # Gap between mats and from table center
|
||||
# Player's left = +X, Player's right = -X
|
||||
const ZONE_POSITIONS = {
|
||||
"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
|
||||
"deck": Vector3(-7.0, 0.1, 4.0), # Back-right (player's right, behind backups)
|
||||
"break": Vector3(-7.0, 0.1, 1.5), # Front-right (player's right, front row)
|
||||
"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)
|
||||
}
|
||||
|
||||
# Background texture path
|
||||
const BACKGROUND_TEXTURE_PATH: String = "res://assets/table/background_1.png"
|
||||
|
||||
# Components
|
||||
var table_mesh: MeshInstance3D
|
||||
var background_mesh: MeshInstance3D
|
||||
var player_mat_meshes: Array[MeshInstance3D] = [null, null]
|
||||
var camera: TableCamera
|
||||
|
||||
func _ready() -> void:
|
||||
_create_background()
|
||||
_create_table_base()
|
||||
_create_camera()
|
||||
_create_lighting()
|
||||
@@ -46,8 +51,39 @@ func _ready() -> void:
|
||||
_create_deck_indicators()
|
||||
_generate_mats()
|
||||
|
||||
func _load_background_texture() -> Texture2D:
|
||||
var texture = load(BACKGROUND_TEXTURE_PATH)
|
||||
if texture:
|
||||
return texture
|
||||
push_warning("Could not load background texture: " + BACKGROUND_TEXTURE_PATH)
|
||||
return null
|
||||
|
||||
func _create_background() -> void:
|
||||
# Large background plane that fills the view behind the table,
|
||||
# similar to the wood desk surface in Pokemon TCG Online.
|
||||
background_mesh = MeshInstance3D.new()
|
||||
add_child(background_mesh)
|
||||
|
||||
var plane = PlaneMesh.new()
|
||||
plane.size = Vector2(80.0, 80.0) # Large enough to fill camera view
|
||||
background_mesh.mesh = plane
|
||||
|
||||
var mat = StandardMaterial3D.new()
|
||||
var bg_texture = _load_background_texture()
|
||||
if bg_texture:
|
||||
mat.albedo_texture = bg_texture
|
||||
# Tile the texture so the wood grain repeats naturally
|
||||
mat.uv1_scale = Vector3(3.0, 3.0, 1.0)
|
||||
else:
|
||||
mat.albedo_color = Color(0.25, 0.15, 0.08) # Fallback wood-ish brown
|
||||
mat.roughness = 0.9
|
||||
background_mesh.material_override = mat
|
||||
|
||||
# Sit slightly below the table surface to avoid z-fighting
|
||||
background_mesh.position = Vector3(0, -0.05, 0)
|
||||
|
||||
func _create_table_base() -> void:
|
||||
# Base table surface (dark, slightly larger than mats)
|
||||
# Base table surface with wood texture, slightly raised above background
|
||||
table_mesh = MeshInstance3D.new()
|
||||
add_child(table_mesh)
|
||||
|
||||
@@ -56,8 +92,16 @@ func _create_table_base() -> void:
|
||||
table_mesh.mesh = plane
|
||||
|
||||
var mat = StandardMaterial3D.new()
|
||||
mat.albedo_color = Color(0.08, 0.10, 0.08) # Very dark green base
|
||||
var bg_texture = _load_background_texture()
|
||||
if bg_texture:
|
||||
mat.albedo_texture = bg_texture
|
||||
# Slightly darker tint so the table surface is distinct from the background
|
||||
mat.albedo_color = Color(0.7, 0.65, 0.6)
|
||||
else:
|
||||
mat.albedo_color = Color(0.15, 0.1, 0.06)
|
||||
mat.roughness = 0.85
|
||||
table_mesh.material_override = mat
|
||||
table_mesh.position.y = 0.0
|
||||
|
||||
func _create_player_mat(player_idx: int, texture: ImageTexture) -> void:
|
||||
var mat_mesh = MeshInstance3D.new()
|
||||
@@ -110,10 +154,10 @@ func _create_lighting() -> void:
|
||||
add_child(env)
|
||||
var environment = Environment.new()
|
||||
environment.ambient_light_source = Environment.AMBIENT_SOURCE_COLOR
|
||||
environment.ambient_light_color = Color(0.3, 0.3, 0.35)
|
||||
environment.ambient_light_energy = 0.5
|
||||
environment.ambient_light_color = Color(0.35, 0.3, 0.25)
|
||||
environment.ambient_light_energy = 0.6
|
||||
environment.background_mode = Environment.BG_COLOR
|
||||
environment.background_color = Color(0.1, 0.1, 0.15)
|
||||
environment.background_color = Color(0.12, 0.08, 0.04) # Dark brown to blend with wood
|
||||
env.environment = environment
|
||||
|
||||
func _create_zones() -> void:
|
||||
|
||||
Reference in New Issue
Block a user