aboutsummaryrefslogtreecommitdiff
path: root/src/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'src/helpers')
-rw-r--r--src/helpers/birthday_start.gd8
-rw-r--r--src/helpers/clouds_move.gd14
-rw-r--r--src/helpers/size_change.gd3
-rw-r--r--src/helpers/start_light.gd8
-rw-r--r--src/helpers/text_fade.gd88
5 files changed, 120 insertions, 1 deletions
diff --git a/src/helpers/birthday_start.gd b/src/helpers/birthday_start.gd
new file mode 100644
index 0000000..4cf5743
--- /dev/null
+++ b/src/helpers/birthday_start.gd
@@ -0,0 +1,8 @@
+extends Timer
+
+
+func _ready():
+ pass
+
+func _on_AnimationPlayer_animation_finished(anim_name):
+ print("!!!!")
diff --git a/src/helpers/clouds_move.gd b/src/helpers/clouds_move.gd
new file mode 100644
index 0000000..3c26fa2
--- /dev/null
+++ b/src/helpers/clouds_move.gd
@@ -0,0 +1,14 @@
+extends ParallaxLayer
+
+export var speed := 20.0
+var offset_x = 0.0
+var last_camera_x = 0.0
+
+func _ready():
+ last_camera_x = get_node("../../Camera2D").get_camera_position().x
+
+func _process(delta):
+ motion_offset = Vector2(offset_x, 0)
+ var new_camera_x = get_node("../../Camera2D").get_camera_position().x
+ offset_x -= delta*speed + (new_camera_x - last_camera_x)*-2
+ last_camera_x = new_camera_x
diff --git a/src/helpers/size_change.gd b/src/helpers/size_change.gd
index b94a192..b86993e 100644
--- a/src/helpers/size_change.gd
+++ b/src/helpers/size_change.gd
@@ -1,14 +1,15 @@
extends Sprite
+
export (OpenSimplexNoise) var noise
export var speed := 20.0
var pos := 0.0
onready var orig_scale = scale
+
func _ready():
pos = rand_range(0,1000)
-
func _process(delta):
pos += delta*speed
scale = orig_scale * (1 + noise.get_noise_1d(pos)*0.2)
diff --git a/src/helpers/start_light.gd b/src/helpers/start_light.gd
new file mode 100644
index 0000000..e8d27d1
--- /dev/null
+++ b/src/helpers/start_light.gd
@@ -0,0 +1,8 @@
+extends Timer
+
+
+func _ready():
+ connect("timeout", self, "_wait_timer_callback")
+
+func _wait_timer_callback():
+ get_node("../light").fade_timer.start()
diff --git a/src/helpers/text_fade.gd b/src/helpers/text_fade.gd
new file mode 100644
index 0000000..ae3db40
--- /dev/null
+++ b/src/helpers/text_fade.gd
@@ -0,0 +1,88 @@
+extends RichTextLabel
+
+export(PoolColorArray) var char_colors = PoolColorArray()
+export var fade_step_time = 0.1
+export var do_autostart = true
+export var char_delta = 1.0
+export var char_step = 0.01
+export var time_until_fadeout = 1.0
+
+var fade_timer
+var wait_timer
+var delta
+var current_max_index
+var last_index_delta
+var fadein
+
+func set_bbcode_opacity():
+ var new_bbcode = str("")
+
+ for i in min(char_colors.size(), text.length()):
+ if i <= current_max_index:
+ if fadein == true:
+ char_colors[i].a = min(char_colors[i].a + char_step, 1.0)
+ else:
+ char_colors[i].a = max(char_colors[i].a - char_step, 0.0)
+ new_bbcode += "[color=#" + char_colors[i].to_html(true) + "]" + text[i] + "[/color]"
+
+ set_bbcode(new_bbcode)
+
+ if char_colors[char_colors.size() - 1].a == 1.0 and fadein == true:
+ fade_timer.stop()
+ wait_timer.start()
+
+func set_next_char():
+ last_index_delta = delta
+ current_max_index = min(current_max_index + 1, text.length())
+
+func reset(_fadein = true):
+ delta = 0
+ current_max_index = 0
+ last_index_delta = delta
+ fadein = _fadein
+
+func _ready():
+ if char_colors.size() > text.length() or char_colors.size() == 0:
+ push_error (str(self.name) + ": Size of character colors more than the text length: " + str(char_colors.size()) + " > " + str(text.length()))
+ get_tree().quit(-1)
+
+ if char_colors.size() < text.length():
+ var i = char_colors.size() - 1
+ while i < text.length() - 1:
+ char_colors.append(char_colors[i])
+ i += 1
+
+ for i in char_colors.size():
+ char_colors[i].a = 0.0
+
+ current_max_index = -1
+ set_bbcode_opacity()
+ reset(true)
+
+ fade_timer = Timer.new()
+ fade_timer.set_one_shot(false)
+ fade_timer.set_wait_time(fade_step_time)
+ fade_timer.set_autostart(do_autostart)
+ fade_timer.connect("timeout", self, "_fade_timer_callback")
+ add_child(fade_timer)
+
+ wait_timer = Timer.new()
+ wait_timer.set_one_shot(true)
+ wait_timer.set_wait_time(time_until_fadeout)
+ wait_timer.set_autostart(false)
+ wait_timer.connect("timeout", self, "_wait_timer_callback")
+ add_child(wait_timer)
+
+func _process(_delta):
+ delta += _delta
+
+func _fade_timer_callback():
+ if current_max_index >= 0:
+ if delta > last_index_delta + char_delta:
+ set_next_char()
+
+ set_bbcode_opacity()
+
+func _wait_timer_callback():
+ reset(false)
+ fade_timer.start()