Learn to Code via Tutorials on Repl.it!

← Back to all posts
Best c# effects
Bunnytoes (147)

Code for typewriter and part 4 on code created by @SixBeeps modified by me

You start the code with

using System;
using System.Threading;

To change the color you write

Console.ForegroundColor = ConsoleColor.Cyan;
//do almost any color and have the first letter in caps

to do a deleting you do this:

Console.WriteLine("Awesome");
      Thread.Sleep(183);
      Console.Clear();
      Console.WriteLine("Awesom");
      Thread.Sleep(183);
      Console.Clear();
      Console.WriteLine("Aweso");
      Thread.Sleep(183);
      Console.Clear();
      Console.WriteLine("Awes");
      Thread.Sleep(183);
      Console.Clear();
      Console.WriteLine("Awe");
      Thread.Sleep(183);
      Console.Clear();
      Console.WriteLine("Aw");
      Thread.Sleep(183);
      Console.Clear();
      Console.WriteLine("A");
      Thread.Sleep(183);
      Console.Clear();
      Console.WriteLine("");
      Thread.Sleep(183);
      Console.Clear();

You can do any delay but this works best

now to go a unlocking effects you do this:

Console.WriteLine("Unlocking.");
      Thread.Sleep(183);
      Console.Clear();
      Console.WriteLine("Unlocking..");
      Thread.Sleep(183);
      Console.Clear();
      Console.WriteLine("Unlocking...");
      Thread.Sleep(183);
      Console.Clear();
      Console.WriteLine("Unlocking.");
      Thread.Sleep(183);
      Console.Clear();
      Console.WriteLine("Unlocking..");
      Thread.Sleep(183);
      Console.Clear();
      Console.WriteLine("Unlocking...");
      Thread.Sleep(183);
      Console.Clear();
      Console.WriteLine("Unlocking.");
      Thread.Sleep(183);
      Console.Clear();
      Console.WriteLine("Unlocking..");
      Thread.Sleep(183);
      Console.Clear();
      Console.WriteLine("Unlocking...");
      Thread.Sleep(183);
      Console.Clear();

do any sleep time but this works the best for me

to do the slowprint/typewriter do this code:

using System;
using System.Threading;
using System.Collections.Generic;

class MainClass {
	public static Dictionary<int, float> options = new Dictionary<int, float> {
    {1, 1/1f},	
  	{2, 1/5f},
    {3, 1/10f},
    {4, 1/15f},
		{5, 1/25f},
		{6, 1/35f},
    {7, 1/45f},
    {8, 1/55f}
	};

  public static void Main (string[] args) {
    Console.WriteLine("Enter words to slowprint");
    string slowwwww = Console.ReadLine();
    
    Console.Clear();
    Console.WriteLine ("Pick a slowprint speed:\n\n1.) 1 CPS\n2.) 5 CPS\n3.) 10 CPS\n4.) 15 CPS\n5.) 25 CPS\n6.) 35 CPS\n7.) 45 CPS\n8. 55 CPS)");
		int choice;
		do {
			Console.Write("> ");
		} while (int.TryParse(Console.ReadLine(), out choice) == false || choice < 1 || choice > 8);

		Slowprint(slowwwww, options[choice]);
  }

	public static void Slowprint(string text, float waitTime) {
		foreach (char c in text.ToCharArray()) {
			Console.Write(c);
			Thread.Sleep((int)(waitTime * 1000));
		}
		Console.WriteLine();
	}
}

or do this

Console.Write("H");
  Thread.Sleep(183);
  Console.Write("e");
  Thread.Sleep(183);
  Console.Write("l");
  Thread.Sleep(183);
  Console.Write("l");
  Thread.Sleep(183);
  Console.Write("o\n");

and last to change the background you do

Console.BackgroundColor = ConsoleColor.Red;
//you can do any color with a caps

this is an arrow key detector(can swap out some of them)

using System;

class MainClass {
  public static void Main (string[] args) {
     Console.WriteLine("Enter an arrow key");
 ConsoleKeyInfo arrow = Console.ReadKey();
     switch (arrow.Key) {
 
 case (ConsoleKey.LeftArrow):
 Console.WriteLine("You chose left");
  break;
case (ConsoleKey.RightArrow):
Console.WriteLine("You chose right");
break;

case (ConsoleKey.UpArrow):
Console.WriteLine("You chose up");
break;
case (ConsoleKey.DownArrow):
Console.WriteLine("You chose down");
break;

case (ConsoleKey.Enter):
Console.WriteLine("I said arrow keys not enter");
break;

default:
Console.WriteLine("I said do an arrow key");
   break;
    }
  }
}

now here is a c# \ tutorial
you have seen the

\
before right? Well I am hear to teach what what they mean, starting with

\n
it creates a new lines, next the

\t
it creates a tab, the

\b
deletes the character before it, and finaly the

\r
takes the word behind it, and deletes the amount of characters it is from the front and then brings it to the front.

example code for \r

Console.WriteLine("Hello \ryou");

output:

alright this is the end of the tutorial and I hope you enjoyed!

Comments
hotnewtop
JWZ6 (651)

@Bunnytoes np btw i think ur \ tutorial is a bit too brief

Bunnytoes (147)

@JWZ6 I may add onto it later