From 8859f2e23f25d11cc135755b95d2667d2a88c73b Mon Sep 17 00:00:00 2001 From: betalars Date: Thu, 29 Jun 2023 17:35:30 +0200 Subject: [PATCH] changing random rotation offset to depend on card text --- src/logic-scenes/board/card.gd | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/logic-scenes/board/card.gd b/src/logic-scenes/board/card.gd index e11c46d..bc2d486 100644 --- a/src/logic-scenes/board/card.gd +++ b/src/logic-scenes/board/card.gd @@ -4,7 +4,7 @@ extends Area2D class_name Card var compatible_postits: Array[PostIt] = [] var own_postits: Array[PostIt] = [] -var wiggle_pos: float = randf_range(-100, 100) +var wiggle_pos: float = 0 var wiggle_intensity: float = 0 var noise: Noise = FastNoiseLite.new() var wiggle_tween @@ -16,8 +16,10 @@ var scale_tween if is_inside_tree() or Engine.is_editor_hint(): $Label.text = value $BackgroundSprite.frame = text.hash() % $BackgroundSprite.sprite_frames.get_frame_count($BackgroundSprite.animation) - if is_inside_tree(): - $BackgroundSprite.void_active = value == "" + wiggle_pos = float(text.hash() % 100) + if is_inside_tree() and value == "": + $BackgroundSprite.void_active = true + _handle_wiggle(0) @export var wiggle_strength: float = 0.2 @export var wiggle_speed: float = 5 @export_range(1, 2) var scale_bump: float = 1.05 @@ -50,7 +52,7 @@ var scale_tween @export var voice_line: AudioStream = null func _ready(): - _handle_wiggle(0) + if not Engine.is_editor_hint() and is_inside_tree(): for postit in self.get_children(): if postit is PostIt: self.own_postits.append(postit as PostIt) @@ -64,8 +66,11 @@ func _ready(): own_postits[0].sibling = own_postits[1] own_postits[1].sibling = own_postits[0] - $BackgroundSprite.frame = randi() % $BackgroundSprite.sprite_frames.get_frame_count($BackgroundSprite.animation) + $BackgroundSprite.frame = text.hash() % $BackgroundSprite.sprite_frames.get_frame_count($BackgroundSprite.animation) $Label.text = self.text + + wiggle_pos = float(text.hash() % 100) + _handle_wiggle(0) func _process(delta: float) -> void: