05-09-2023, 01:30 AM
Order out of Chaos
Code: (Select All)
'by mnrvovrfc 8-May-2023 with tiny little mod by b+
Option _Explicit
Dim As Long scren
Dim As Integer px, py, xi, yi, xn, yn, xx, yy, c, l, nivel
Dim As _Unsigned _Byte redo
Randomize Timer
scren = _NewImage(120, 31, 0)
Screen scren
_Delay 0.5
_ScreenMove 0, 0
_Title "Press [ESC] to quit."
nivel = 1
px = Random1(100) + 10
py = Random1(29) + 1
xi = (Random1(2) - 1) * 2 - 1
yi = (Random1(2) - 1) * 2 - 1
xn = nivel
yn = nivel
c = 0
l = Random1(8) + 4
redo = 0
Do
_Limit 100
If redo Then
redo = 0
Else
outchar px, py, 219, 0
End If
px = px + xi * xn
py = py + yi * yn
If px < 1 Or px > 120 Then
px = px - xi * xn
py = py - yi * yn
redo = 1
End If
If py < 1 Or py > 30 Then
px = px - xi * xn
py = py - yi * yn
If nivel > 1 Then nivel = nivel - 1
If Random1(2) = 1 And xn > 1 Then xn = xn - 1
If Random1(2) = 1 And yn > 1 Then yn = yn - 1
redo = 1
End If
If redo = 0 Then
If Screen(py, px) = 219 Then
px = px - xi * xn
py = py - yi * yn
If c < l Then
If Random1(2) = 1 Then
xn = nivel
If xn > 40 Then xn = 40
ElseIf Random1(2) = 1 Then
yn = nivel
If yn > 16 Then yn = 16
Else
nivel = nivel + 1
If nivel > 50 Then
nivel = 1
For yy = 1 To 30
For xx = 1 To 120
outchar xx, yy, 32, 219
Next
Next
End If
End If
End If
End If
c = c + 1
If c > l Then
outchar px, py, 219, 0
If nivel > 1 Then nivel = nivel - 1
If Random1(2) = 1 And xn > 1 Then xn = xn - 1
If Random1(2) = 1 And yn > 1 Then yn = yn - 1
redo = 1
End If
End If
If redo Then
xi = (Random1(2) - 1) * 2 - 1
yi = (Random1(2) - 1) * 2 - 1
c = 0
l = Random1(8) + 4
Else
outchar px, py, 82, 0
_Display
End If
Loop Until _KeyDown(27)
_AutoDisplay
System
Sub outchar (x As Integer, y As Integer, ca As _Unsigned _Byte, cb As _Unsigned _Byte)
Static sch As _Unsigned _Byte
If cb Then
sch = Screen(y, x)
If sch = cb Then sch = ca Else sch = cb
Else
sch = ca
End If
Color (y + x) Mod 16 + 1
Locate y, x: Print Chr$(sch);
End Sub
Function Random1& (maxvaluu&)
Dim sg%
sg% = Sgn(maxvaluu&)
If sg% = 0 Then
Random1& = 0
Else
If sg% = -1 Then maxvaluu& = maxvaluu& * -1
Random1& = Int(Rnd * maxvaluu& + 1) * sg%
End If
End Function
b = b + ...