diff options
author | David Luevano Alvarado <david@luevano.xyz> | 2022-06-01 03:27:11 -0600 |
---|---|---|
committer | David Luevano Alvarado <david@luevano.xyz> | 2022-06-01 03:27:11 -0600 |
commit | 2c5d588bc593929a96f0e58d7d1ab52f269add55 (patch) | |
tree | 17c3cd8f5a880197734fc1530766f01eec5ea425 /src/tools | |
parent | daa89fdeccc46e1ae871651eeedde47808ac03d1 (diff) |
make working basic snake, refactor code and made gif recorder its separate thing
Diffstat (limited to 'src/tools')
-rw-r--r-- | src/tools/ScreenRecorder.tscn | 31 | ||||
-rw-r--r-- | src/tools/screen_recorder.gd | 13 |
2 files changed, 44 insertions, 0 deletions
diff --git a/src/tools/ScreenRecorder.tscn b/src/tools/ScreenRecorder.tscn new file mode 100644 index 0000000..d29753a --- /dev/null +++ b/src/tools/ScreenRecorder.tscn @@ -0,0 +1,31 @@ +[gd_scene load_steps=4 format=2] + +[ext_resource path="res://addons/GifMaker/GifRectangle.gd" type="Script" id=1] +[ext_resource path="res://tools/screen_recorder.gd" type="Script" id=2] +[ext_resource path="res://addons/GifMaker/GifRecorder.gd" type="Script" id=3] + +[node name="ScreenRecorder" type="CanvasLayer"] +script = ExtResource( 2 ) + +[node name="Control" type="Control" parent="."] +anchor_right = 1.0 +anchor_bottom = 1.0 + +[node name="GifRectangle" type="ReferenceRect" parent="Control"] +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +margin_left = -128.0 +margin_top = -128.0 +margin_right = 128.0 +margin_bottom = 128.0 +script = ExtResource( 1 ) + +[node name="GifRecorder" type="Viewport" parent="Control"] +size = Vector2( 2, 2 ) +script = ExtResource( 3 ) +render_type = 1 +seconds = 4.0 +autostart = true +capture_node_path = NodePath("../GifRectangle") diff --git a/src/tools/screen_recorder.gd b/src/tools/screen_recorder.gd new file mode 100644 index 0000000..2ab77e5 --- /dev/null +++ b/src/tools/screen_recorder.gd @@ -0,0 +1,13 @@ +extends CanvasLayer + +onready var gif_recorder: GifRecorder = $Control/GifRecorder + + +func _input(event: InputEvent) -> void: + if event is InputEventKey and event.scancode == KEY_G and event.pressed: + print("Encoding GIF.") + gif_recorder.render_to_file("res://test.gif") + yield(gif_recorder, "done_encoding") + print("Done encoding GIF.") + gif_recorder.clear() + gif_recorder.start() |