implement sprite-sheet switching depending on age and room

This commit is contained in:
betalars 2026-03-11 13:56:53 +01:00
parent 8637479c82
commit 1c9c95f3b4
2 changed files with 31 additions and 3 deletions

View File

@ -2,6 +2,7 @@ extends Draggable
class_name Card
var card_id : StringName
var from_youth: bool
enum burned {
NOT,
@ -141,6 +142,8 @@ func init(card_name: String = "card", own_id:StringName = "-1") -> void:
push_error("Illegal card!", card_name, own_id)
card_id = own_id
name = card_name
# first digit of the card id is 0-3 for youth cards.
from_youth = (card_id as String)[0] as int < 4
func _ready():
@ -154,6 +157,14 @@ func _ready():
func _on_text_updated():
if is_node_ready() and name != "c_void" and name != "3.c_void":
if from_youth:
if State.current_room == State.rooms.YOUTH or State.onready_room == State.rooms.YOUTH:
background_sprite.animation = "youth"
else:
background_sprite.animation = "aged"
else:
background_sprite.animation = "adult"
var curr_frame := text.hash() % background_sprite.sprite_frames.get_frame_count(background_sprite.animation)
background_sprite.frame = curr_frame
@ -168,7 +179,11 @@ func _on_text_updated():
wiggle_pos = float(text.hash() % 100)
label.rotation = deg_to_rad(transfor_arr[curr_frame].get_rotation())
# the adult cards are more straight.
if from_youth:
label.rotation = deg_to_rad(transfor_arr[curr_frame].get_rotation())
else:
label.rotation = 0.0
#label.position = transfor_arr[curr_frame].origin
burn_progress = burn_progress

View File

@ -1,8 +1,9 @@
extends Draggable
class_name StickyNote
var sticky_id
var parent_id : StringName
var sticky_id: StringName
var parent_id: StringName
var from_youth: bool
var sibling: StickyNote
var shift_tween: Tween
@ -70,6 +71,9 @@ func init(sticky_name: String = "sticky_note", card_id: StringName = "-1") -> vo
parent_id = StringName(card_id.rsplit(".", false, 1)[0])
sticky_id = card_id
# first digit of the card id is 0-3 for youth cards.
from_youth = (card_id as String)[0] as int < 4
func _ready() -> void:
super._ready()
label = $Content/Label
@ -81,6 +85,15 @@ func _ready() -> void:
func _on_text_updated():
label.text = text
if from_youth:
if State.current_room == State.rooms.YOUTH or State.onready_room == State.rooms.YOUTH:
background_sprite.animation = "youth"
else:
background_sprite.animation = "aged"
else:
background_sprite.animation = "adult"
background_sprite.frame = text.hash() % background_sprite.sprite_frames.get_frame_count(background_sprite.animation)