Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static bool Speaking;
- const int TypeSpeed = 50;
- private static readonly char[] SlowChars = new char[] { '!', '?', ',', '.' };
- public static void AnimatedText(string Text, bool speech = false, bool Centering = false)
- {
- Speaking = true;
- if (Centering)
- Console.CursorLeft = (Console.BufferWidth - Text.Length) / 2;
- ThreadPool.QueueUserWorkItem(delegate
- {
- for (int i = 0; i < Text.Length; i++)
- {
- if (Speaking)
- {
- if (SlowChars.Contains(Text[i]) && speech)
- {
- Console.Write(Text[i]);
- Thread.Sleep(TypeSpeed * 10);
- }
- else
- {
- Console.Write(Text[i]);
- Thread.Sleep(TypeSpeed);
- }
- }
- }
- Console.WriteLine();
- Speaking = false;
- });
- Console.ReadKey(true);
- Speaking = false;
- Console.Clear();
- if (Centering)
- Console.CursorLeft = (Console.BufferWidth - Text.Length) / 2;
- Console.WriteLine(Text);
- Console.ReadKey(true);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement