Advertisement
Guest User

Untitled

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