Kingdaro

CC fireplace

Sep 27th, 2012
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.47 KB | None | 0 0
  1. local screen = peripheral.wrap('back')
  2.  
  3. local fire = {}
  4.  
  5. local w,h = screen.getSize()
  6. local max = math.ceil(h*0.5)
  7.  
  8. for i=1, w do
  9.   table.insert(fire, math.random(max))
  10. end
  11.  
  12. while true do
  13.   screen.clear()
  14.  
  15.   for i=1, #fire do
  16.     local n = fire[i]
  17.     if n >= max then
  18.       fire[i] = 1
  19.     else
  20.       fire[i] = n + math.random(0,2)
  21.     end
  22.    
  23.     n = fire[i]
  24.    
  25.     for y=1, n do
  26.       screen.setCursorPos(i, h - n + y)
  27.       screen.write('S')
  28.     end
  29.   end
  30.  
  31.   sleep(0.1)
  32. end
Advertisement
Add Comment
Please, Sign In to add comment