home *** CD-ROM | disk | FTP | other *** search
/ Boston 2 / boston-2.iso / DOS / PROGRAM / BASIC / POWBASIC / LIBRARY1 / EXAMP1.ZIP / UMEX238.BAS < prev    next >
BASIC Source File  |  1990-03-29  |  2KB  |  62 lines

  1. 'User's Manual Example, Page 238.
  2.  
  3. 'T4.BAS--T4 bacteripphage animation demonstration
  4. DEFINT a-z                'all variables are integers by default
  5. DIM T42!(244),T4!(424)    'dimension two arrays
  6. SCREEN 1, 0               'select screen modes
  7. COLOR 0, 0                'select colors
  8. 'T4 is a bacteriophage-- a tiny organism that attacks bacteria.
  9. 'It reporduces by attaching to a bacterium, injecting its DNA,
  10. 'and taking over the reproductive system of the bacterium.
  11. 'This animation demonstrates the sequence graphically.
  12. 'Draw a bacterium: a big ellipse at the bottom of the screen.
  13. CIRCLE (160,180),160,1,,,4/30
  14. PAINT (160,170),1,1       'fill it in
  15. CALL drawT4               'bacteriophage definition
  16. FOR I = 1 TO 40           'each pass, the image is lowered a little
  17.   PUT (24 + I * 4, 22 + I * 2), T4!, XOR  'draw position 1
  18.   DELAY 0.2                               'admire it
  19.   PUT (24 + I * 4, 22 + I * 2), T4!, XOR  'XOR to erase it
  20.   PUT (12 + I * 4, 37 + I * 2), T4!, XOR  'replace it with position 2
  21.   DELAY 0.2                               'admire some more
  22.   PUT (12 + I * 4, 37 + I * 2), T4!, XOR  'this too shall pass
  23. NEXT I
  24.  
  25. ' At end of loop, nothing is on the screen, so we need to show
  26. ' the first image one more time.
  27. PUT (24 + I * 4, 22 + I * 2), T4!, XOR
  28. I = I + 1
  29. DELAY 1
  30. PAINT (I * 4 + 34, I * 2 + 40), 0, 3
  31. DELAY 0.4
  32. CIRCLE (160,180), 160,3,,,4/30
  33. PAINT (160,170),2,3       'Infection takes over
  34. DELAY 1
  35. END
  36.  
  37. SUB drawT4
  38.   shared T4!(), T42!()
  39.   '----- first position of T4
  40.   DRAW "bm 20,50 c3"
  41.   DRAW "m-5,-9 m+0,-9 m+7,-8 m+7,0 m+7,+8 m+0,+9 m-5,+9 m-11,+0"
  42.   PAINT (24,40),2,3
  43.   LINE (18,50)-(33,52),3,BF
  44.   LINE (23,53)-(28,59),3,BF
  45.   LINE (20,59)-(31,63),3,BF
  46.   DRAW "bm 22,63 m-6,+12 bm 24,63 m-4,+12 bm 25,65 m+6,+12"
  47.   DRAW "bm 26,63 m+4,+12 bm 29,63 m+6,+12"
  48.   GET (14,20)-(42,80),T4!
  49.   PUT (14,20),T4!,XOR
  50.   '----- second position
  51.   DRAW "bm 20,54 c3"
  52.   DRAW "m-10,-7 m+0,-7 m+10,-4 m+12,0 m+10,+4 m+0,+7 m-10,+7 m-12,+0"
  53.   PAINT (24,45),2,3
  54.   LINE (18,54)-(33,56),3,BF
  55.   LINE (23,57)-(28,59),3,BF
  56.   LINE (20,59)-(31,63),3,BF
  57.   DRAW "bm 22,63 m-19,+5 bm 24,63 m-14,+7"
  58.   DRAW "bm 26,63 m+14,+7 bm 28,63 m+19,+5"
  59.   GET (2,35)-(50,75),T42!
  60.   PUT (2,35),T42!,XOR
  61. END SUB
  62.