+faces logic

This commit is contained in:
Mikhail Aristov 2024-01-26 20:53:36 +01:00
parent acd320437f
commit a33fc22afc
10 changed files with 211 additions and 0 deletions

View File

@ -0,0 +1,24 @@
[gd_scene load_steps=5 format=3 uid="uid://bvc6fbd5cgb0i"]
[ext_resource type="Texture2D" uid="uid://f74hle6gaeie" path="res://sprites/faces/curly_happy.png" id="1_7pet0"]
[ext_resource type="Script" path="res://scenes/faces/face.gd" id="1_vcbhp"]
[ext_resource type="Texture2D" uid="uid://oeljmd05bkvj" path="res://sprites/faces/curly_neutral.png" id="2_54uqk"]
[ext_resource type="Texture2D" uid="uid://5iygla17stpm" path="res://sprites/faces/curly_not_amused.png" id="3_2t0h4"]
[node name="FaceCurly" type="Node2D" node_paths=PackedStringArray("sprite_happy", "sprite_neutral", "sprite_unhappy")]
script = ExtResource("1_vcbhp")
mood = 1
sprite_happy = NodePath("Happy")
sprite_neutral = NodePath("Neutral")
sprite_unhappy = NodePath("Unhappy")
[node name="Happy" type="Sprite2D" parent="."]
modulate = Color(1, 1, 1, 0)
texture = ExtResource("1_7pet0")
[node name="Neutral" type="Sprite2D" parent="."]
texture = ExtResource("2_54uqk")
[node name="Unhappy" type="Sprite2D" parent="."]
modulate = Color(1, 1, 1, 0)
texture = ExtResource("3_2t0h4")

View File

@ -0,0 +1,24 @@
[gd_scene load_steps=5 format=3 uid="uid://bvc6fbd5cgb0i"]
[ext_resource type="Texture2D" uid="uid://f74hle6gaeie" path="res://sprites/faces/curly_happy.png" id="1_7pet0"]
[ext_resource type="Script" path="res://scenes/faces/face.gd" id="1_vcbhp"]
[ext_resource type="Texture2D" uid="uid://oeljmd05bkvj" path="res://sprites/faces/curly_neutral.png" id="2_54uqk"]
[ext_resource type="Texture2D" uid="uid://5iygla17stpm" path="res://sprites/faces/curly_not_amused.png" id="3_2t0h4"]
[node name="FaceCurly" type="Node2D" node_paths=PackedStringArray("sprite_happy", "sprite_neutral", "sprite_unhappy")]
script = ExtResource("1_vcbhp")
mood = 1
sprite_happy = NodePath("Happy")
sprite_neutral = NodePath("Neutral")
sprite_unhappy = NodePath("Unhappy")
[node name="Happy" type="Sprite2D" parent="."]
modulate = Color(1, 1, 1, 0)
texture = ExtResource("1_7pet0")
[node name="Neutral" type="Sprite2D" parent="."]
texture = ExtResource("2_54uqk")
[node name="Unhappy" type="Sprite2D" parent="."]
modulate = Color(1, 1, 1, 0)
texture = ExtResource("3_2t0h4")

View File

@ -0,0 +1,38 @@
extends Node2D
@export var mood : int = 0
var last_mood : int = 0
@export var sprite_happy : Sprite2D
@export var sprite_neutral : Sprite2D
@export var sprite_unhappy : Sprite2D
const tween_speed : float = 1.5
const color_transparent : Color = Color(1, 1, 1, 0)
const color_visible : Color = Color(1, 1, 1, 1)
# Called when the node enters the scene tree for the first time.
func _ready():
mood = 0
last_mood = 0
sprite_happy.modulate.a = 0
sprite_neutral.modulate.a = 1
sprite_unhappy.modulate.a = 0
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(_delta):
if mood != last_mood:
var tween = get_tree().create_tween().bind_node(self).set_parallel().set_trans(Tween.TRANS_LINEAR)
if mood < 0:
tween.tween_property(sprite_unhappy, "modulate", color_visible, tween_speed)
tween.tween_property(sprite_neutral, "modulate", color_transparent, tween_speed)
tween.tween_property(sprite_happy, "modulate", color_transparent, tween_speed)
elif mood > 0:
tween.tween_property(sprite_unhappy, "modulate", color_transparent, tween_speed)
tween.tween_property(sprite_neutral, "modulate", color_transparent, tween_speed)
tween.tween_property(sprite_happy, "modulate", color_visible, tween_speed)
else:
tween.tween_property(sprite_unhappy, "modulate", color_transparent, tween_speed)
tween.tween_property(sprite_neutral, "modulate", color_visible, tween_speed)
tween.tween_property(sprite_happy, "modulate", color_transparent, tween_speed)
last_mood = mood

View File

@ -0,0 +1,23 @@
[gd_scene load_steps=5 format=3 uid="uid://bvc6fbd5cgb0i"]
[ext_resource type="Texture2D" uid="uid://f74hle6gaeie" path="res://sprites/faces/curly_happy.png" id="1_7pet0"]
[ext_resource type="Script" path="res://scenes/faces/face.gd" id="1_vcbhp"]
[ext_resource type="Texture2D" uid="uid://oeljmd05bkvj" path="res://sprites/faces/curly_neutral.png" id="2_54uqk"]
[ext_resource type="Texture2D" uid="uid://5iygla17stpm" path="res://sprites/faces/curly_not_amused.png" id="3_2t0h4"]
[node name="FaceCurly" type="Node2D" node_paths=PackedStringArray("sprite_happy", "sprite_neutral", "sprite_unhappy")]
script = ExtResource("1_vcbhp")
sprite_happy = NodePath("Happy")
sprite_neutral = NodePath("Neutral")
sprite_unhappy = NodePath("Unhappy")
[node name="Happy" type="Sprite2D" parent="."]
modulate = Color(1, 1, 1, 0)
texture = ExtResource("1_7pet0")
[node name="Neutral" type="Sprite2D" parent="."]
texture = ExtResource("2_54uqk")
[node name="Unhappy" type="Sprite2D" parent="."]
modulate = Color(1, 1, 1, 0)
texture = ExtResource("3_2t0h4")

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://f74hle6gaeie"
path="res://.godot/imported/curly_happy.png-9e9ff70650ad5d974bed4d467c2fab96.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://sprites/faces/curly_happy.png"
dest_files=["res://.godot/imported/curly_happy.png-9e9ff70650ad5d974bed4d467c2fab96.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
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/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://oeljmd05bkvj"
path="res://.godot/imported/curly_neutral.png-744de6cc3b034dab87651d1b8bea41fc.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://sprites/faces/curly_neutral.png"
dest_files=["res://.godot/imported/curly_neutral.png-744de6cc3b034dab87651d1b8bea41fc.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
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/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://5iygla17stpm"
path="res://.godot/imported/curly_not_amused.png-498d9cc5b1b6d3ab361a6266096d6b59.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://sprites/faces/curly_not_amused.png"
dest_files=["res://.godot/imported/curly_not_amused.png-498d9cc5b1b6d3ab361a6266096d6b59.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
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/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1