From a4ca3c3a34366ba645c8fed17007353aae96813a Mon Sep 17 00:00:00 2001 From: Fabien Freling Date: Tue, 14 Dec 2021 13:22:44 +0100 Subject: [PATCH] replace states with simple function --- Main.gd | 46 +++++++++------------------------------------- 1 file changed, 9 insertions(+), 37 deletions(-) diff --git a/Main.gd b/Main.gd index 0a2154e..473a69b 100644 --- a/Main.gd +++ b/Main.gd @@ -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")