Guest User

Untitled

a guest
Sep 22nd, 2015
212
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. cls()
  2.  
  3. MAGIC_NUM_1  = 16
  4. MAGIC_NUM_2  = 30
  5. gc = 0
  6. plasma = {}
  7.  
  8. function dist(x1, y1, x2, y2)
  9.     return  sqrt(((x2-x1)*(x2-x1)) + ((y2-y1)*(y2-y1)))
  10. end
  11.  
  12. function rerange(n, omin, omax, nmin, nmax)
  13.     return (((n - omin) * (nmax - nmin)) / (omax - omin)) + nmin
  14. end
  15.  
  16. function plasma()
  17.     local c
  18.     local c1
  19.     local c2
  20.  
  21.     local c21
  22.  
  23.     for y=1,127 do
  24.         for x=1,127 do
  25.             c1 = sin(x / MAGIC_NUM_1 + gc)
  26.             c2 = sin(dist(x, y, sin(-gc) * MAGIC_NUM_2 + MAGIC_NUM_2, cos(-gc) * MAGIC_NUM_2 + MAGIC_NUM_2) / MAGIC_NUM_1)
  27.             c  = c1 + c2 + gc
  28.             pset(x, y, rerange(c, -1, 1, 1, 15))
  29.         end
  30.     end
  31. end
  32.  
  33. function _init()
  34.  
  35. end
  36.  
  37. function _update()
  38.     gc += 1
  39. end
  40.  
  41. function _draw()
  42.     cls()
  43.     plasma()
  44. end
RAW Paste Data