Skip to content

Instantly share code, notes, and snippets.

@omni-
Last active August 29, 2015 14:02
Show Gist options
  • Save omni-/520f3bbb4d181aacd3f4 to your computer and use it in GitHub Desktop.
Save omni-/520f3bbb4d181aacd3f4 to your computer and use it in GitHub Desktop.
Scrolling Console Text
public static string GetTitle()
{
List<string> titlelist = new List<string>()
{
"Slimes OP",
"Now with Color!",
"Stochastic!",
"Sammy Classic Sonic Fan!",
"Expand",
"Drugs are bad, kids",
"Realm 2 Coming -S-o-o-n- -S-o-m-e-d-a-y- Probably!",
"A Game of Slimes",
"I, for one, welcome our new Slime overlord.",
"Revengeance",
"Redemption",
"A Slimes' Tale",
"Masaaki Endoh Version",
"Big in Japan",
"Is this thing on?"
};
int result = Main.rand.Next(0, titlelist.Count);
return titlelist[result];
}
public static void typeNoDelay(string src, ConsoleColor color)
{
Console.WriteLine(src, color);
}
public static void type(string src, int speed)
{
Main.is_typing = true;
Console.WriteLine("\r\n");
foreach (char c in src)
{
Console.Write(c);
Thread.SpinWait(speed * 1000000);
}
Main.is_typing = false;
}
public static void type(string src)
{
Main.is_typing = true;
Console.WriteLine("\r\n");
foreach (char c in src)
{
Console.Write(c);
Thread.SpinWait(1000000);
}
Main.is_typing = false;
}
public static void typeOnSameLine(string src)
{
Main.is_typing = true;
foreach (char c in src)
{
Console.Write(c);
Thread.SpinWait(1000000);
}
Main.is_typing = false;
}
public static void typeOnSameLine(string src, int speed)
{
Main.is_typing = true;
foreach (char c in src)
{
Console.Write(c);
Thread.SpinWait(1000000 * speed);
}
Main.is_typing = false;
}
public static void typeOnSameLine(string src, ConsoleColor color)
{
Main.is_typing = true;
Console.ForegroundColor = color;
foreach (char c in src)
{
Console.Write(c);
Thread.SpinWait(1000000);
}
Main.is_typing = false;
Console.ResetColor();
}
public static void typeOnSameLine(string src, int speed, ConsoleColor color)
{
Main.is_typing = true;
Console.ForegroundColor = color;
foreach (char c in src)
{
Console.Write(c);
Thread.SpinWait(1000000 * speed);
}
Main.is_typing = false;
Console.ResetColor();
}
public static void type(string src, ConsoleColor color)
{
Main.is_typing = true;
Console.ForegroundColor = color;
Console.WriteLine("\r\n");
foreach (char c in src)
{
Console.Write(c);
Thread.SpinWait(1000000);
}
Main.is_typing = false;
Console.ResetColor();
}
public static void type(string src, int speed, ConsoleColor color)
{
Main.is_typing = true;
Console.ForegroundColor = color;
Console.WriteLine("\r\n");
foreach (char c in src)
{
Console.Write(c);
Thread.SpinWait(1000000 * speed);
}
Main.is_typing = false;
Console.ResetColor();
}
public static void type(string src, bool rainbow)
{
if (rainbow)
{
Main.is_typing = true;
List<ConsoleColor> colors = new List<ConsoleColor> { ConsoleColor.Blue, ConsoleColor.Cyan, ConsoleColor.DarkMagenta, ConsoleColor.Green, ConsoleColor.Magenta, ConsoleColor.Red, ConsoleColor.White, ConsoleColor.Yellow };
Console.WriteLine("\r\n");
string[] words = src.Split();
int i = 0;
foreach (string word in words)
{
if (word != words[0])
Console.Write(" ");
Console.ForegroundColor = colors[i];
foreach (char c in word)
{
Console.Write(c);
Thread.SpinWait(1000000);
}
i++;
if (i > colors.Count - 1)
i = 0;
}
Main.is_typing = false;
Console.ResetColor();
}
else
{
Main.is_typing = true;
Console.WriteLine("\r\n");
foreach (char c in src)
{
Console.Write(c);
Thread.SpinWait(1000000);
}
Main.is_typing = false;
}
}
public static void type(string src, int speed, bool rainbow)
{
if (rainbow)
{
Main.is_typing = true;
List<ConsoleColor> colors = new List<ConsoleColor> { ConsoleColor.Blue, ConsoleColor.Cyan, ConsoleColor.DarkMagenta, ConsoleColor.Green, ConsoleColor.Magenta, ConsoleColor.Red, ConsoleColor.White, ConsoleColor.Yellow };
Console.WriteLine("\r\n");
string[] words = src.Split();
int i = 0;
foreach (string word in words)
{
if (word != words[0])
Console.Write(" ");
Console.ForegroundColor = colors[i];
foreach (char c in word)
{
Console.Write(c);
Thread.SpinWait(1000000 * speed);
}
i++;
if (i > colors.Count - 1)
i = 0;
}
Main.is_typing = false;
Console.ResetColor();
}
else
{
Main.is_typing = true;
Console.WriteLine("\r\n");
foreach (char c in src)
{
Console.Write(c);
Thread.SpinWait(1000000 * speed);
}
Main.is_typing = false;
}
}
public static ConsoleKeyInfo readkey()
{
while (Main.is_typing)
{
while (Console.KeyAvailable) Console.ReadKey(true);
ConsoleKeyInfo key = Console.ReadKey(true);
}
return Console.ReadKey();
}
public static string readinput()
{
while (Main.is_typing)
{
while (Console.KeyAvailable) Console.ReadKey(true);
ConsoleKeyInfo key = Console.ReadKey(true);
}
return Console.ReadLine().ToLower();
}
public static string readinput(bool ExactSpelling)
{
if (ExactSpelling)
{
while (Main.is_typing)
{
while (Console.KeyAvailable) Console.ReadKey(true);
ConsoleKeyInfo key = Console.ReadKey(true);
}
return Console.ReadLine();
}
else
{
while (Main.is_typing)
{
while (Console.KeyAvailable) Console.ReadKey(true);
ConsoleKeyInfo key = Console.ReadKey(true);
}
return Console.ReadLine().ToLower();
}
}
public static string ToUpperFirstLetter(this string source)
{
if (string.IsNullOrEmpty(source))
return string.Empty;
// convert to char array of the string
char[] letters = source.ToCharArray();
// upper case the first char
letters[0] = char.ToUpper(letters[0]);
// return the array made of the new char array
return new string(letters);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment