SHARE
TWEET

Untitled

a guest Oct 21st, 2019 96 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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)
  25.     end
  26.    
  27.     --Spawn extra particles to cover new screen area (based on player speed)
  28.    
  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], primitive=Graphics.GL_TRIANGLE_STRIP, priority = -98}
  40.             --Graphics.drawImageWP(gfx[part.sprite], part.x, part.y, -98)
  41.         end
  42.     end
  43.    
  44.     spawnCooldown = spawnCooldown - 1
  45. end
  46.  
  47. function spawnParticle(x, y)
  48.     local obj = {x=x, y=y}
  49.     obj.sprite = math.random(numberOfSprites)
  50.    
  51.     obj.xV = 0
  52.     obj.yV = math.random(-110, -70)
  53.     obj.baseX = x
  54.     obj.timer = 0
  55.    
  56.     table.insert(particles, obj)
  57. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top