{"id":466,"date":"2011-10-04T19:30:29","date_gmt":"2011-10-04T16:30:29","guid":{"rendered":"http:\/\/newage.ql.lt\/blog\/?p=466"},"modified":"2022-01-19T08:34:44","modified_gmt":"2022-01-19T06:34:44","slug":"matrix-effect","status":"publish","type":"post","link":"http:\/\/9v.lt\/blog\/matrix-effect\/","title":{"rendered":"Matrix effect"},"content":{"rendered":"<p>This is a cool little application I found deep in my folder structure :D<br \/>\nNo idea where I got it from, and no idea who is the author of it.<br \/>\n<!--more--><br \/>\nUhm&#8230; this application is a simulation of The Matrix, like seen in the movie I suppose :D looks really cool. Runs only on Windows.<\/p>\n<p>Download: <a href=\"\/blog\/filemgmt\/uploads\/files\/matrix.exe\">matrix.exe<\/a><\/p>\n<p>Code (Now I don&#8217;t know if this is the real code, but it looks like it isn&#8217;t&#8230;):<\/p>\n<pre lang=\"vb\">\r\nImports System\r\nModule Module1\r\n\r\nSub Main(ByVal args As String())\r\n    Console.Title = \"tH3 M7tr1x 3ff3<t\"\r\n    Console.ForegroundColor = ConsoleColor.DarkGreen\r\n    Console.WindowLeft = InlineAssignHelper(Console.WindowTop, 0)\r\n    Console.WindowHeight = InlineAssignHelper(Console.BufferHeight, Console.LargestWindowHeight)\r\n    Console.WindowWidth = InlineAssignHelper(Console.BufferWidth, Console.LargestWindowWidth)\r\n    #If readkey Then\r\n    Console.WriteLine(\"H1T 7NY K3Y T0 C0NT1NU3 =\/\")\r\n    Console.ReadKey()\r\n    #End If\r\n    Console.CursorVisible = False\r\n    Dim width As Integer, height As Integer\r\n    Dim y As Integer()\r\n    Dim l As Integer()\r\n    Initialize(width, height, y, l)\r\n    Dim ms As Integer\r\n    While True\r\n        Dim t1 As DateTime = DateTime.Now\r\n        MatrixStep(width, height, y, l)\r\n        ms = 10 - CInt(DirectCast((DateTime.Now - t1), TimeSpan).TotalMilliseconds)\r\n        If ms > 0 Then\r\n            System.Threading.Thread.Sleep(ms)\r\n        End If\r\n        If Console.KeyAvailable Then\r\n            If Console.ReadKey().Key = ConsoleKey.F5 Then\r\n                Initialize(width, height, y, l)\r\n            End If\r\n        End If\r\n        End While\r\n    End Sub\r\n    \r\n    Dim thistime As Boolean = False\r\n    \r\n    Sub MatrixStep(ByVal width As Integer, ByVal height As Integer, ByVal y As Integer(), ByVal l As Integer())\r\n        Dim x As Integer\r\n        thistime = Not thistime\r\n        For x = 0 To width - 1\r\n            If x Mod 11 = 10 Then\r\n                If Not thistime Then\r\n                    Continue For\r\n                End If\r\n                Console.ForegroundColor = ConsoleColor.White\r\n            Else\r\n                Console.ForegroundColor = ConsoleColor.DarkGreen\r\n                Console.SetCursorPosition(x, inBoxY(CInt(y(x) - 2 - (l(x) \/ 40 * 2)), height))\r\n                Console.Write\u00ae\r\n                Console.ForegroundColor = ConsoleColor.Green\r\n            End If\r\n            Console.SetCursorPosition(x, y(x))\r\n            Console.Write\u00ae\r\n            y(x) = inBoxY(y(x) + 1, height)\r\n            Console.SetCursorPosition(x, inBoxY(y(x) - l(x), height))\r\n            Console.Write(\" \"c)\r\n        Next\r\n    End Sub\r\n    \r\n    Private Sub Initialize(ByRef width As Integer, ByRef height As Integer, ByRef y As Integer(), ByRef l As Integer())\r\n        Dim h1 As Integer\r\n        Dim h2 As Integer = CInt((InlineAssignHelper(h1, CInt((InlineAssignHelper(height, Console.WindowHeight)) \/ 2))) \/ 2)\r\n        width = Console.WindowWidth - 1\r\n        y = New Integer(width - 1) {}\r\n        l = New Integer(width - 1) {}\r\n        Dim x As Integer\r\n        Console.Clear()\r\n        For x = 0 To width - 1\r\n            y(x) = m_r.[Next](height)\r\n            l(x) = m_r.[Next](h2 * (If((x Mod 11 <> 10), 2, 1)), h1 * (If((x Mod 11 <> 10), 2, 1)))\r\n        Next\r\n    End Sub\r\n    \r\n    Dim m_r As New Random()\r\n    \r\n    Private ReadOnly Property R() As Char\r\n    Get\r\n    Dim t As Integer = m_r.[Next](10)\r\n    If t <= 2 Then\r\n        Return CChar((\"0\"c &#038; m_r.[Next](10)))\r\n    ElseIf t <= 4 Then\r\n        Return CChar((\"a\"c &#038; m_r.[Next](27)))\r\n    ElseIf t <= 6 Then\r\n        Return CChar((\"A\"c &#038; m_r.[Next](27)))\r\n    Else\r\n        Return CChar(CChar(CStr((m_r.[Next](32, 255)))))\r\n    End If\r\n    End Get\r\nEnd Property\r\n\r\nPublic Function inBoxY(ByVal n As Integer, ByVal height As Integer) As Integer\r\n    n = n Mod height\r\n    If n < 0 Then\r\n        Return n + height\r\n    Else\r\n        Return n\r\n    End If\r\nEnd Function\r\n\r\nPrivate Function InlineAssignHelper(Of T)(ByRef target As T, ByVal value As T) As T\r\n    target = value\r\n    Return value\r\nEnd Function\r\n\r\nEnd Module\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>This is a cool little application I found deep in my folder structure :D No<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[416,480,479,415],"class_list":["post-466","post","type-post","status-publish","format-standard","hentry","category-general","tag-basic","tag-effect","tag-matrix","tag-visual"],"_links":{"self":[{"href":"http:\/\/9v.lt\/blog\/wp-json\/wp\/v2\/posts\/466","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/9v.lt\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/9v.lt\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/9v.lt\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/9v.lt\/blog\/wp-json\/wp\/v2\/comments?post=466"}],"version-history":[{"count":0,"href":"http:\/\/9v.lt\/blog\/wp-json\/wp\/v2\/posts\/466\/revisions"}],"wp:attachment":[{"href":"http:\/\/9v.lt\/blog\/wp-json\/wp\/v2\/media?parent=466"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/9v.lt\/blog\/wp-json\/wp\/v2\/categories?post=466"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/9v.lt\/blog\/wp-json\/wp\/v2\/tags?post=466"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}