add matrix text effect
bendn 2022-05-06
parent 6cfaa60 · commit 0198a32
-rw-r--r--Chat.gd5
-rw-r--r--icon.pngbin3498 -> 63168 bytes
-rw-r--r--matrix.gd28
-rw-r--r--project.godot10
4 files changed, 39 insertions, 4 deletions
diff --git a/Chat.gd b/Chat.gd
index 9caf8ad..d7084eb 100644
--- a/Chat.gd
+++ b/Chat.gd
@@ -10,7 +10,7 @@ onready var scrollbar = scroller.get_v_scrollbar()
func _ready():
add_label(
- "[b]server[color=#f0e67e]:[/color][/b] [b] welcome to [rainbow freq=.3 sat=.7][shake rate=20 level=25]room 2![/shake][/rainbow]",
+ "[b]server[color=#f0e67e]:[/color] [matrix]welcome to[/matrix] [rainbow freq=.3 sat=.7][shake rate=20 level=25]room 2!",
"server"
)
@@ -23,9 +23,10 @@ func _on_Main_recieved(data):
func add_label(bbcode: String, name = "richtextlabel"):
var l = RichTextLabel.new()
l.name = name
- labels.add_child(l)
l.rect_min_size = Vector2(1000, 40)
+ l.install_effect(RichTextMatrix.new())
l.bbcode_enabled = true
+ labels.add_child(l)
l.append_bbcode(bbcode)
tween.interpolate_property(
scrollbar, "value", scrollbar.value, scrollbar.max_value, .5, Tween.TRANS_BOUNCE
diff --git a/icon.png b/icon.png
index a0b64ee..fae5477 100644
--- a/icon.png
+++ b/icon.png
Binary files differ
diff --git a/matrix.gd b/matrix.gd
new file mode 100644
index 0000000..8f07f94
--- /dev/null
+++ b/matrix.gd
@@ -0,0 +1,28 @@
+tool extends RichTextEffect
+class_name RichTextMatrix
+
+var bbcode = "matrix"
+
+func _init():
+ resource_name = "RichTextMatrix"
+
+func _process_custom_fx(char_fx : CharFXTransform) -> bool:
+ var clear_time = char_fx.env.get("clean", 2.0)
+ var dirty_time = char_fx.env.get("dirty", 1.0)
+ var text_span = char_fx.env.get("span", 50)
+
+ var value = char_fx.character
+
+ var matrix_time = fmod(char_fx.elapsed_time + (char_fx.absolute_index / float(text_span)), \
+ clear_time + dirty_time)
+
+ matrix_time = 0.0 if matrix_time < clear_time else \
+ (matrix_time - clear_time)/dirty_time
+
+ if( value >= 65 && value < 126 && matrix_time > 0.0 ):
+ value -= 65
+ value = value + int((1 * matrix_time * (126-65)))
+ value %= (126 - 65)
+ value += 65
+ char_fx.character = value
+ return true \ No newline at end of file
diff --git a/project.godot b/project.godot
index b9a6c69..77f90ef 100644
--- a/project.godot
+++ b/project.godot
@@ -13,14 +13,20 @@ _global_script_classes=[ {
"class": "Network",
"language": "GDScript",
"path": "res://WS.gd"
+}, {
+"base": "RichTextEffect",
+"class": "RichTextMatrix",
+"language": "GDScript",
+"path": "res://matrix.gd"
} ]
_global_script_class_icons={
-"Network": ""
+"Network": "",
+"RichTextMatrix": ""
}
[application]
-config/name="chat app"
+config/name="room2"
run/main_scene="res://WS.tscn"
config/icon="res://icon.png"