Code: Select all
Dim sort.l(1000)
For i = 1 To 1000
sort(i) = Random(1000)
Next
writes.l
times.l = 0
If OpenWindow(0,0,0,1000,1000,"Sort",#PB_Window_ScreenCentered)
hWnd = WindowID(0)
hDC = GetDC_(hWnd)
hBrush = CreateSolidBrush_(RGB(0,0,0))
Debug hBrush
Repeat
Delay(10)
writes = 0
times+1
StartDrawing(WindowOutput(0))
Box(0,0,1000,1000,RGB(255,255,255))
StopDrawing()
For i = 2 To 1000
If sort(i) < sort(i-1)
a = sort(i)
sort(i) = sort(i-1)
sort(i-1) = a
writes+1
EndIf
Next
For i = 2 To 1000
StartDrawing(WindowOutput(0))
BackColor(RGB(255,255,255))
Box(i-1,0,1,sort(i-1),RGB(0,0,0))
StopDrawing()
Next
Until Not writes
EndIf