Advertisement
Guest User

hurp.lua

a guest
Feb 25th, 2015
286
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.34 KB | None | 0 0
  1. local component = require("component")
  2. local os = require("os")
  3. local gpu = component.gpu
  4. local w,h = gpu.getResolution()
  5. local tick = 1/(h/2)
  6. local white = true
  7. local black = true
  8. local whiteCol = 16777215
  9. local blackCol = 0
  10.  
  11. function setup()
  12.   gpu.setBackground(0x000000)
  13.   gpu.setForeground(0xFFFFFF)
  14.   gpu.fill(1,1,w,h," ")
  15. end
  16.  
  17. function fromWhite()
  18.   if white then
  19.     whiteCol = whiteCol-1
  20.   else
  21.     whiteCol = whiteCol+1
  22.   end
  23.   if whiteCol == 0 then
  24.     white = false
  25.   elseif whiteCol == 16777215 then
  26.     white = true
  27.   end
  28.   --print(whiteCol)
  29.   return whiteCol
  30. end
  31.  
  32. function fromBlack()
  33.   if black then
  34.     blackCol = blackCol+1
  35.   else
  36.     blackCol = blackCol-1
  37.   end
  38.   if blackCol == 16777215 then
  39.     black = false
  40.   elseif blackCol == 0 then
  41.     black = true
  42.   end
  43.   --print(blackCol)
  44.   return blackCol
  45. end
  46.  
  47. function aniIn()
  48.   for i=1, h/2 do
  49.     setup()
  50.     gpu.setBackground(fromWhite())
  51.     gpu.fill(i,i,w-(i*2)+2,h-(i*2)+2," ")-- this line
  52.     gpu.setBackground(fromBlack())
  53.     gpu.fill(i+1,i+1,w-(i*2),h-(i*2)," ")
  54.     os.sleep(tick)
  55.   end
  56. end
  57.  
  58. function aniOut()
  59.   for i=h/2, 1, -1 do
  60.     setup()
  61.     gpu.setBackground(fromWhite())
  62.     gpu.fill(i,i,w-(i*2)+2,h-(i*2)+2," ")
  63.     gpu.setBackground(fromBlack())
  64.     gpu.fill(i+1,i+1,w-(i*2),h-(i*2)," ")
  65.     os.sleep(tick)
  66.   end
  67. end
  68.  
  69. function main()
  70.   aniIn()
  71.   aniOut()
  72. end
  73.  
  74. while true do
  75.   main()
  76. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement