Advertisement
Guest User

Untitled

a guest
May 22nd, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
QBasic 2.96 KB | None | 0 0
  1. Rem Project: test
  2. Rem Created: 5/2/2010 5:08:38 AM
  3. SET GLOBAL OBJECT CREATION 1
  4.  
  5. Rem ***** Main Source File *****
  6. global DIM seedx#(32768)  ` Seed X
  7. global DIM seedy#(32768)  ` Seed Y
  8. global DIM seedz#(32768)  ` Seed Z
  9. global DIM seeda#(32768)  ` Seed Angle
  10. global DIM seedd#(32768)  ` Seed Depth
  11. global DIM seedb#(32768)  ` Seed Breed
  12. global DIM seedl#(32768)  ` Seed Life
  13. global seednum AS INTEGER = 1
  14.  
  15. global grow_distance# = 0.75
  16. global cx AS INTEGER = 0
  17. global obj AS INTEGER = 1
  18. global count AS INTEGER = 24
  19. global ticks AS INTEGER = 0
  20.  
  21. seedx#(0) = 0     ` Initial Seed X
  22. seedy#(0) = -50   ` Initial Seed Y
  23. seedz#(0) = 0     ` Initial Seed Z
  24. seeda#(0) = 90    ` Initial Seed Angle
  25. seedd#(0) = 0     ` Initial Seed Depth
  26. seedb#(0) = 8     ` Initial Seed Breed
  27. seedl#(0) = 80    ` Initial Seed Life
  28.  
  29. make camera 1
  30. position camera 0,0,-100
  31. backdrop ON
  32. color backdrop 1,rgb(0,0,0)
  33. make light 1
  34. position light 1,-40,0,0
  35. color light 1,rgb(128,0,255)
  36.  
  37. DO
  38.  
  39. ` process each seed
  40. loopseednum = seednum-1
  41. FOR n = 0 TO loopseednum
  42.    seedl#(n) = seedl#(n) - 1
  43.    IF seedl#(n) > 0
  44.       ` Grow up
  45.       seedx#(n) = seedx#(n) + COS(seeda#(n)) * grow_distance#
  46.       seedy#(n) = seedy#(n) + SIN(seeda#(n)) * grow_distance#
  47.       seedz#(n) = seedz#(n) + seedd#(n) * grow_distance#
  48.       grow_at(seedx#(n), seedy#(n), seedz#(n), seedl#(n))
  49.  
  50.       ` Breed new child
  51.       IF seedb#(n) <= 0
  52.          ` Angle AND depth TO spread
  53.          angle# = 15 + RND(15)
  54.          IF RND(1) = 1 THEN angle# = -angle#
  55.          depth# = ( -10 + RND(20) ) / 10.0
  56.  
  57.          seedx#(seednum) = seedx#(n)
  58.          seedy#(seednum) = seedy#(n)
  59.          seedz#(seednum) = seedz#(n)
  60.          seeda#(seednum) = seeda#(n) - angle#
  61.          seeda#(n) = seeda#(n) + angle#
  62.          seedd#(seednum) = depth#
  63.          seedd#(n) = depth#
  64.          seedb#(seednum) = 8 + RND(8)
  65.          seedl#(seednum) = seedl#(n) + RND(10)
  66.  
  67.          ` We have a new seed!
  68.          seednum = seednum + 1
  69.  
  70.          ` RESET breed
  71.          seedb#(n) = 8 + RND(8)
  72.       ELSE
  73.          seedb#(n) = seedb#(n) - 1
  74.       endif
  75.    endif
  76. NEXT
  77.  
  78. tc=tc+5:IF tc>360 THEN tc=0
  79. FOR n = 1 TO obj-1
  80.    ` Rotate animation
  81.  `  rotate object n, SIN(ticks)*360,SIN(0-ticks)*360,COS(ticks)*360
  82.  color object n,rgb(SIN(n+tc)*255,SIN(n+(tc+90))*255,COS(tc-n)*255)
  83. NEXT n
  84.  
  85. SLEEP 60
  86.  
  87. rem set cursor 0, 0
  88. rem PRINT "Childs: ", seednum
  89. rem PRINT "Objects: ", obj
  90. sync
  91. `set camera fov 1,120
  92. position camera 1,SIN(ticks)*5,-40,-50
  93. POINT camera 1,0,-40,0
  94.  
  95. ticks = ticks + 1
  96.  
  97. LOOP
  98.  
  99. FUNCTION grow_at( x#, y#, z#, life# )
  100.    siz# = 2.0 - obj / 1800.0
  101.  
  102.    IF siz# > 0.9
  103.       make object sphere obj, siz#
  104.       SET OBJECT WIREFRAME obj,0
  105.        position object obj, x#+(-0.25+RND(50)/100.0), y#+(-0.25+RND(50)/100.0), 80 + z#+(-0.25+RND(50)/100.0)
  106.       rem position object obj, x#, y#, 80 + z#
  107.       rem IF obj > 1500 THEN delete object obj-1498
  108.       cx=cx+1:IF cx=360 THEN  cx=0
  109.       obj = obj + 1
  110.    endif
  111. endfunction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement