hanafuda/Main.gd

41 lines
1.1 KiB
GDScript3
Raw Normal View History

2021-12-06 23:10:39 +01:00
extends Node
2021-12-14 21:53:45 +01:00
onready var HanafudaCard = preload("res://HanafudaCard.tscn")
2021-12-13 23:38:36 +01:00
onready var deck = $Deck
onready var tween = $Tween
2021-12-06 23:10:39 +01:00
func _ready():
2021-12-14 13:22:44 +01:00
var dealer = oya()
2021-12-12 23:21:03 +01:00
2021-12-14 13:22:44 +01:00
func oya():
tween.start()
2022-01-23 23:56:54 +01:00
var deck_position = Vector2(10, 10)
var card_reveal_duration = 0.5
var card_dim = 150
2021-12-14 21:53:45 +01:00
var card_1 = HanafudaCard.instance().init_card($Deck.draw_card())
2022-01-23 23:56:54 +01:00
card_1.set_min_dimension(card_dim)
2021-12-14 21:53:45 +01:00
add_child(card_1)
2022-01-23 23:56:54 +01:00
var card_size = card_1.get_size()
var padding = 20
var delta_x = (card_size.x + padding) / 2
2021-12-13 23:38:36 +01:00
tween.interpolate_property(card_1, "position",
2022-01-23 23:56:54 +01:00
deck_position, Vector2(get_viewport().size.x / 2 - delta_x, get_viewport().size.y / 2),
card_reveal_duration,
2021-12-13 23:38:36 +01:00
Tween.TRANS_LINEAR, Tween.EASE_IN_OUT)
2022-01-23 23:56:54 +01:00
var card_2 = HanafudaCard.instance().init_card($Deck.draw_card())
card_2.set_min_dimension(card_dim)
add_child(card_2)
tween.interpolate_property(card_2, "position",
deck_position, Vector2(get_viewport().size.x / 2 + delta_x, get_viewport().size.y / 2),
card_reveal_duration,
Tween.TRANS_LINEAR, Tween.EASE_IN_OUT)
2021-12-13 23:38:36 +01:00
2021-12-14 13:22:44 +01:00
yield(tween, "tween_all_completed")
2021-12-13 23:38:36 +01:00
2021-12-12 23:21:03 +01:00
print("update oya")