Guest User

Untitled

a guest
Mar 13th, 2018
70
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- Pico-8 Rain Effect used in Punk-8
  2. -- Public Domain
  3.  
  4. rain = {}
  5.  
  6. function iff(c,a,b)
  7.     return c and a or b
  8. end
  9.  
  10. function between(b, e)
  11.     return b + rnd(e - b + 1)
  12. end
  13.  
  14. function initrain()
  15.     for i=1,128 do
  16.         add(rain, {
  17.              between(-64,128),
  18.              between(0,128),
  19.              iff(i<64, 5, 13)}
  20.         )
  21.     end
  22. end
  23.  
  24. function drawrain()
  25.     for r in all(rain) do
  26.         r[2] += iff(r[3]==5,3,4)
  27.         if r[2] > between(70,88) then
  28.             pset(r[1],r[2],1)
  29.             r[1] = between(-64,96)
  30.             r[2] = -between(0,32)  
  31.         end
  32.         r[1] += iff(r[3]==5,2,3)
  33.         line(r[1]-2 ,r[2]-3,
  34.              r[1],r[2],
  35.              r[3])
  36.     end
  37. end
RAW Paste Data