Matrix effect

This is a cool little application I found deep in my folder structure :D
No idea where I got it from, and no idea who is the author of it.

Uhm… this application is a simulation of The Matrix, like seen in the movie I suppose :D looks really cool. Runs only on Windows.

Download: matrix.exe

Code (Now I don’t know if this is the real code, but it looks like it isn’t…):

Imports System
Module Module1
 
Sub Main(ByVal args As String())
    Console.Title = "tH3 M7tr1x 3ff3<t"
    Console.ForegroundColor = ConsoleColor.DarkGreen
    Console.WindowLeft = InlineAssignHelper(Console.WindowTop, 0)
    Console.WindowHeight = InlineAssignHelper(Console.BufferHeight, Console.LargestWindowHeight)
    Console.WindowWidth = InlineAssignHelper(Console.BufferWidth, Console.LargestWindowWidth)
    #If readkey Then
    Console.WriteLine("H1T 7NY K3Y T0 C0NT1NU3 =/")
    Console.ReadKey()
    #End If
    Console.CursorVisible = False
    Dim width As Integer, height As Integer
    Dim y As Integer()
    Dim l As Integer()
    Initialize(width, height, y, l)
    Dim ms As Integer
    While True
        Dim t1 As DateTime = DateTime.Now
        MatrixStep(width, height, y, l)
        ms = 10 - CInt(DirectCast((DateTime.Now - t1), TimeSpan).TotalMilliseconds)
        If ms > 0 Then
            System.Threading.Thread.Sleep(ms)
        End If
        If Console.KeyAvailable Then
            If Console.ReadKey().Key = ConsoleKey.F5 Then
                Initialize(width, height, y, l)
            End If
        End If
        End While
    End Sub
 
    Dim thistime As Boolean = False
 
    Sub MatrixStep(ByVal width As Integer, ByVal height As Integer, ByVal y As Integer(), ByVal l As Integer())
        Dim x As Integer
        thistime = Not thistime
        For x = 0 To width - 1
            If x Mod 11 = 10 Then
                If Not thistime Then
                    Continue For
                End If
                Console.ForegroundColor = ConsoleColor.White
            Else
                Console.ForegroundColor = ConsoleColor.DarkGreen
                Console.SetCursorPosition(x, inBoxY(CInt(y(x) - 2 - (l(x) / 40 * 2)), height))
                Console.Write®
                Console.ForegroundColor = ConsoleColor.Green
            End If
            Console.SetCursorPosition(x, y(x))
            Console.Write®
            y(x) = inBoxY(y(x) + 1, height)
            Console.SetCursorPosition(x, inBoxY(y(x) - l(x), height))
            Console.Write(" "c)
        Next
    End Sub
 
    Private Sub Initialize(ByRef width As Integer, ByRef height As Integer, ByRef y As Integer(), ByRef l As Integer())
        Dim h1 As Integer
        Dim h2 As Integer = CInt((InlineAssignHelper(h1, CInt((InlineAssignHelper(height, Console.WindowHeight)) / 2))) / 2)
        width = Console.WindowWidth - 1
        y = New Integer(width - 1) {}
        l = New Integer(width - 1) {}
        Dim x As Integer
        Console.Clear()
        For x = 0 To width - 1
            y(x) = m_r.[Next](height)
            l(x) = m_r.[Next](h2 * (If((x Mod 11 <> 10), 2, 1)), h1 * (If((x Mod 11 <> 10), 2, 1)))
        Next
    End Sub
 
    Dim m_r As New Random()
 
    Private ReadOnly Property R() As Char
    Get
    Dim t As Integer = m_r.[Next](10)
    If t <= 2 Then
        Return CChar(("0"c & m_r.[Next](10)))
    ElseIf t <= 4 Then
        Return CChar(("a"c & m_r.[Next](27)))
    ElseIf t <= 6 Then
        Return CChar(("A"c & m_r.[Next](27)))
    Else
        Return CChar(CChar(CStr((m_r.[Next](32, 255)))))
    End If
    End Get
End Property
 
Public Function inBoxY(ByVal n As Integer, ByVal height As Integer) As Integer
    n = n Mod height
    If n < 0 Then
        Return n + height
    Else
        Return n
    End If
End Function
 
Private Function InlineAssignHelper(Of T)(ByRef target As T, ByVal value As T) As T
    target = value
    Return value
End Function
 
End Module
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments