Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading;
- namespace ConsoleApplication1
- {
- class Program
- {
- static int ColorIndex = 0;
- static double sinAngle = 0;
- static int xx = 0;
- static int yy = 0;
- static int hsp = 0;
- static int vsp = 0;
- private static ConsoleColor getCol(int index)
- {
- ConsoleColor col = ConsoleColor.Black;
- switch(index){
- case 0: col = ConsoleColor.Red; break;
- case 1: col = ConsoleColor.Green; break;
- case 2: col = ConsoleColor.Magenta; break;
- case 3: col = ConsoleColor.Cyan; break;
- case 4: col = ConsoleColor.Yellow; break;
- case 5: col = ConsoleColor.DarkGreen; break;
- case 6: col = ConsoleColor.DarkBlue; break;
- }
- return col;
- }
- static void Main(string[] args)
- {
- String str = Console.ReadLine();
- int width = str.Length;
- Random rnd = new Random();
- hsp = rnd.Next(-2, 2);
- vsp = rnd.Next(-2, 2);
- xx = (int)((Console.WindowWidth / 2) - width / 2);
- yy = (int)(Console.WindowHeight / 2);
- Console.Clear();
- while (true)
- {
- if (Console.KeyAvailable)
- {
- if (Console.ReadKey().Key == ConsoleKey.Escape)
- {
- return;
- }
- }
- if ((xx + width + hsp) >= Console.WindowWidth)
- {
- hsp = -hsp;
- }
- if ((xx + hsp) <= 0)
- {
- hsp = -hsp;
- }
- if ((yy + vsp) >= Console.WindowHeight - 1)
- {
- vsp = -vsp;
- }
- if ((yy + vsp) <= 0)
- {
- vsp = -vsp;
- }
- xx += hsp;
- yy += vsp;
- Thread.Sleep(50);
- ColorIndex = (ColorIndex + 1) % 6;
- Console.Clear();
- Console.ForegroundColor = getCol(ColorIndex);
- Console.SetCursorPosition(xx, yy);
- for (int i = 0; i < str.Length; i++)
- {
- ColorIndex = (ColorIndex + 1) % 6;
- Console.ForegroundColor = getCol(ColorIndex);
- Console.Write(str.Substring(i, 1));
- }
- sinAngle += .1;
- Console.WriteLine();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement