Advertisement
PaymentOption

stars

Jul 30th, 2012
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.91 KB | None | 0 0
  1. local mon = peripheral.wrap("back")
  2. mon.setCursorBlink(false)
  3.  
  4. local stars = {}
  5. local w,h = mon.getSize()
  6.  
  7. -- local i = 1 -- I replaced many of your loops with for loops; seemed simpler.
  8.  
  9. for i=1, 21 do
  10.     stars[i] = {math.floor((math.random()-0.5)*200), math.floor((math.random()-0.5)*200), math.floor(math.random()*1000)}
  11. end
  12.  
  13. local function displayStars()
  14.     for i=1, 21 do
  15.         mon.setCursorPos(stars[i][1]/stars[i][3] + w/2, stars[i][2]/stars[i][3] + h/2)
  16.         term.write(mon.getCursorPos()[1] .. mon.getCursorPos()[2])
  17.         mon.write("*")
  18.     end
  19. end
  20.  
  21. local function updateStars()
  22.     for i=1, 21 do
  23.         if stars[i][3]<2 then
  24.             stars[i][3] = stars[i][3] - 1
  25.         else
  26.             stars[i][3] = 1000
  27.         end
  28.     end
  29. end
  30.  
  31. local run = true
  32.  
  33. while run do
  34.     if true then
  35.         updateStars()
  36.         mon.clear()
  37.         displayStars()
  38.     end
  39.     sleep(1)
  40. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement