1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
| static void Main()
{
Console.ForegroundColor = ConsoleColor.DarkGreen;
Console.WindowLeft = Console.WindowTop = 0;
Console.WindowHeight = Console.BufferHeight = Console.LargestWindowHeight;
Console.WindowWidth = Console.BufferWidth = Console.LargestWindowWidth;
Console.WriteLine("Hit Any Key To Continue");
Console.ReadKey();
Console.CursorVisible = false;
int width, height;
// setup array of starting y values
int[] y;
// width was 209, height was 81
// setup the screen and initial conditions of y
Initialize(out width, out height, out y);
// do the Matrix effect
// every loop all y's get incremented by 1
int[] timer = new int[width];
int maxspeed = 10;
for (int i = 0; i < width; i++)
{
timer[i] = rand.Next(1,maxspeed);
}
int count = 1;
while (true)
{
for (int i = 0; i < width; i++)
{
if(count % timer[i] == 0)
{
UpdateOneColumn(i, height, y);
}
}
count++;
if (count > maxspeed)
{
count = 1;
}
//UpdateAllColumns(width, height, y);
Thread.Sleep(5);
}
}
private static void UpdateOneColumn(int width, int height, int[] y)
{
int x = width;
Console.ForegroundColor = ConsoleColor.Green;
Console.SetCursorPosition(x, y[x]);
Console.Write(AsciiCharacter);
// the dark green character - 2 positions above the bright green character
Console.ForegroundColor = ConsoleColor.DarkGreen;
int temp = y[x] - 2;
Console.SetCursorPosition(x, inScreenYPosition(temp, height));
Console.Write(AsciiCharacter);
// the 'space' - 20 positions above the bright green character
int temp1 = y[x] - 20;
Console.SetCursorPosition(x, inScreenYPosition(temp1, height));
Console.Write(' ');
// increment y
y[x] = inScreenYPosition(y[x] + 1, height);
} |
Partager