Advertisement
Kulverstukas

Matrix effect

Oct 4th, 2011
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Imports System
  2.  Module Module1
  3.  
  4.  Sub Main(ByVal args As String())
  5.  Console.Title = "tH3 M7tr1x 3ff3<t"
  6.  Console.ForegroundColor = ConsoleColor.DarkGreen
  7.  Console.WindowLeft = InlineAssignHelper(Console.WindowTop, 0)
  8.  Console.WindowHeight = InlineAssignHelper(Console.BufferHeight, Console.LargestWindowHeight)
  9.  Console.WindowWidth = InlineAssignHelper(Console.BufferWidth, Console.LargestWindowWidth)
  10.  #If readkey Then
  11.  Console.WriteLine("H1T 7NY K3Y T0 C0NT1NU3 =/")
  12.  Console.ReadKey()
  13.  #End If
  14.  Console.CursorVisible = False
  15.  Dim width As Integer, height As Integer
  16.  Dim y As Integer()
  17.  Dim l As Integer()
  18.  Initialize(width, height, y, l)
  19.  Dim ms As Integer
  20.  While True
  21.  Dim t1 As DateTime = DateTime.Now
  22.  MatrixStep(width, height, y, l)
  23.  ms = 10 - CInt(DirectCast((DateTime.Now - t1), TimeSpan).TotalMilliseconds)
  24.  If ms > 0 Then
  25.  System.Threading.Thread.Sleep(ms)
  26.  End If
  27.  If Console.KeyAvailable Then
  28.  If Console.ReadKey().Key = ConsoleKey.F5 Then
  29.  Initialize(width, height, y, l)
  30.  End If
  31.  End If
  32.  End While
  33.  End Sub
  34.  
  35.  Dim thistime As Boolean = False
  36.  
  37.  Sub MatrixStep(ByVal width As Integer, ByVal height As Integer, ByVal y As Integer(), ByVal l As Integer())
  38.  Dim x As Integer
  39.  thistime = Not thistime
  40.  For x = 0 To width - 1
  41.  If x Mod 11 = 10 Then
  42.  If Not thistime Then
  43.  Continue For
  44.  End If
  45.  Console.ForegroundColor = ConsoleColor.White
  46.  Else
  47.  Console.ForegroundColor = ConsoleColor.DarkGreen
  48.  Console.SetCursorPosition(x, inBoxY(CInt(y(x) - 2 - (l(x) / 40 * 2)), height))
  49.  Console.Write®
  50.  Console.ForegroundColor = ConsoleColor.Green
  51.  End If
  52.  Console.SetCursorPosition(x, y(x))
  53.  Console.Write®
  54.  y(x) = inBoxY(y(x) + 1, height)
  55.  Console.SetCursorPosition(x, inBoxY(y(x) - l(x), height))
  56.  Console.Write(" "c)
  57.  Next
  58.  End Sub
  59.  
  60.  Private Sub Initialize(ByRef width As Integer, ByRef height As Integer, ByRef y As Integer(), ByRef l As Integer())
  61.  Dim h1 As Integer
  62.  Dim h2 As Integer = CInt((InlineAssignHelper(h1, CInt((InlineAssignHelper(height, Console.WindowHeight)) / 2))) / 2)
  63.  width = Console.WindowWidth - 1
  64.  y = New Integer(width - 1) {}
  65.  l = New Integer(width - 1) {}
  66.  Dim x As Integer
  67.  Console.Clear()
  68.  For x = 0 To width - 1
  69.  y(x) = m_r.[Next](height)
  70.  l(x) = m_r.[Next](h2 * (If((x Mod 11 <> 10), 2, 1)), h1 * (If((x Mod 11 <> 10), 2, 1)))
  71.  Next
  72.  End Sub
  73.  
  74.  Dim m_r As New Random()
  75.  
  76.  Private ReadOnly Property R() As Char
  77.  Get
  78.  Dim t As Integer = m_r.[Next](10)
  79.  If t <= 2 Then
  80.  Return CChar(("0"c & m_r.[Next](10)))
  81.  ElseIf t <= 4 Then
  82.  Return CChar(("a"c & m_r.[Next](27)))
  83.  ElseIf t <= 6 Then
  84.  Return CChar(("A"c & m_r.[Next](27)))
  85.  Else
  86.  Return CChar(CChar(CStr((m_r.[Next](32, 255)))))
  87.  End If
  88.  End Get
  89.  End Property
  90.  
  91.  Public Function inBoxY(ByVal n As Integer, ByVal height As Integer) As Integer
  92.  n = n Mod height
  93.  If n < 0 Then
  94.  Return n + height
  95.  Else
  96.  Return n
  97.  End If
  98.  End Function
  99.  
  100.  Private Function InlineAssignHelper(Of T)(ByRef target As T, ByVal value As T) As T
  101.  target = value
  102.  Return value
  103.  End Function
  104.  
  105.  End Module
  106.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement