Guest User

Untitled

a guest
Jan 24th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.09 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace MatrixRevolution
  7. {
  8.     class Program
  9.     {
  10.         private static readonly int MatrixWidth = Console.LargestWindowWidth;
  11.         private static readonly int MatrixHeight = Console.LargestWindowHeight;
  12.  
  13.         private static char[,] matrix;
  14.         private static Random rand = new Random();
  15.  
  16.         static void Main(string[] args)
  17.         {
  18.             Console.WindowHeight = Console.BufferHeight = MatrixHeight;
  19.             Console.WindowWidth = Console.BufferWidth = MatrixWidth;
  20.             Console.ForegroundColor = ConsoleColor.DarkGreen;
  21.             Console.WindowLeft = Console.WindowTop = 0;
  22.  
  23.             int[] y = new int[MatrixWidth];
  24.             int[] length = new int[MatrixWidth];
  25.  
  26.             for (int x = 0; x < MatrixWidth; x++)
  27.             {
  28.                 y[x] = rand.Next(1, MatrixHeight);
  29.                 length[x] = rand.Next(1, MatrixHeight - y[x]);
  30.             }
  31.  
  32.             for (int x= 0; x < MatrixWidth; x++)
  33.                 for (int i = 0; i < length[x]; i++)
  34.                 {
  35.                     Console.CursorVisible = false;
  36.                     Console.SetCursorPosition(x, y[x] + i);
  37.                     Console.Write((char)rand.Next(32, 125));
  38.                 }
  39.  
  40.             int l = 0;
  41.             while(true)
  42.             {
  43.                 for (int x = 0; x < MatrixWidth-1; x++)
  44.                 {
  45.                     y[x] = y[x] < MatrixHeight ? y[x] : 0;
  46.                     Console.SetCursorPosition(x, y[x]++);
  47.                     Console.Write(' ');
  48.  
  49.                     int newY = y[x] + length[x] < MatrixHeight ? y[x] + length[x] : (y[x] + length[x]) - MatrixHeight;
  50.                     Console.SetCursorPosition(x, newY++);
  51.                     Console.Write((char)rand.Next(32, 125));
  52.                    
  53.                     x = l % 2 == 0 ? x : x + 1;
  54.                     x = l++ % 3 == 0 ? x : x + 2;
  55.                 }
  56.                 System.Threading.Thread.Sleep(40);
  57.             }
  58.             Console.ReadLine();
  59.         }
  60.     }
  61. }
Add Comment
Please, Sign In to add comment