' GloWorm
' Coded by TrickyKeyboard,
' trickykeyboard@moscowmail.com!

  open window 640, 512

  dim buble_x(7)
  dim buble_y(7)
  dim buble_size(7)

  for what = 0 to 7
    buble_x(what) = ran(640)
    buble_y(what) = ran(512)
    buble_size(what) = 4 + ran(4)
  next

  repeat
    setdrawbuf dw
    dw = 1 - dw
    setdispbuf dw
    clear window

    setrgb 1, 0, 0, 0
    setrgb 2, 0, 0, 255
    setrgb 3, 0, 0, 0
    gtriangle 0, 511 to 0, 0 to 639, 511

    setrgb 1, 0, 0, 255
    setrgb 2, 0, 0, 0
    setrgb 3, 0, 0, 255
    gtriangle 0, 0 to 639, 511 to 639, 0

    for what = 0 to 7
      mm = mm + 0.4

      x = sin(mm) * 32 + what + 319
      y = cos(mm) * 32 + what + 255

      setrgb 1, what * what, what * what, 0
      fill circle x + what * 2, y + what * 2, 32
    next

    for what = 0 to 7
      if (buble_y(what) < -8) then
        buble_x(what) = ran(640)
        buble_y(what) = 520
        buble_size(what) = 4 + ran(4)
      endif

      buble_y(what) = buble_y(what) - 6 - ran(2)

      setrgb 1, 0, 255, 255
      circle buble_x(what), buble_y(what), buble_size(what)
    next

    setrgb 1, 255, 0, 0
    text 320, 480, "Do you like GloWorm? Hit x button to quit..", "cc"

    command = peek("port1")

    if (command = 16384) then
      quit = 1
    endif
  until (quit = 1)

  end



