home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d9xx / d969 / ace.lha / ACE / ACE-2.0.lha / PRGS.lha / Turtle / tree.b < prev   
Text File  |  1994-01-10  |  795b  |  60 lines

  1. '...recursive binary tree using turtle graphics
  2.  
  3. #include <inputs.h>
  4.  
  5. sub tree(n)
  6.   if n<5 then exit sub 
  7.    turnright 30
  8.    forward n
  9.    tree(n*.75)
  10.    back n
  11.    turnleft 60
  12.    forward n
  13.    tree(n*.75)
  14.    back n
  15.    turnright 30
  16. end sub
  17.  
  18. sub usage
  19.   print "usage: tree <depth>"
  20. end sub
  21.  
  22. if argcount<>1 then 
  23.   ask.depth=-1
  24. else
  25.   ask.depth=0
  26.   x$=arg$(1)
  27.   if x$="?" then
  28.     usage
  29.     input "enter depth: ",depth
  30.   else
  31.     depth=val(x$)    '..get depth
  32.   end if
  33. end if
  34.  
  35. screen 1,640,225,2,2
  36. color 1,0
  37.  
  38.  cls
  39.  locate 1,1
  40.  if ask.depth then 
  41.     prints "enter depth: "
  42.     depth=inputs%
  43.     cls
  44.     locate 1,1
  45.  end if
  46.  prints "depth of tree is"
  47.  prints depth 
  48.  
  49.  penup
  50.  setxy 320,150
  51.  pendown
  52.  
  53.  tree(depth)
  54.  
  55.  locate 24,1
  56.  prints "press 'q' to quit..."
  57.  while ucase$(inkey$)<>"Q":wend
  58.  
  59. screen close 1
  60.