Hack Forums
[C#] Matrix Code [C#] - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [C#] Matrix Code [C#] (/showthread.php?tid=1199879)

Pages: Pages 1 2


Matrix Code [C#] - Obi-Wan Cannabis - Apr 9, 2011

There's probably a thousand of this on the forum but there's always new people around here so I'm going to post this...
This is how it will look like:

[img]http://i.min.us/ikBPwK.png[/img]

Step 1) Start a new console application in C#.
Step 2) Delete every line of code and paste this code (I didn't coded this, just found it on the netz and thought about sharing it):

Code
#define readkey

using System;

namespace m7tr1x
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.Title = "Dos monitor";
            Console.ForegroundColor = ConsoleColor.DarkGreen;
            Console.WindowLeft = Console.WindowTop = 0;
            Console.WindowHeight = Console.BufferHeight = Console.LargestWindowHeight;
            Console.WindowWidth = Console.BufferWidth = Console.LargestWindowWidth;

#if readkey

#endif

            Console.CursorVisible = false;
            int width, height;
            int[] y;
            int[] l;
            Initialize(out width, out height, out y, out l);
            int ms;

            while (true)
            {
                DateTime t1 = DateTime.Now;
                MatrixStep(width, height, y, l);
                ms = 10 - (int)((TimeSpan)(DateTime.Now - t1)).TotalMilliseconds;

                if (ms > 0)
                    System.Threading.Thread.Sleep(ms);

                if (Console.KeyAvailable)
                    if (Console.ReadKey().Key == ConsoleKey.F5)
                        Initialize(out width, out height, out y, out l);
            }
        }

        static bool thistime = false;

        private static void MatrixStep(int width, int height, int[] y, int[] l)
        {
            int x;
            thistime = !thistime;

            for (x = 0; x < width; ++x)
            {
                if (x % 11 == 10)
                {
                    if (!thistime)
                        continue;

                    Console.ForegroundColor = ConsoleColor.White;
                }
                else
                {
                    Console.ForegroundColor = ConsoleColor.DarkGreen;
                    Console.SetCursorPosition(x, inBoxY(y[x] - 2 - (l[x] / 40 * 2), height));
                    Console.Write(R);
                    Console.ForegroundColor = ConsoleColor.Green;
                }
                Console.SetCursorPosition(x, y[x]);
                Console.Write(R);
                y[x] = inBoxY(y[x] + 1, height);
                Console.SetCursorPosition(x, inBoxY(y[x] - l[x], height));
                Console.Write(' ');
            }
        }

        private static void Initialize(out int width, out int height, out int[] y, out int[] l)
        {
            int h1;
            int h2 = (h1 = (height = Console.WindowHeight) / 2) / 2;
            width = Console.WindowWidth - 1;
            y = new int[width];
            l = new int[width];
            int x;
            Console.Clear();
            for (x = 0; x < width; ++x)
            {
                y[x] = r.Next(height);
                l[x] = r.Next(h2 * ((x % 11 != 10) ? 2 : 1), h1 * ((x % 11 != 10) ? 2 : 1));
            }
        }

        static Random r = new Random();

        static char R
        {
            get
            {
                int t = r.Next(10);
                if (t <= 2)
                    return (char)('0' + r.Next(10));
                else if (t <= 4)
                    return (char)('a' + r.Next(27));
                else if (t <= 6)
                    return (char)('A' + r.Next(27));
                else
                    return (char)(r.Next(32, 255));
            }
        }

        public static int inBoxY(int n, int height)
        {
            n = n % height;
            if (n < 0)
                return n + height;
            else
                return n;
        }
    }
}

Step 3) Save it and build it.
Step 4) Go to bin folder, run it and enjoy. 🤝🤝


* - Alison Wonderland - Apr 9, 2011

this looks mean!

im going to test it right now.

will it work in Visual C# 2008?


* - vullux - Apr 9, 2011

Awesome, im trying to learn C# ^^


* - Obi-Wan Cannabis - Apr 9, 2011

(Apr 9, 2011 06:50 PM)Uknown_Hacker Wrote:  this looks mean!

im going to test it right now.

will it work in Visual C# 2008?

Yes. I guess so! 🤝


* - besimbicer - Apr 9, 2011

wow its realy nice thanks you bro +1 rap


* - Obi-Wan Cannabis - Apr 9, 2011

(Apr 9, 2011 06:50 PM)vullux Wrote:  Awesome, im trying to learn C# ^^

Kewl! Enjoy mate... 😎

(Apr 9, 2011 06:55 PM)besimbicer Wrote:  wow its realy nice thanks you bro +1 rap

Thanks for the "rap" bro! 🤣


* - Alison Wonderland - Apr 9, 2011

Works Great. I think it just needs to be faster then it will look awesome

edit

Make less code replace

Code
Console.WindowHeight = Console.BufferHeight = Console.LargestWindowHeight;
    Console.WindowWidth = Console.BufferWidth = Console.LargestWindowWidth;

with

Code
Console.SetWindowSize(Console.LargestWindowWidth, Console.LargestWindowHeight);



* - Hodgy - Apr 9, 2011

I remember making one of these when I was learning c#.


* - DrNorton - Apr 9, 2011

haha cool code, :) i cant wait to learn more.


* - Jinxyy - Apr 10, 2011

Hey, nice code stuff. I'm making a program that makes you look like a pro hacker when you show it to others, and this will add into my collection (ofcourse, credits).

One thing im just asking is how can I make a smaller window of it, instead of full screen? I changed:

Console.WindowHeight = Console.BufferHeight = Console.LargestWindowHeight;
Console.WindowWidth = Console.BufferWidth = Console.LargestWindowWidth;

Into:

Console.WindowHeight = 740;
Console.WindowWidth = 300;

But it doesnt work, gives me an error when I try to debug. Any help? I'd like to resize it to normal CMD size.


* - tw0n - Apr 10, 2011

Aha, never seen that before. It looks jokes.

(Apr 10, 2011 10:35 AM)Nexus Wrote:  Hey, nice code stuff. I'm making a program that makes you look like a pro hacker when you show it to others, and this will add into my collection (ofcourse, credits).

One thing im just asking is how can I make a smaller window of it, instead of full screen? I changed:

Console.WindowHeight = Console.BufferHeight = Console.LargestWindowHeight;
Console.WindowWidth = Console.BufferWidth = Console.LargestWindowWidth;

Into:

Console.WindowHeight = 740;
Console.WindowWidth = 300;

But it doesnt work, gives me an error when I try to debug. Any help? I'd like to resize it to normal CMD size.

Just delete the two following lines and it will be the default size:
Code
Console.WindowHeight = Console.BufferHeight = Console.LargestWindowHeight;
Console.WindowWidth = Console.BufferWidth = Console.LargestWindowWidth;



* - Obi-Wan Cannabis - Apr 10, 2011

(Apr 10, 2011 10:35 AM)Nexus Wrote:  Hey, nice code stuff. I'm making a program that makes you look like a pro hacker when you show it to others, and this will add into my collection (ofcourse, credits).

One thing im just asking is how can I make a smaller window of it, instead of full screen? I changed:

Console.WindowHeight = Console.BufferHeight = Console.LargestWindowHeight;
Console.WindowWidth = Console.BufferWidth = Console.LargestWindowWidth;

Into:

Console.WindowHeight = 740;
Console.WindowWidth = 300;

But it doesnt work, gives me an error when I try to debug. Any help? I'd like to resize it to normal CMD size.

I guess tw0n answered it for me. 🤝

(Apr 10, 2011 10:41 AM)tw0n Wrote:  Just delete the two following lines and it will be the default size:
Code
Console.WindowHeight = Console.BufferHeight = Console.LargestWindowHeight;
Console.WindowWidth = Console.BufferWidth = Console.LargestWindowWidth;



* - ๖ۣۜÑåzgйŀ - Sep 1, 2011

Looks awsome
And since my Dos is blue instead of lame black it makes it even cooler



* - Xori - Sep 1, 2011

By the way if you want to troll a computer store (well, it's customers), go to a computer that's turned on, open up CMD, type in

color a
tree C:\




* - ( ͡° ͜ʖ ͡°) - Sep 1, 2011

Nice program! If i have time I'm gonna convert this to a screensaver soon. 👍