Advertisement
Guest User

Untitled

a guest
Nov 19th, 2019
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. --Ported from javascript
  2.  
  3. local particles = {}
  4.  
  5. local numberOfSprites = 5
  6. local spawnCooldown = 0
  7.  
  8. local gfx = {}
  9. for i=1, numberOfSprites do
  10. gfx[i] = Graphics.loadImage(i .. ".png")
  11. end
  12.  
  13. local function sin(d)
  14. return math.sin(d*0.017453292519943)
  15. end
  16.  
  17. function onDraw()
  18. --Red overlay:
  19. Graphics.glDraw{vertexCoords={0, 0, 0, 600, 800, 0, 800, 600}, color={1, 0, 0, 0.133}, primitive=Graphics.GL_TRIANGLE_STRIP, priority = 1}
  20.  
  21. if spawnCooldown <= 0 then
  22. spawnCooldown = math.random(3)
  23.  
  24. spawnParticle(math.random()*832 - 16, 600) --Up to 16px off either end of screen
  25. end
  26.  
  27. Text.print(mem(0x00B250E2, FIELD_WORD),0,0) --Line to check if paused
  28. if true then
  29. for i,part in ipairs(particles) do
  30. if part ~= -1 then
  31. part.x = part.baseX + sin(part.timer*5)*40 --Wavy effect
  32. part.y = (part.y + 100) * (1 + 1/part.yV) - 100 --Converging effect
  33. part.timer = part.timer + 0.65
  34.  
  35. if part.y < -32 then
  36. particles[i] = -1
  37. end
  38.  
  39. Graphics.glDraw{vertexCoords={part.x, part.y, part.x + 6, part.y, part.x + 6, part.y + 6, part.x, part.y + 6}, texture=gfx[part.sprite], textureCoords={0, 0, 1, 0, 1, 1, 0, 1}, color={1,1,1,0.8}, primitive=Graphics.GL_TRIANGLE_FAN, priority = -98}
  40. --Graphics.drawImage(gfx[part.sprite], part.x, part.y)
  41. end
  42. end
  43. end
  44.  
  45. spawnCooldown = spawnCooldown - 1
  46. end
  47.  
  48. function spawnParticle(x, y)
  49. local obj = {x=x, y=y}
  50. obj.sprite = math.random(numberOfSprites)
  51.  
  52. obj.xV = 0
  53. obj.yV = math.random(-110, -70)
  54. obj.baseX = x
  55. obj.timer = 0
  56.  
  57. table.insert(particles, obj)
  58. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement