' Triangle Tricks
' Coded by TrickyKeyboard,
' trickykeyboard@moscowmail.com!
' This is for the competion too!

' Some basic stuff..

  open window 640, 512

  message$ = "                                Hi, and welcome to my (TrickyKeyboard's) other entry for that competion.. I hope you like this demo. I'm very amazed about the power of YaBasic. In this demo it draws 128 triangles very quickly and ofcourse some other graphics and does some math stuff. Well, then some greetings to ShockWave, Doctor, Xalthorn, Jimshaw, Rafryer, Parabellum, Jinx and all other m8s! Thank you! Hit x button to quit, you can also remove this scrolling text and that logo by hitting square button and make them come back by hitting circle button..                                "
  length = len(message$)

  stuff = 1

' Double buffer things..

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

' Background..

    for y = 0 to 3
      for x = 0 to 4
        setrgb 1, 0, 0, x * 3 * y * 3
        fill rectangle x * 128 + 64, y * 128 to x * 128 + 128, y * 128 + 64
        fill rectangle x * 128, y * 128 + 64 to x * 128 + 64, y * 128 + 128
      next
    next

' The main thing..

    for what = 0 to 127
      mm1 = mm1 + 0.05

      x = sin(mm1) * what + 192
      y = cos(mm1) * what + 128

      setrgb 1, what * 2, 0, 0
      setrgb 2, 0, what * 2, 0
      setrgb 3, 0, 0, what * 2
      gtriangle x + 256, y + 256 to x, y + 256 to x + 128, y
    next

' The scrolling text and the logo..

    if (stuff = 1) then
      mm2 = mm2 + 0.25

      x = sin(mm2) * 128 + 192
      y = cos(mm2) * 32 + 128

      setrgb 1, 255, 127, 63
      setrgb 2, 0, 0, 0
      setrgb 3, 0, 0, 0
      gtriangle x, y to x + 128, y + 8 to x + 128, y + 32
      gtriangle x + 64, y to x + 72, y + 256 to x + 56, y + 244
      gtriangle x + 132, y + 8 to x + 128, y + 256 to x + 160, y + 224
      gtriangle x + 132, y + 120 to x + 248, y + 48 to x + 256, y + 8
      gtriangle x + 132, y + 128 to x + 252, y + 184 to x + 256, y + 160
      setrgb 1, 255, 127, 127
      text x + 68, y + 92, "ricky"
      text x + 148, y + 128, "eyboard"

      text_x = text_x + 0.25

      if (text_x > length - 32) then
        text_x = 0
      endif

      text_to_show$ = mid$(message$, text_x, 32)

      setrgb 1, 255, 255, 255
      text 320, 32, text_to_show$, "cc"
    endif

' Controller reading..

    command = peek("port1")

    if (command = 8192) then
      stuff = 1
    elseif (command = 16384) then
      quit = 1
    elseif (command = 32768) then
      stuff = 0
    endif
  until (quit = 1)

' The end.. :)

  end



