diff --git a/Deck.gd b/Deck.gd index ee85f6e..c9d4d5e 100644 --- a/Deck.gd +++ b/Deck.gd @@ -2,7 +2,7 @@ extends Node2D const CardValue = preload("res://CardValue.gd") -onready var cards = [ +@onready var cards = [ CardValue.new(Enums.Month.JANUARY, Enums.Type.LIGHT), CardValue.new(Enums.Month.JANUARY, Enums.Type.RIBBON), CardValue.new(Enums.Month.JANUARY, Enums.Type.SCRAP_1), diff --git a/HanafudaCard.gd b/HanafudaCard.gd index 28255eb..d69d013 100644 --- a/HanafudaCard.gd +++ b/HanafudaCard.gd @@ -1,16 +1,16 @@ -tool +@tool class_name HanafudaCard extends Node2D const CardValue = preload("res://CardValue.gd") -export var revealed: bool = true setget reveal -export(Enums.Month) var month: int setget _set_card_month -export(Enums.Type) var type: int setget _set_card_type +@export var revealed: bool = true: set = reveal +@export var month: int: set = _set_card_month +@export var type: int: set = _set_card_type var value: CardValue = CardValue.new(Enums.Month.JANUARY, Enums.Type.LIGHT) -onready var _is_ready := true +@onready var _is_ready := true # Called when the node enters the scene tree for the first time. func _ready() -> void: @@ -55,7 +55,7 @@ func reveal(new_reveal: bool) -> void: revealed = new_reveal if not _is_ready: - yield(self, "ready") + await self.ready if revealed: $Frontside.show() @@ -72,7 +72,7 @@ func _set_card_type(new_type: int) -> void: func set_size(new_size: Vector2) -> void: if not _is_ready: - yield(self, "ready") + await self.ready var texture_size = $Frontside.texture.get_size() var scale = new_size / texture_size @@ -80,7 +80,7 @@ func set_size(new_size: Vector2) -> void: func set_min_dimension(dim: int) -> void: if not _is_ready: - yield(self, "ready") + await self.ready var texture_size = $Frontside.texture.get_size() var scale = Vector2(dim, dim) / texture_size @@ -89,7 +89,7 @@ func set_min_dimension(dim: int) -> void: func set_max_dimension(dim: int) -> void: if not _is_ready: - yield(self, "ready") + await self.ready var texture_size = $Frontside.texture.get_size() var scale = Vector2(dim, dim) / texture_size @@ -98,7 +98,7 @@ func set_max_dimension(dim: int) -> void: func get_size() -> Vector2: if not _is_ready: - yield(self, "ready") + await self.ready var texture_size = $Frontside.texture.get_size() return texture_size * self.scale diff --git a/HanafudaCard.tscn b/HanafudaCard.tscn index 3e0c020..eb1e117 100644 --- a/HanafudaCard.tscn +++ b/HanafudaCard.tscn @@ -1,30 +1,30 @@ [gd_scene load_steps=5 format=2] [ext_resource path="res://HanafudaCard.gd" type="Script" id=1] -[ext_resource path="res://assets/png/Hanafuda_January_Hikari.png" type="Texture" id=2] -[ext_resource path="res://assets/png/Hanafuda_border.png" type="Texture" id=3] -[ext_resource path="res://assets/japanese_pattern_01.png" type="Texture" id=4] +[ext_resource path="res://assets/png/Hanafuda_January_Hikari.png" type="Texture2D" id=2] +[ext_resource path="res://assets/png/Hanafuda_border.png" type="Texture2D" id=3] +[ext_resource path="res://assets/japanese_pattern_01.png" type="Texture2D" id=4] [node name="HanafudaCard" type="Node2D"] script = ExtResource( 1 ) -[node name="Frontside" type="Sprite" parent="."] +[node name="Frontside" type="Sprite2D" parent="."] texture = ExtResource( 2 ) [node name="Backside" type="Node2D" parent="."] visible = false [node name="TextureRect" type="TextureRect" parent="Backside"] -margin_left = -110.0 -margin_top = -193.0 -margin_right = 1000.0 -margin_bottom = 1722.0 -rect_scale = Vector2( 0.2, 0.2 ) +offset_left = -110.0 +offset_top = -193.0 +offset_right = 1000.0 +offset_bottom = 1722.0 +scale = Vector2( 0.2, 0.2 ) texture = ExtResource( 4 ) stretch_mode = 2 __meta__ = { "_edit_use_anchors_": false } -[node name="Border sprite" type="Sprite" parent="Backside"] +[node name="Border sprite" type="Sprite2D" parent="Backside"] texture = ExtResource( 3 ) diff --git a/Main.gd b/Main.gd index 9a59e73..131aefc 100644 --- a/Main.gd +++ b/Main.gd @@ -1,9 +1,9 @@ extends Node -onready var HanafudaCard = preload("res://HanafudaCard.tscn") +@onready var HanafudaCard = preload("res://HanafudaCard.tscn") -onready var deck = $Deck -onready var tween = $Tween +@onready var deck = $Deck +@onready var tween = $Tween func _ready(): var dealer = oya() @@ -14,7 +14,7 @@ func oya(): var card_reveal_duration = 0.5 var card_dim = 150 - var card_1 = HanafudaCard.instance().init_card($Deck.draw_card()) + var card_1 = HanafudaCard.instantiate().init_card($Deck.draw_card()) card_1.set_min_dimension(card_dim) add_child(card_1) @@ -27,7 +27,7 @@ func oya(): card_reveal_duration, Tween.TRANS_LINEAR, Tween.EASE_IN_OUT) - var card_2 = HanafudaCard.instance().init_card($Deck.draw_card()) + var card_2 = HanafudaCard.instantiate().init_card($Deck.draw_card()) card_2.set_min_dimension(card_dim) add_child(card_2) tween.interpolate_property(card_2, "position", @@ -35,7 +35,7 @@ func oya(): card_reveal_duration, Tween.TRANS_LINEAR, Tween.EASE_IN_OUT) - yield(tween, "tween_all_completed") + await tween.tween_all_completed print("Player 1: {c}".format({"c": card_1.value.desc()})) print("Player 2: {c}".format({"c": card_2.value.desc()})) diff --git a/Main.tscn b/Main.tscn index 47f8457..3054492 100644 --- a/Main.tscn +++ b/Main.tscn @@ -1,26 +1,34 @@ -[gd_scene load_steps=4 format=2] +[gd_scene load_steps=4 format=3 uid="uid://bb31qjmt5sk6i"] -[ext_resource path="res://HanafudaCard.tscn" type="PackedScene" id=1] -[ext_resource path="res://Main.gd" type="Script" id=2] -[ext_resource path="res://Deck.gd" type="Script" id=3] +[ext_resource type="PackedScene" path="res://HanafudaCard.tscn" id="1"] +[ext_resource type="Script" path="res://Main.gd" id="2"] +[ext_resource type="Script" path="res://Deck.gd" id="3"] [node name="Node" type="Node"] -script = ExtResource( 2 ) +script = ExtResource("2") [node name="Background" type="ColorRect" parent="."] +anchors_preset = 15 anchor_right = 1.0 anchor_bottom = 1.0 -color = Color( 0.0941176, 0.423529, 0.27451, 1 ) -__meta__ = { -"_edit_use_anchors_": false -} +color = Color(0.0941176, 0.423529, 0.27451, 1) -[node name="HanafudaCard" parent="." instance=ExtResource( 1 )] +[node name="HanafudaCard" parent="." instance=ExtResource("1")] visible = false -position = Vector2( 205, 447 ) +position = Vector2(205, 447) [node name="Deck" type="Node2D" parent="."] -position = Vector2( 293, 412 ) -script = ExtResource( 3 ) +position = Vector2(293, 412) +script = ExtResource("3") [node name="Tween" type="Tween" parent="."] +_import_path = NodePath("") +unique_name_in_owner = false +process_mode = 0 +process_priority = 0 +process_physics_priority = 0 +process_thread_group = 0 +physics_interpolation_mode = 0 +auto_translate_mode = 0 +editor_description = "" +script = null diff --git a/assets/japanese_pattern_01.png.import b/assets/japanese_pattern_01.png.import index 79ca71c..4edde9c 100644 --- a/assets/japanese_pattern_01.png.import +++ b/assets/japanese_pattern_01.png.import @@ -1,8 +1,9 @@ [remap] importer="texture" -type="StreamTexture" -path="res://.import/japanese_pattern_01.png-f5786b9777fdcad19c4be71085ddc93d.stex" +type="CompressedTexture2D" +uid="uid://cortgeafdhh2v" +path="res://.godot/imported/japanese_pattern_01.png-f5786b9777fdcad19c4be71085ddc93d.ctex" metadata={ "vram_texture": false } @@ -10,26 +11,24 @@ metadata={ [deps] source_file="res://assets/japanese_pattern_01.png" -dest_files=[ "res://.import/japanese_pattern_01.png-f5786b9777fdcad19c4be71085ddc93d.stex" ] +dest_files=["res://.godot/imported/japanese_pattern_01.png-f5786b9777fdcad19c4be71085ddc93d.ctex"] [params] compress/mode=0 +compress/high_quality=false compress/lossy_quality=0.7 -compress/hdr_mode=0 -compress/bptc_ldr=0 +compress/hdr_compression=1 compress/normal_map=0 -flags/repeat=0 -flags/filter=true -flags/mipmaps=false -flags/anisotropic=false -flags/srgb=2 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" process/fix_alpha_border=true process/premult_alpha=false -process/HDR_as_SRGB=false -process/invert_color=false process/normal_map_invert_y=false -stream=false -size_limit=0 -detect_3d=true -svg/scale=1.0 +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/default_env.tres b/default_env.tres index 20207a4..91ba4d8 100644 --- a/default_env.tres +++ b/default_env.tres @@ -1,7 +1,7 @@ -[gd_resource type="Environment" load_steps=2 format=2] +[gd_resource type="Environment" load_steps=2 format=3 uid="uid://t70a0g8ack6a"] -[sub_resource type="ProceduralSky" id=1] +[sub_resource type="Sky" id="1"] [resource] background_mode = 2 -background_sky = SubResource( 1 ) +sky = SubResource("1") diff --git a/icon.png.import b/icon.png.import index a4c02e6..99a599c 100644 --- a/icon.png.import +++ b/icon.png.import @@ -1,8 +1,9 @@ [remap] importer="texture" -type="StreamTexture" -path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" +type="CompressedTexture2D" +uid="uid://b7icomn0rprn" +path="res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.ctex" metadata={ "vram_texture": false } @@ -10,26 +11,24 @@ metadata={ [deps] source_file="res://icon.png" -dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" ] +dest_files=["res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.ctex"] [params] compress/mode=0 +compress/high_quality=false compress/lossy_quality=0.7 -compress/hdr_mode=0 -compress/bptc_ldr=0 +compress/hdr_compression=1 compress/normal_map=0 -flags/repeat=0 -flags/filter=true -flags/mipmaps=false -flags/anisotropic=false -flags/srgb=2 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" process/fix_alpha_border=true process/premult_alpha=false -process/HDR_as_SRGB=false -process/invert_color=false process/normal_map_invert_y=false -stream=false -size_limit=0 -detect_3d=true -svg/scale=1.0 +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/project.godot b/project.godot index 69b62d7..cb7e46d 100644 --- a/project.godot +++ b/project.godot @@ -6,28 +6,13 @@ ; [section] ; section goes between [] ; param=value ; assign values to parameters -config_version=4 - -_global_script_classes=[ { -"base": "Node", -"class": "CardValue", -"language": "GDScript", -"path": "res://CardValue.gd" -}, { -"base": "Node2D", -"class": "HanafudaCard", -"language": "GDScript", -"path": "res://HanafudaCard.gd" -} ] -_global_script_class_icons={ -"CardValue": "", -"HanafudaCard": "" -} +config_version=5 [application] config/name="Hanafuda" run/main_scene="res://Main.tscn" +config/features=PackedStringArray("4.3") config/icon="res://icon.png" [autoload] @@ -36,8 +21,8 @@ Enums="*res://Enums.gd" [display] -window/size/width=600 -window/size/height=900 +window/size/viewport_width=600 +window/size/viewport_height=900 [physics] @@ -45,4 +30,4 @@ common/enable_pause_aware_picking=true [rendering] -environment/default_environment="res://default_env.tres" +environment/defaults/default_environment="res://default_env.tres"