fireworks.lua 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. -- title: fireworks test
  2. -- author: pixelbath
  3. -- desc: description
  4. -- script: lua
  5. t=0
  6. color_fuse = {12,4}
  7. colors = {
  8. {3,2,1},
  9. {7,6,5},
  10. {11,10,9},
  11. {15,14,13},
  12. }
  13. seeds = {}
  14. function add_firework_seed(xpos)
  15. table.insert(seeds, {
  16. vel_y = -1 + (math.random() * -1),
  17. startx = math.random(240),
  18. color = math.random(3)+1,
  19. x = xpos, y = 136,
  20. })
  21. end
  22. function fireworks_update()
  23. local delete_seeds = {}
  24. for i = 1, #seeds do
  25. local this_seed = seeds[i]
  26. this_seed.vel_y = this_seed.vel_y + 0.012
  27. this_seed.y = this_seed.y + this_seed.vel_y
  28. pix(this_seed.x, this_seed.y, this_seed.color)
  29. -- reaching the apex
  30. if this_seed.vel_y > -0.1 then
  31. if math.random() > 10 * math.abs(this_seed.vel_y) then
  32. spawn_explosion(this_seed.x, this_seed.y, this_seed.color)
  33. table.insert(delete_seeds, i)
  34. end
  35. end
  36. end
  37. for i = #delete_seeds, 1, -1 do
  38. table.remove(seeds, delete_seeds[i])
  39. end
  40. end
  41. function spawn_explosion(xpos, ypos, color)
  42. end
  43. add_firework_seed(50)
  44. function TIC()
  45. if btn(0) then y=y-1 end
  46. if btn(1) then y=y+1 end
  47. if btn(2) then x=x-1 end
  48. if btn(3) then x=x+1 end
  49. cls(0)
  50. fireworks_update()
  51. t=t+1
  52. end
  53. -- <WAVES>
  54. -- 000:00000000ffffffff00000000ffffffff
  55. -- 001:0123456789abcdeffedcba9876543210
  56. -- 002:0123456789abcdef0123456789abcdef
  57. -- </WAVES>
  58. -- <SFX>
  59. -- 000:000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000304000000000
  60. -- </SFX>
  61. -- <PALETTE>
  62. -- 000:1a1c2c610018da3038fa484ceec2612cce50108540083c2404366f042c79045dda1085fff4f4f42c0038690071a508b2
  63. -- </PALETTE>