iNNOKENTIY21
Silver Member | Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору
Код: static void Main() { var lines = new List<string>(); int speed = 200; Console.CursorVisible = false; Console.ForegroundColor = ConsoleColor.DarkGreen; while (true) { if (lines.Count >= Console.WindowHeight) { lines.Remove(lines[0]); } lines.Add(GetLine()); Console.SetCursorPosition(0, 0); for (int i = lines.Count - 1; i >= 0; i--) { Console.Write(lines[i]); } Thread.Sleep(TimeSpan.FromMilliseconds(speed)); } } private static readonly Random rnd = new Random(); private static readonly string txt = "iNNOKENTIY21"; static string GetLine() { var line = new StringBuilder(); int left = rnd.Next(Console.WindowWidth - txt.Length); int right = left + txt.Length; if (left > 0) { line.Append(' ', left); } line.Append(txt); if (right < Console.WindowWidth) { line.Append(' ', Console.WindowWidth - right); } return line.ToString(); } |
|