wip: adding visual representation, starting with player battlefield
This commit is contained in:
parent
21f7d9de04
commit
77da7cf6b2
34
field.gd
Normal file
34
field.gd
Normal 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
1
field.gd.uid
Normal file
@ -0,0 +1 @@
|
|||||||
|
uid://cqutu8u3qenu0
|
18
field.tscn
Normal file
18
field.tscn
Normal 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")
|
30
player.gd
30
player.gd
@ -1,8 +1,9 @@
|
|||||||
extends Node2D
|
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):
|
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"])
|
print(json["name"])
|
||||||
|
|
||||||
|
|
||||||
func _test_func():
|
# func _test_func():
|
||||||
card.load_card()
|
# card.load_card()
|
||||||
print(card.card_id)
|
# print(card.card_id)
|
||||||
print(card.card_name)
|
# print(card.card_name)
|
||||||
print(card.card_type)
|
# print(card.card_type)
|
||||||
print(card.oracle_text)
|
# print(card.oracle_text)
|
||||||
|
|
||||||
|
|
||||||
# Called when the node enters the scene tree for the first time.
|
# Called when the node enters the scene tree for the first time.
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
# TODO: Create 2-4 player instances as children of this tabletop node.
|
# card = _card_class.new("d3f10f07-7cfe-4a6f-8de6-373e367a731b")
|
||||||
card = _card_class.new("d3f10f07-7cfe-4a6f-8de6-373e367a731b")
|
# add_child(card)
|
||||||
add_child(card)
|
# card.cache_done.connect(_test_func)
|
||||||
|
|
||||||
card.cache_done.connect(_test_func)
|
fields.append(field_scene.instantiate())
|
||||||
|
var colors: Array[Color] = [Color(1, 0, 1)]
|
||||||
pass # Replace with function body.
|
fields[0].set_colors(colors)
|
||||||
|
add_child(fields[0])
|
||||||
|
|
||||||
|
|
||||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
|
12
player.tscn
12
player.tscn
@ -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://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://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"]
|
[node name="Player" type="Node2D"]
|
||||||
script = ExtResource("1_4flbx")
|
script = ExtResource("1_4flbx")
|
||||||
|
|
||||||
[node name="Field" type="Node2D" parent="."]
|
|
||||||
|
|
||||||
[node name="Hand" type="Node2D" parent="."]
|
[node name="Hand" type="Node2D" parent="."]
|
||||||
|
|
||||||
[node name="Library" type="Node2D" parent="."]
|
[node name="Library" type="Node2D" parent="."]
|
||||||
script = ExtResource("2_onrkg")
|
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")
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user