update to godot v4
This commit is contained in:
parent
371af850ae
commit
18b8ba71f8
2
Deck.gd
2
Deck.gd
|
@ -2,7 +2,7 @@ extends Node2D
|
||||||
|
|
||||||
const CardValue = preload("res://CardValue.gd")
|
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.LIGHT),
|
||||||
CardValue.new(Enums.Month.JANUARY, Enums.Type.RIBBON),
|
CardValue.new(Enums.Month.JANUARY, Enums.Type.RIBBON),
|
||||||
CardValue.new(Enums.Month.JANUARY, Enums.Type.SCRAP_1),
|
CardValue.new(Enums.Month.JANUARY, Enums.Type.SCRAP_1),
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
tool
|
@tool
|
||||||
class_name HanafudaCard
|
class_name HanafudaCard
|
||||||
extends Node2D
|
extends Node2D
|
||||||
|
|
||||||
const CardValue = preload("res://CardValue.gd")
|
const CardValue = preload("res://CardValue.gd")
|
||||||
|
|
||||||
export var revealed: bool = true setget reveal
|
@export var revealed: bool = true: set = reveal
|
||||||
export(Enums.Month) var month: int setget _set_card_month
|
@export var month: int: set = _set_card_month
|
||||||
export(Enums.Type) var type: int setget _set_card_type
|
@export var type: int: set = _set_card_type
|
||||||
|
|
||||||
var value: CardValue = CardValue.new(Enums.Month.JANUARY, Enums.Type.LIGHT)
|
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.
|
# Called when the node enters the scene tree for the first time.
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
|
@ -55,7 +55,7 @@ func reveal(new_reveal: bool) -> void:
|
||||||
revealed = new_reveal
|
revealed = new_reveal
|
||||||
|
|
||||||
if not _is_ready:
|
if not _is_ready:
|
||||||
yield(self, "ready")
|
await self.ready
|
||||||
|
|
||||||
if revealed:
|
if revealed:
|
||||||
$Frontside.show()
|
$Frontside.show()
|
||||||
|
@ -72,7 +72,7 @@ func _set_card_type(new_type: int) -> void:
|
||||||
|
|
||||||
func set_size(new_size: Vector2) -> void:
|
func set_size(new_size: Vector2) -> void:
|
||||||
if not _is_ready:
|
if not _is_ready:
|
||||||
yield(self, "ready")
|
await self.ready
|
||||||
|
|
||||||
var texture_size = $Frontside.texture.get_size()
|
var texture_size = $Frontside.texture.get_size()
|
||||||
var scale = new_size / texture_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:
|
func set_min_dimension(dim: int) -> void:
|
||||||
if not _is_ready:
|
if not _is_ready:
|
||||||
yield(self, "ready")
|
await self.ready
|
||||||
|
|
||||||
var texture_size = $Frontside.texture.get_size()
|
var texture_size = $Frontside.texture.get_size()
|
||||||
var scale = Vector2(dim, dim) / texture_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:
|
func set_max_dimension(dim: int) -> void:
|
||||||
if not _is_ready:
|
if not _is_ready:
|
||||||
yield(self, "ready")
|
await self.ready
|
||||||
|
|
||||||
var texture_size = $Frontside.texture.get_size()
|
var texture_size = $Frontside.texture.get_size()
|
||||||
var scale = Vector2(dim, dim) / texture_size
|
var scale = Vector2(dim, dim) / texture_size
|
||||||
|
@ -98,7 +98,7 @@ func set_max_dimension(dim: int) -> void:
|
||||||
|
|
||||||
func get_size() -> Vector2:
|
func get_size() -> Vector2:
|
||||||
if not _is_ready:
|
if not _is_ready:
|
||||||
yield(self, "ready")
|
await self.ready
|
||||||
|
|
||||||
var texture_size = $Frontside.texture.get_size()
|
var texture_size = $Frontside.texture.get_size()
|
||||||
return texture_size * self.scale
|
return texture_size * self.scale
|
||||||
|
|
|
@ -1,30 +1,30 @@
|
||||||
[gd_scene load_steps=5 format=2]
|
[gd_scene load_steps=5 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://HanafudaCard.gd" type="Script" id=1]
|
[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_January_Hikari.png" type="Texture2D" id=2]
|
||||||
[ext_resource path="res://assets/png/Hanafuda_border.png" type="Texture" id=3]
|
[ext_resource path="res://assets/png/Hanafuda_border.png" type="Texture2D" id=3]
|
||||||
[ext_resource path="res://assets/japanese_pattern_01.png" type="Texture" id=4]
|
[ext_resource path="res://assets/japanese_pattern_01.png" type="Texture2D" id=4]
|
||||||
|
|
||||||
[node name="HanafudaCard" type="Node2D"]
|
[node name="HanafudaCard" type="Node2D"]
|
||||||
script = ExtResource( 1 )
|
script = ExtResource( 1 )
|
||||||
|
|
||||||
[node name="Frontside" type="Sprite" parent="."]
|
[node name="Frontside" type="Sprite2D" parent="."]
|
||||||
texture = ExtResource( 2 )
|
texture = ExtResource( 2 )
|
||||||
|
|
||||||
[node name="Backside" type="Node2D" parent="."]
|
[node name="Backside" type="Node2D" parent="."]
|
||||||
visible = false
|
visible = false
|
||||||
|
|
||||||
[node name="TextureRect" type="TextureRect" parent="Backside"]
|
[node name="TextureRect" type="TextureRect" parent="Backside"]
|
||||||
margin_left = -110.0
|
offset_left = -110.0
|
||||||
margin_top = -193.0
|
offset_top = -193.0
|
||||||
margin_right = 1000.0
|
offset_right = 1000.0
|
||||||
margin_bottom = 1722.0
|
offset_bottom = 1722.0
|
||||||
rect_scale = Vector2( 0.2, 0.2 )
|
scale = Vector2( 0.2, 0.2 )
|
||||||
texture = ExtResource( 4 )
|
texture = ExtResource( 4 )
|
||||||
stretch_mode = 2
|
stretch_mode = 2
|
||||||
__meta__ = {
|
__meta__ = {
|
||||||
"_edit_use_anchors_": false
|
"_edit_use_anchors_": false
|
||||||
}
|
}
|
||||||
|
|
||||||
[node name="Border sprite" type="Sprite" parent="Backside"]
|
[node name="Border sprite" type="Sprite2D" parent="Backside"]
|
||||||
texture = ExtResource( 3 )
|
texture = ExtResource( 3 )
|
||||||
|
|
12
Main.gd
12
Main.gd
|
@ -1,9 +1,9 @@
|
||||||
extends Node
|
extends Node
|
||||||
|
|
||||||
onready var HanafudaCard = preload("res://HanafudaCard.tscn")
|
@onready var HanafudaCard = preload("res://HanafudaCard.tscn")
|
||||||
|
|
||||||
onready var deck = $Deck
|
@onready var deck = $Deck
|
||||||
onready var tween = $Tween
|
@onready var tween = $Tween
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
var dealer = oya()
|
var dealer = oya()
|
||||||
|
@ -14,7 +14,7 @@ func oya():
|
||||||
var card_reveal_duration = 0.5
|
var card_reveal_duration = 0.5
|
||||||
var card_dim = 150
|
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)
|
card_1.set_min_dimension(card_dim)
|
||||||
add_child(card_1)
|
add_child(card_1)
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ func oya():
|
||||||
card_reveal_duration,
|
card_reveal_duration,
|
||||||
Tween.TRANS_LINEAR, Tween.EASE_IN_OUT)
|
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)
|
card_2.set_min_dimension(card_dim)
|
||||||
add_child(card_2)
|
add_child(card_2)
|
||||||
tween.interpolate_property(card_2, "position",
|
tween.interpolate_property(card_2, "position",
|
||||||
|
@ -35,7 +35,7 @@ func oya():
|
||||||
card_reveal_duration,
|
card_reveal_duration,
|
||||||
Tween.TRANS_LINEAR, Tween.EASE_IN_OUT)
|
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 1: {c}".format({"c": card_1.value.desc()}))
|
||||||
print("Player 2: {c}".format({"c": card_2.value.desc()}))
|
print("Player 2: {c}".format({"c": card_2.value.desc()}))
|
||||||
|
|
34
Main.tscn
34
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 type="PackedScene" path="res://HanafudaCard.tscn" id="1"]
|
||||||
[ext_resource path="res://Main.gd" type="Script" id=2]
|
[ext_resource type="Script" path="res://Main.gd" id="2"]
|
||||||
[ext_resource path="res://Deck.gd" type="Script" id=3]
|
[ext_resource type="Script" path="res://Deck.gd" id="3"]
|
||||||
|
|
||||||
[node name="Node" type="Node"]
|
[node name="Node" type="Node"]
|
||||||
script = ExtResource( 2 )
|
script = ExtResource("2")
|
||||||
|
|
||||||
[node name="Background" type="ColorRect" parent="."]
|
[node name="Background" type="ColorRect" parent="."]
|
||||||
|
anchors_preset = 15
|
||||||
anchor_right = 1.0
|
anchor_right = 1.0
|
||||||
anchor_bottom = 1.0
|
anchor_bottom = 1.0
|
||||||
color = Color( 0.0941176, 0.423529, 0.27451, 1 )
|
color = Color(0.0941176, 0.423529, 0.27451, 1)
|
||||||
__meta__ = {
|
|
||||||
"_edit_use_anchors_": false
|
|
||||||
}
|
|
||||||
|
|
||||||
[node name="HanafudaCard" parent="." instance=ExtResource( 1 )]
|
[node name="HanafudaCard" parent="." instance=ExtResource("1")]
|
||||||
visible = false
|
visible = false
|
||||||
position = Vector2( 205, 447 )
|
position = Vector2(205, 447)
|
||||||
|
|
||||||
[node name="Deck" type="Node2D" parent="."]
|
[node name="Deck" type="Node2D" parent="."]
|
||||||
position = Vector2( 293, 412 )
|
position = Vector2(293, 412)
|
||||||
script = ExtResource( 3 )
|
script = ExtResource("3")
|
||||||
|
|
||||||
[node name="Tween" type="Tween" parent="."]
|
[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
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
[remap]
|
[remap]
|
||||||
|
|
||||||
importer="texture"
|
importer="texture"
|
||||||
type="StreamTexture"
|
type="CompressedTexture2D"
|
||||||
path="res://.import/japanese_pattern_01.png-f5786b9777fdcad19c4be71085ddc93d.stex"
|
uid="uid://cortgeafdhh2v"
|
||||||
|
path="res://.godot/imported/japanese_pattern_01.png-f5786b9777fdcad19c4be71085ddc93d.ctex"
|
||||||
metadata={
|
metadata={
|
||||||
"vram_texture": false
|
"vram_texture": false
|
||||||
}
|
}
|
||||||
|
@ -10,26 +11,24 @@ metadata={
|
||||||
[deps]
|
[deps]
|
||||||
|
|
||||||
source_file="res://assets/japanese_pattern_01.png"
|
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]
|
[params]
|
||||||
|
|
||||||
compress/mode=0
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
compress/lossy_quality=0.7
|
compress/lossy_quality=0.7
|
||||||
compress/hdr_mode=0
|
compress/hdr_compression=1
|
||||||
compress/bptc_ldr=0
|
|
||||||
compress/normal_map=0
|
compress/normal_map=0
|
||||||
flags/repeat=0
|
compress/channel_pack=0
|
||||||
flags/filter=true
|
mipmaps/generate=false
|
||||||
flags/mipmaps=false
|
mipmaps/limit=-1
|
||||||
flags/anisotropic=false
|
roughness/mode=0
|
||||||
flags/srgb=2
|
roughness/src_normal=""
|
||||||
process/fix_alpha_border=true
|
process/fix_alpha_border=true
|
||||||
process/premult_alpha=false
|
process/premult_alpha=false
|
||||||
process/HDR_as_SRGB=false
|
|
||||||
process/invert_color=false
|
|
||||||
process/normal_map_invert_y=false
|
process/normal_map_invert_y=false
|
||||||
stream=false
|
process/hdr_as_srgb=false
|
||||||
size_limit=0
|
process/hdr_clamp_exposure=false
|
||||||
detect_3d=true
|
process/size_limit=0
|
||||||
svg/scale=1.0
|
detect_3d/compress_to=1
|
||||||
|
|
|
@ -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]
|
[resource]
|
||||||
background_mode = 2
|
background_mode = 2
|
||||||
background_sky = SubResource( 1 )
|
sky = SubResource("1")
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
[remap]
|
[remap]
|
||||||
|
|
||||||
importer="texture"
|
importer="texture"
|
||||||
type="StreamTexture"
|
type="CompressedTexture2D"
|
||||||
path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"
|
uid="uid://b7icomn0rprn"
|
||||||
|
path="res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.ctex"
|
||||||
metadata={
|
metadata={
|
||||||
"vram_texture": false
|
"vram_texture": false
|
||||||
}
|
}
|
||||||
|
@ -10,26 +11,24 @@ metadata={
|
||||||
[deps]
|
[deps]
|
||||||
|
|
||||||
source_file="res://icon.png"
|
source_file="res://icon.png"
|
||||||
dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" ]
|
dest_files=["res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.ctex"]
|
||||||
|
|
||||||
[params]
|
[params]
|
||||||
|
|
||||||
compress/mode=0
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
compress/lossy_quality=0.7
|
compress/lossy_quality=0.7
|
||||||
compress/hdr_mode=0
|
compress/hdr_compression=1
|
||||||
compress/bptc_ldr=0
|
|
||||||
compress/normal_map=0
|
compress/normal_map=0
|
||||||
flags/repeat=0
|
compress/channel_pack=0
|
||||||
flags/filter=true
|
mipmaps/generate=false
|
||||||
flags/mipmaps=false
|
mipmaps/limit=-1
|
||||||
flags/anisotropic=false
|
roughness/mode=0
|
||||||
flags/srgb=2
|
roughness/src_normal=""
|
||||||
process/fix_alpha_border=true
|
process/fix_alpha_border=true
|
||||||
process/premult_alpha=false
|
process/premult_alpha=false
|
||||||
process/HDR_as_SRGB=false
|
|
||||||
process/invert_color=false
|
|
||||||
process/normal_map_invert_y=false
|
process/normal_map_invert_y=false
|
||||||
stream=false
|
process/hdr_as_srgb=false
|
||||||
size_limit=0
|
process/hdr_clamp_exposure=false
|
||||||
detect_3d=true
|
process/size_limit=0
|
||||||
svg/scale=1.0
|
detect_3d/compress_to=1
|
||||||
|
|
|
@ -6,28 +6,13 @@
|
||||||
; [section] ; section goes between []
|
; [section] ; section goes between []
|
||||||
; param=value ; assign values to parameters
|
; param=value ; assign values to parameters
|
||||||
|
|
||||||
config_version=4
|
config_version=5
|
||||||
|
|
||||||
_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": ""
|
|
||||||
}
|
|
||||||
|
|
||||||
[application]
|
[application]
|
||||||
|
|
||||||
config/name="Hanafuda"
|
config/name="Hanafuda"
|
||||||
run/main_scene="res://Main.tscn"
|
run/main_scene="res://Main.tscn"
|
||||||
|
config/features=PackedStringArray("4.3")
|
||||||
config/icon="res://icon.png"
|
config/icon="res://icon.png"
|
||||||
|
|
||||||
[autoload]
|
[autoload]
|
||||||
|
@ -36,8 +21,8 @@ Enums="*res://Enums.gd"
|
||||||
|
|
||||||
[display]
|
[display]
|
||||||
|
|
||||||
window/size/width=600
|
window/size/viewport_width=600
|
||||||
window/size/height=900
|
window/size/viewport_height=900
|
||||||
|
|
||||||
[physics]
|
[physics]
|
||||||
|
|
||||||
|
@ -45,4 +30,4 @@ common/enable_pause_aware_picking=true
|
||||||
|
|
||||||
[rendering]
|
[rendering]
|
||||||
|
|
||||||
environment/default_environment="res://default_env.tres"
|
environment/defaults/default_environment="res://default_env.tres"
|
||||||
|
|
Loading…
Reference in a new issue