Advertisement
linesguy

simple particle engine

Aug 14th, 2018
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. 10 hgr : hcolor = 3
  2.  
  3. 21 sx = 140
  4. 22 sy = 96
  5. 23 g = 0.5
  6. 24 n = 30
  7. 35 dim vx(n) : dim vy(n)
  8. 40 dim age(n)
  9. 45 dim exist(n)
  10.  
  11. 199Poke230,32:gosub 200:Poke49236,0:poke 230,64:gosub200:poke49237,0:goto199
  12. 200fr=fr+1:?"frame ";fr;", pn ";pn:call-3086
  13. 205 gosub 1000 : rem add particle
  14. 207 for i = 1 to n : if exist(i) = 1 then gosub 2000 : rem calc and draw
  15. 208 next i
  16. 210
  17.  
  18. 999 return
  19.  
  20. 1000 rem add particle
  21. 1005 done = 0
  22. 1010 for i = 1 to n
  23. 1020 if exist(i) = 0 then exist(i) = 1 : vx(i) = int(rnd(1)*10)-5 : vy(i) = int(rnd(1)*10)-5 : age(i) = 0 : pn = pn + 1 : done = 1
  24. 1100 if done = 0 then next i
  25. 1110 return
  26.  
  27. 2000 rem calc and draw
  28. 2010 age(i) = age(i) + 0.3
  29. 2013 nx = sx+(vx(i)*age(i)) : ny = sy+(vy(i)*age(i))+(g*(age(i)*age(i))/2)
  30. 2015 if nx < 0 or nx>279 or ny<0 or ny>159 then exist(i) = 0 : pn = pn - 1 : return
  31. 2020 hplot nx,ny : return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement