Skip to content

Commit

Permalink
New node ShiftingLabel for visualizing consonant/vowel pools
Browse files Browse the repository at this point in the history
  • Loading branch information
kesac committed Jun 12, 2024
1 parent 38368e1 commit bec2acc
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
30 changes: 30 additions & 0 deletions Syllabore/Syllabore.Visualizer/ShiftingLabel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using Godot;
using System;
using System.Collections.Generic;

public partial class ShiftingLabel : Label
{
private Random _random;

// Strings to shift through
public List<string> Values;

public override void _Ready()
{
_random = new Random();
this.Values = new List<string>();
this.GetNode<Timer>("Timer").Start();
}

// Randomly select a value from the list
// and set the value of this label
public void Shift()
{
if (this.Values.Count > 0)
{
var index = _random.Next(0, this.Values.Count);
this.Text = this.Values[index].ToUpper();
}
}

}
21 changes: 21 additions & 0 deletions Syllabore/Syllabore.Visualizer/ShiftingLabel.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[gd_scene load_steps=3 format=3 uid="uid://cr4njnftd3faq"]

[ext_resource type="Script" path="res://ShiftingLabel.cs" id="1_53b72"]

[sub_resource type="LabelSettings" id="LabelSettings_0r5f7"]
font_size = 35

[node name="ShiftingLabel" type="Label"]
offset_right = 40.0
offset_bottom = 23.0
text = "X"
label_settings = SubResource("LabelSettings_0r5f7")
horizontal_alignment = 1
vertical_alignment = 1
script = ExtResource("1_53b72")

[node name="Timer" type="Timer" parent="."]
wait_time = 0.2
autostart = true

[connection signal="timeout" from="Timer" to="." method="Shift"]

0 comments on commit bec2acc

Please sign in to comment.