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;
- namespace MatrixRevolution
- {
- class Program
- {
- private static readonly int MatrixWidth = Console.LargestWindowWidth;
- private static readonly int MatrixHeight = Console.LargestWindowHeight;
- private static char[,] matrix;
- private static Random rand = new Random();
- private static void InitializeMatrix(out char[,] matrix, int width, int height)
- {
- matrix = new char[width, height];
- for (int x = 0; x < matrix.GetLength(0); x++)
- {
- int y = 0;
- int odd = x % 2 == 0 ? 0 : 1;
- while (y < matrix.GetLength(1))
- {
- int tmpHeight = rand.Next(1, height);
- if (y + tmpHeight > height)
- break;
- for (int i = 0; i < tmpHeight; i++)
- {
- matrix[x,y+i] = odd % 2 == 0 ? (char)rand.Next(32,125) : ' ';
- }
- odd++;
- y += tmpHeight;
- }
- }
- }
- private static void PrintMatrix(char [,] matrix)
- {
- for (int x = 0; x < matrix.GetLength(0); x++)
- {
- for (int y = 0; y < matrix.GetLength(1); y++)
- {
- Console.SetCursorPosition(x, y);
- Console.Write(matrix[x, y]);
- }
- }
- }
- private static void MoveRows(char [,] matrix)
- {
- for (int x = 0; x < matrix.GetLength(0); x++)
- {
- char last = matrix[x, matrix.GetLength(1) - 1];
- for (int y = matrix.GetLength(1) - 1; y > 0; y--)
- {
- matrix[x, y] = matrix[x, y-1];
- }
- matrix[x, 0] = last;
- }
- }
- static void Main(string[] args)
- {
- Console.WindowHeight = Console.BufferHeight = MatrixHeight;
- Console.WindowWidth = Console.BufferWidth = MatrixWidth;
- Console.ForegroundColor = ConsoleColor.DarkGreen;
- Console.WindowLeft = Console.WindowTop = 0;
- //InitializeMatrix(out matrix, MatrixWidth, MatrixHeight);
- //PrintMatrix(matrix);
- //for (int i = 0; i < 50; i++)
- //{
- // MoveRows(matrix);
- // PrintMatrix(matrix);
- //}
- int[] y = new int[MatrixWidth];
- int[] length = new int[MatrixWidth];
- for (int x = 0; x < MatrixWidth; x++)
- {
- y[x] = rand.Next(1, MatrixHeight);
- length[x] = rand.Next(1, MatrixHeight - y[x]);
- }
- for (int x= 0; x < MatrixWidth; x++)
- {
- for (int i = 0; i < length[x]; i++)
- {
- Console.CursorVisible = false;
- Console.SetCursorPosition(x, y[x] + i);
- Console.Write((char)rand.Next(32, 125));
- }
- }
- //int newY = y[5] + length[5];
- for (int i = 0; i < 6000; i++)
- {
- for (int x = 0; x < MatrixWidth-1; x++)
- {
- y[x] = y[x] < MatrixHeight ? y[x] : 0;
- Console.SetCursorPosition(x, y[x]++);
- Console.Write(' ');
- int newY = y[x] + length[x] < MatrixHeight ? y[x] + length[x] : (y[x] + length[x]) - MatrixHeight;
- Console.SetCursorPosition(x, newY++);
- Console.Write((char)rand.Next(32, 125));
- x = i % 2 == 0 ? x : x + 1;
- x = i % 3 == 0 ? x : x + 2;
- }
- System.Threading.Thread.Sleep(40);
- }
- Console.ReadLine();
- }
- }
- }
Add Comment
Please, Sign In to add comment