wip: adding visual representation, starting with player battlefield

This commit is contained in:
ShyProton 2025-04-23 18:05:38 -04:00
parent 21f7d9de04
commit 77da7cf6b2
5 changed files with 70 additions and 25 deletions

34
field.gd Normal file
View File

@ -0,0 +1,34 @@
extends TextureRect
var _screen_size: Vector2
var _colors: Array[Color]
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
_screen_size = get_viewport_rect().size
# TODO: Calculate this field's scale and position based on which no# field this is.
# TODO: Method to take list of colors, split into this format of dictionary, and apply as gradient.
var gradient_data := {
0.0: Color.MAROON,
1.0: Color.MAROON,
}
var gradient := Gradient.new()
gradient.offsets = gradient_data.keys()
gradient.colors = gradient_data.values()
var gradient_texture = GradientTexture1D.new()
gradient_texture.gradient = gradient
# gradient_texture.width = _screen_size.x
texture = gradient_texture
func set_colors(colors: Array[Color]) -> void:
_colors = colors
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass

1
field.gd.uid Normal file
View File

@ -0,0 +1 @@
uid://cqutu8u3qenu0

18
field.tscn Normal file
View File

@ -0,0 +1,18 @@
[gd_scene load_steps=3 format=3 uid="uid://clnevm4xcexrs"]
[ext_resource type="Script" uid="uid://cqutu8u3qenu0" path="res://field.gd" id="1_6e7u2"]
[ext_resource type="Script" uid="uid://b3yqd1qu7dyq" path="res://card.gd" id="2_ujqnb"]
[node name="Field" type="TextureRect"]
offset_top = 540.0
offset_right = 1920.0
offset_bottom = 1080.0
script = ExtResource("1_6e7u2")
[node name="Card" type="TextureRect" parent="."]
layout_mode = 0
offset_left = -1.0
offset_top = 1.0
offset_right = 39.0
offset_bottom = 41.0
script = ExtResource("2_ujqnb")

View File

@ -1,8 +1,9 @@
extends Node2D
var _card_class = preload("res://card.gd")
# var _card_class = preload("res://card.gd")
var card
var field_scene = preload("res://field.tscn")
var fields: Array[Node] = []
func _on_request_completed(result, response_code, headers, body):
@ -10,23 +11,24 @@ func _on_request_completed(result, response_code, headers, body):
print(json["name"])
func _test_func():
card.load_card()
print(card.card_id)
print(card.card_name)
print(card.card_type)
print(card.oracle_text)
# func _test_func():
# card.load_card()
# print(card.card_id)
# print(card.card_name)
# print(card.card_type)
# print(card.oracle_text)
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
# TODO: Create 2-4 player instances as children of this tabletop node.
card = _card_class.new("d3f10f07-7cfe-4a6f-8de6-373e367a731b")
add_child(card)
# card = _card_class.new("d3f10f07-7cfe-4a6f-8de6-373e367a731b")
# add_child(card)
# card.cache_done.connect(_test_func)
card.cache_done.connect(_test_func)
pass # Replace with function body.
fields.append(field_scene.instantiate())
var colors: Array[Color] = [Color(1, 0, 1)]
fields[0].set_colors(colors)
add_child(fields[0])
# Called every frame. 'delta' is the elapsed time since the previous frame.

View File

@ -1,22 +1,12 @@
[gd_scene load_steps=4 format=3 uid="uid://cx0vga81xwckh"]
[gd_scene load_steps=3 format=3 uid="uid://cx0vga81xwckh"]
[ext_resource type="Script" uid="uid://w2rqm1u7p7im" path="res://player.gd" id="1_4flbx"]
[ext_resource type="Script" uid="uid://bc51go8t8uvts" path="res://library.gd" id="2_onrkg"]
[ext_resource type="Script" uid="uid://b3yqd1qu7dyq" path="res://card.gd" id="3_i3pqv"]
[node name="Player" type="Node2D"]
script = ExtResource("1_4flbx")
[node name="Field" type="Node2D" parent="."]
[node name="Hand" type="Node2D" parent="."]
[node name="Library" type="Node2D" parent="."]
script = ExtResource("2_onrkg")
[node name="TextureRect" type="TextureRect" parent="."]
offset_left = -1.0
offset_top = 1.0
offset_right = 39.0
offset_bottom = 41.0
script = ExtResource("3_i3pqv")