diff options
author | nokoe <nokoe@mailbox.org> | 2025-04-10 15:55:59 +0200 |
---|---|---|
committer | nokoe <nokoe@mailbox.org> | 2025-04-10 15:56:26 +0200 |
commit | ba085c63d3687fd33c99c87b002a51c95beef7f7 (patch) | |
tree | c225e1b18faefc8c2a5f2e421a39fc53fbc9a8f5 | |
parent | 35c24bb62710d06fc1739bfab2242e16290911a7 (diff) | |
download | hurrycurry-ba085c63d3687fd33c99c87b002a51c95beef7f7.tar hurrycurry-ba085c63d3687fd33c99c87b002a51c95beef7f7.tar.bz2 hurrycurry-ba085c63d3687fd33c99c87b002a51c95beef7f7.tar.zst |
add cat ears
-rw-r--r-- | client/global.gd | 2 | ||||
-rw-r--r-- | client/player/character/cat_ears.gd | 34 | ||||
-rw-r--r-- | client/player/character/cat_ears.gd.uid | 1 | ||||
-rw-r--r-- | client/player/character/cat_ears.tscn | 17 | ||||
-rw-r--r-- | client/player/character/character.gd | 17 | ||||
-rw-r--r-- | client/player/character/character.tscn | 6 | ||||
-rw-r--r-- | client/player/character/hairstyles/cat_ears.res | bin | 0 -> 4691 bytes | |||
-rw-r--r-- | data/maps/debug2.yaml | 2 |
8 files changed, 73 insertions, 6 deletions
diff --git a/client/global.gd b/client/global.gd index ff88593e..56566bbe 100644 --- a/client/global.gd +++ b/client/global.gd @@ -200,7 +200,7 @@ func get_hint(key: String): static func interpolate(current, target, dt): return target + (current - target) * exp(-dt) -static func interpolate_angle(current, target, dt): +static func interpolate_angle(current, target, dt) -> float: current = fmod(current, PI * 2) target = fmod(target, PI * 2) if target - current > PI: target -= PI * 2 diff --git a/client/player/character/cat_ears.gd b/client/player/character/cat_ears.gd new file mode 100644 index 00000000..fbf2c8e2 --- /dev/null +++ b/client/player/character/cat_ears.gd @@ -0,0 +1,34 @@ +# Hurry Curry! - a game about cooking +# Copyright 2025 nokoe +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, version 3 of the License only. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <https://www.gnu.org/licenses/>. +# +class_name CatEars +extends Node3D + +const EAR_ROTATION := deg_to_rad(20.) +var ear_target := 0. + +func set_inner_mat(mat: BaseMaterial3D): + $Left.set_surface_override_material(1, mat) + $Right.set_surface_override_material(1, mat) + + +func set_outer_mat(mat: BaseMaterial3D): + $Left.set_surface_override_material(0, mat) + $Right.set_surface_override_material(0, mat) + +func _process(delta: float) -> void: + if visible: + $Right.rotation.z = G.interpolate_angle($Right.rotation.z, ear_target + EAR_ROTATION, delta * 10.) + $Left.rotation.z = G.interpolate_angle($Left.rotation.z, PI + ear_target + EAR_ROTATION, delta * 10.) diff --git a/client/player/character/cat_ears.gd.uid b/client/player/character/cat_ears.gd.uid new file mode 100644 index 00000000..23c4925e --- /dev/null +++ b/client/player/character/cat_ears.gd.uid @@ -0,0 +1 @@ +uid://cyyugv3ylq8ux diff --git a/client/player/character/cat_ears.tscn b/client/player/character/cat_ears.tscn new file mode 100644 index 00000000..ab1d96eb --- /dev/null +++ b/client/player/character/cat_ears.tscn @@ -0,0 +1,17 @@ +[gd_scene load_steps=3 format=3 uid="uid://dspkdcg1ui6dl"] + +[ext_resource type="ArrayMesh" uid="uid://3k87npushfgh" path="res://player/character/hairstyles/cat_ears.res" id="1_5c3r8"] +[ext_resource type="Script" uid="uid://cyyugv3ylq8ux" path="res://player/character/cat_ears.gd" id="1_q747p"] + +[node name="CatEars" type="Node3D"] +script = ExtResource("1_q747p") + +[node name="Left" type="MeshInstance3D" parent="."] +transform = Transform3D(-0.391948, 0.0798526, 2.14072e-08, 0.0798526, 0.391948, 6.34998e-09, 1.97086e-08, -1.04957e-08, 0.4, -0.0100086, 0.361507, 1.20572e-08) +mesh = ExtResource("1_5c3r8") +skeleton = NodePath("") + +[node name="Right" type="MeshInstance3D" parent="."] +transform = Transform3D(0.389421, -0.0913844, -2.23025e-08, 0.0913844, 0.389421, 5.89238e-09, 2.03665e-08, -1.08318e-08, 0.4, 0.0104306, 0.370664, 1.26181e-08) +mesh = ExtResource("1_5c3r8") +skeleton = NodePath("") diff --git a/client/player/character/character.gd b/client/player/character/character.gd index acdd1c1a..938c7c45 100644 --- a/client/player/character/character.gd +++ b/client/player/character/character.gd @@ -46,6 +46,7 @@ var current_animation := "idle" @onready var username_tag = $Username @onready var tie = $Main/Tie @onready var knife = $Main/HandRight/Knife +@onready var cat_ears: CatEars = $Main/HeadDefault/CatEars const NUM_COLORS = 5; const NUM_HAIRS = 3; @@ -69,6 +70,7 @@ class ParsedStyle: var hair: int var kind: CharacterKind = CharacterKind.PERSON var customer: bool + var cat_ears: bool func _init(n: int) -> void: customer = n < 0 if customer: n *= -1 @@ -77,6 +79,7 @@ class ParsedStyle: else: hair = n % NUM_HAIRS color = n / NUM_HAIRS % NUM_COLORS + cat_ears = floor(n / 4) % 2 == 0 func pack() -> int: if CharacterKind.BOT: return 51 elif CharacterKind.TRAM: return 52 @@ -88,9 +91,13 @@ func _ready(): var t := 0.0 func _process(delta): t += delta - if walking: main_height_target = default_height + sin(t * WALK_ANIM_SPEED) * WALK_ANIM_STRENGTH - else: t = 0 - main.position.y = main_height_target + if walking: + main_height_target = default_height + sin(t * WALK_ANIM_SPEED) * WALK_ANIM_STRENGTH + cat_ears.ear_target = sin(t * WALK_ANIM_SPEED) * 0.075 + else: + t = 0 + cat_ears.ear_target = 0. + main.position.y = G.interpolate(main.position.y, main_height_target, delta * 10.) # Update animation: var next_animation: String @@ -119,9 +126,13 @@ func set_style(id: int): head_default.visible = p.kind == CharacterKind.PERSON $Main.visible = not p.kind == CharacterKind.TRAM $Tram.visible = p.kind == CharacterKind.TRAM + cat_ears.visible = p.cat_ears for h in hairstyles: h.hide() hairstyles[p.hair].show() $Main.get_active_material(0).albedo_color = Color(0.349, 0.349, 0.349) if p.kind == CharacterKind.BOT else COLORS[p.color] + if p.cat_ears: + cat_ears.set_inner_mat($Main.get_active_material(0)) + cat_ears.set_outer_mat(hairstyles[p.hair].get_active_material(0)) func play_animation(name_: String): current_animation = name_ diff --git a/client/player/character/character.tscn b/client/player/character/character.tscn index 07da7498..e1792528 100644 --- a/client/player/character/character.tscn +++ b/client/player/character/character.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=29 format=3 uid="uid://b3hhir2fvnunu"] +[gd_scene load_steps=30 format=3 uid="uid://b3hhir2fvnunu"] [ext_resource type="Script" uid="uid://dwk3vd4nv2k65" path="res://player/character/character.gd" id="1_12lbh"] [ext_resource type="ArrayMesh" uid="uid://bnmm01yjwultj" path="res://player/character/default/main.res" id="2_uovyg"] @@ -10,6 +10,7 @@ [ext_resource type="ArrayMesh" uid="uid://dx7jswwaesok4" path="res://player/character/hairstyles/hair_2.res" id="7_1403k"] [ext_resource type="ArrayMesh" uid="uid://c5qsthvtf3cta" path="res://player/character/hairstyles/hair_3.res" id="8_x5g32"] [ext_resource type="ArrayMesh" uid="uid://c2qnwt44x8ujl" path="res://player/character/default/tie.res" id="9_kgric"] +[ext_resource type="PackedScene" uid="uid://dspkdcg1ui6dl" path="res://player/character/cat_ears.tscn" id="10_8pcb3"] [ext_resource type="AudioStream" uid="uid://bxiorkb4xb8t1" path="res://player/sounds/step1.ogg" id="10_qpd6x"] [ext_resource type="PackedScene" uid="uid://c6sqsj7r03qp1" path="res://player/character/robot/head.tscn" id="10_w8s0d"] [ext_resource type="AudioStream" uid="uid://l2fd8u7rq3cq" path="res://player/sounds/step2.ogg" id="11_2dmo8"] @@ -772,6 +773,8 @@ visible = false mesh = ExtResource("8_x5g32") skeleton = NodePath("") +[node name="CatEars" parent="Main/HeadDefault" instance=ExtResource("10_8pcb3")] + [node name="Tie" type="MeshInstance3D" parent="Main"] transform = Transform3D(0.125, 0, 0, 0, 0.125, 0, 0, 0, 0.125, 0, 0.47772, 0.445265) mesh = ExtResource("9_kgric") @@ -847,5 +850,6 @@ no_depth_test = true text = "Username" [node name="Tram" parent="." instance=ExtResource("18_8h5ka")] +visible = false [connection signal="animation_finished" from="HandAnimations" to="." method="_on_hand_animations_animation_finished"] diff --git a/client/player/character/hairstyles/cat_ears.res b/client/player/character/hairstyles/cat_ears.res Binary files differnew file mode 100644 index 00000000..ae31fa69 --- /dev/null +++ b/client/player/character/hairstyles/cat_ears.res diff --git a/data/maps/debug2.yaml b/data/maps/debug2.yaml index 029d77f3..02e67809 100644 --- a/data/maps/debug2.yaml +++ b/data/maps/debug2.yaml @@ -101,7 +101,7 @@ entities: character: 52 points: [[3, 3], [23, 3], [23, 15], [3, 15]] smoothing: 3. - spacing: 0.35 + spacing: 0.3625 chef_spawn: "~" customer_spawn: "!" |