Advertisement
AssortedBrunoz

DVD

Oct 18th, 2024 (edited)
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.17 KB | None | 0 0
  1. local monitor = peripheral.find("monitor")
  2. term.redirect(monitor)
  3. local max_x, max_y = term.getSize()
  4.  
  5. local dvd = {}
  6. dvd.x = max_x/2
  7. dvd.y = max_y/2
  8. dvd.direction_x = 1
  9. dvd.direction_y = 1
  10. color = {
  11.     colors.white,
  12.     colors.orange,
  13.     colors.magenta,
  14.     colors.lightBlue,
  15.     colors.yellow,
  16.     colors.lime,
  17.     colors.pink,
  18.     colors.gray,
  19.     colors.lightGray,
  20.     colors.cyan,
  21.     colors.purple,
  22.     colors.blue,
  23.     colors.brown,
  24.     colors.green,
  25.     colors.red
  26. }
  27. local t = 1
  28.  
  29. local function reset()
  30.     term.setCursorPos(1,1)
  31.     term.clear()
  32.     paintutils.drawFilledBox(1,1,max_x,max_y,colors.black)
  33.     term.setBackgroundColor(colors.black)
  34. end
  35.  
  36. local function update()
  37.     reset()
  38.  
  39.     local addx = (dvd.x + dvd.direction_x)
  40.     local addy = (dvd.y + dvd.direction_y)
  41.     if addx >= max_x or addx <= 1 then
  42.         dvd.direction_x = -dvd.direction_x
  43.         t = t + 1
  44.     end
  45.     if addy >= max_y or addy <= 2 then
  46.         dvd.direction_y = -dvd.direction_y
  47.         t = t + 1
  48.     end
  49.  
  50.     dvd.x = addx
  51.     dvd.y = addy
  52.    
  53.     paintutils.drawPixel(dvd.x,dvd.y, color[t])
  54. end
  55.  
  56. while true do
  57.     update()
  58.     os.sleep(0.5)
  59. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement