Advertisement
Guest User

Untitled

a guest
May 22nd, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
QBasic 1.46 KB | None | 0 0
  1. global DIM seedx#(1337)  ` Seed X
  2. global DIM seedy#(1337)  ` Seed Y
  3. global DIM seeda#(1337)  ` Seed Angle
  4. global seednum AS INTEGER = 1
  5.  
  6. global grow_distance# = 0.75;
  7. global obj AS INTEGER = 1
  8. global cx AS INTEGER = 0
  9. global cy AS INTEGER = -50
  10. global count AS INTEGER = 24
  11.  
  12. seedx#(0) = cx
  13. seedy#(0) = cy
  14. seeda#(0) = 90
  15. make camera 1
  16. position camera 0,0,-100
  17. backdrop ON
  18. color backdrop 1,rgb(0,0,0)
  19. make light 1
  20. position light 1,-40,0,0
  21. color light 1,rgb(128,0,255)
  22. DO
  23.  
  24. ` process each seed
  25. FOR n = 0 TO seednum-1
  26.    seedx#(n) = seedx#(n) + COS(seeda#(n)) * grow_distance#
  27.    seedy#(n) = seedy#(n) + SIN(seeda#(n)) * grow_distance#
  28.    time# = TIMER()
  29.    grow_at(seedx#(n), seedy#(n), 2.0 - (obj / 1000.0))
  30. NEXT
  31.  
  32. ` Decrement the child counter
  33. IF count <= 0
  34.    ` Angle TO spread
  35.    angle# = 15+RND(15)
  36.    `angle# = 30
  37.  
  38.    ` Create childs
  39.    FOR n = 0 TO seednum-1
  40.       seedx#(n + seednum) = seedx#(n)
  41.       seedy#(n + seednum) = seedy#(n)
  42.       seeda#(n + seednum) = seeda#(n) - angle#
  43.       seeda#(n) = seeda#(n) + angle#
  44.    NEXT n
  45.    seednum = seednum * 2
  46.  
  47.    ` RESET counter
  48.    count = 8+RND(8)
  49. ELSE
  50.    count = count - 2
  51. endif
  52.  
  53. SLEEP 60
  54.  
  55. set cursor 0, 0
  56. PRINT "Childs: ", seednum
  57. PRINT "Objects: ", obj
  58. sync
  59.  
  60. LOOP
  61.  
  62. FUNCTION grow_at( x#, y#, siz# )
  63.    make object cube obj, siz#
  64.    position object obj, x#, y#, 80
  65.    IF obj > 255 THEN delete object obj-254
  66.    color object obj,rgb(RND(255),0,0)
  67.    obj = obj + 1
  68. endfunction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement