Advertisement
Guest User

psclil

a guest
Jun 25th, 2007
1,756
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.65 KB | None | 0 0
  1. #define readkey
  2.  
  3. using System;
  4.  
  5. namespace m7tr1x
  6. {
  7.     class Program
  8.     {
  9.         static void Main(string[ ] args)
  10.         {
  11.             Console.Title = "tH3 M7tr1x 3ff3<t";
  12.             Console.ForegroundColor = ConsoleColor.DarkGreen;
  13.             Console.WindowLeft = Console.WindowTop = 0;
  14.             Console.WindowHeight = Console.BufferHeight = Console.LargestWindowHeight;
  15.             Console.WindowWidth = Console.BufferWidth = Console.LargestWindowWidth;
  16. #if readkey
  17.             Console.WriteLine("H1T 7NY K3Y T0 C0NT1NU3 =/");
  18.             Console.ReadKey();
  19. #endif
  20.             Console.CursorVisible = false;
  21.             int width, height;
  22.             int[ ] y;
  23.             int[ ] l;
  24.             Initialize(out width, out height, out y, out l);
  25.             int ms;
  26.             while ( true )
  27.             {
  28.                 DateTime t1 = DateTime.Now;
  29.                 MatrixStep(width, height, y, l);
  30.                 ms = 10 - (int)( (TimeSpan)( DateTime.Now - t1 ) ).TotalMilliseconds;
  31.                 if ( ms > 0 )
  32.                     System.Threading.Thread.Sleep(ms);
  33.                 if ( Console.KeyAvailable )
  34.                     if ( Console.ReadKey().Key == ConsoleKey.F5 )
  35.                         Initialize(out width, out height, out y, out l);
  36.             }
  37.         }
  38.  
  39.         static bool thistime = false;
  40.  
  41.         private static void MatrixStep(int width, int height, int[ ] y, int[ ] l)
  42.         {
  43.             int x;
  44.             thistime = !thistime;
  45.             for ( x = 0 ; x < width ; ++x )
  46.             {
  47.                 if ( x % 11 == 10 )
  48.                 {
  49.                     if ( !thistime )
  50.                         continue;
  51.                     Console.ForegroundColor = ConsoleColor.White;
  52.                 }
  53.                 else
  54.                 {
  55.                     Console.ForegroundColor = ConsoleColor.DarkGreen;
  56.                     Console.SetCursorPosition(x, inBoxY(y[x] - 2 - ( l[x] / 40 * 2 ), height));
  57.                     Console.Write(R);
  58.                     Console.ForegroundColor = ConsoleColor.Green;
  59.                 }
  60.                 Console.SetCursorPosition(x, y[x]);
  61.                 Console.Write(R);
  62.                 y[x] = inBoxY(y[x] + 1, height);
  63.                 Console.SetCursorPosition(x, inBoxY(y[x] - l[x], height));
  64.                 Console.Write(' ');
  65.             }
  66.         }
  67.  
  68.         private static void Initialize(out int width, out int height, out int[ ] y, out int[ ] l)
  69.         {
  70.             int h1;
  71.             int h2 = ( h1 = ( height = Console.WindowHeight ) / 2 ) / 2;
  72.             width = Console.WindowWidth - 1;
  73.             y = new int[width];
  74.             l = new int[width];
  75.             int x;
  76.             Console.Clear();
  77.             for ( x = 0 ; x < width ; ++x )
  78.             {
  79.                 y[x] = r.Next(height);
  80.                 l[x] = r.Next(h2 * ( ( x % 11 != 10 ) ? 2 : 1 ), h1 * ( ( x % 11 != 10 ) ? 2 : 1 ));
  81.             }
  82.         }
  83.  
  84.         static Random r = new Random();
  85.         static char R
  86.         {
  87.             get
  88.             {
  89.                 int t = r.Next(10);
  90.                 if ( t <= 2 )
  91.                     return (char)( '0' + r.Next(10) );
  92.                 else if ( t <= 4 )
  93.                     return (char)( 'a' + r.Next(27) );
  94.                 else if ( t <= 6 )
  95.                     return (char)( 'A' + r.Next(27) );
  96.                 else
  97.                     return (char)( r.Next(32, 255) );
  98.             }
  99.         }
  100.  
  101.         public static int inBoxY(int n, int height)
  102.         {
  103.             n = n % height;
  104.             if ( n < 0 )
  105.                 return n + height;
  106.             else
  107.                 return n;
  108.         }
  109.     }
  110. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement