replace states with simple function

This commit is contained in:
Fabien Freling 2021-12-14 13:22:44 +01:00
parent c1d63c214a
commit a4ca3c3a34

46
Main.gd
View file

@ -1,54 +1,26 @@
extends Node
signal state_completed
var state_stack = []
onready var deck = $Deck
onready var tween = $Tween
func _ready():
state_stack.push_back(funcref(self, "update_game"))
state_stack.push_back(funcref(self, "update_oya"))
func _process(delta):
# print("Main::_process()")
if state_stack.empty():
return
var dealer = oya()
var state = state_stack.pop_back()
# print(state)
if state == null:
return
state.call_func()
yield(self, "state_completed")
# state_stack.pop_back()
func update_oya():
func oya():
tween.start()
var card_1 = $Deck.card($Deck.draw_card())
card_1.show()
tween.start()
tween.interpolate_property(card_1, "position",
Vector2(0, 0), Vector2(100, 100), 3,
Tween.TRANS_LINEAR, Tween.EASE_IN_OUT)
yield(tween, "tween_all_completed")
yield(tween, "tween_completed")
var card_2 = $Deck.card($Deck.draw_card())
card_2.show()
tween.interpolate_property(card_2, "position",
Vector2(0, 0), Vector2(-100, 100), 0.4,
Tween.TRANS_LINEAR, Tween.EASE_IN_OUT)
# var card_2 = $Deck.card($Deck.draw_card())
# card_2.show()
# tween.interpolate_property(card_2, "position",
# Vector2(0, 0), Vector2(-100, 100), 0.4,
# Tween.TRANS_LINEAR, Tween.EASE_IN_OUT)
#
# yield(tween, "tween_all_completed")
yield(tween, "tween_all_completed")
print("update oya")
emit_signal("state_completed")
func update_game():
print("update game")
emit_signal("state_completed")