include "window.inc"
Def Space 32

Window "Sirpinsky Christmas tree",256,256,WS_OVERLAPPEDWINDOW
Font 12,24,700,"courier"

int numSteps=10000
float ax = 10, cy = 10
float ay = Height - 10
float bx = Width  - 10
float by = Height - 10
float cx = Width  / 2
float px = ax, py = ay
 
While AscKey=0 and WinExit=0
ClsColor 240,200,200
int n
For n=0 To numSteps
  Poke px, py, 0,0,160
Select Case rand(0,2)
       case 0
          px = (px + ax) / 2.0
          py = (py + ay) / 2.0
       case 1
          px = (px + bx) / 2.0
          py = (py + by) / 2.0
       case 2
          px = (px + cx) / 2.0
          py = (py + cy) / 2.0
End Select          
Next
Events
FlipBuffer
WaitFPS 5
Wend
WinEnd