Advertisement
Guest User

startup.lua

a guest
Feb 8th, 2020
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.06 KB | None | 0 0
  1. local nfte = require "nfte"
  2.  
  3. local mon = peripheral.find("monitor")
  4. if mon then
  5.     mon.setTextScale(0.5)
  6.     term.redirect(mon)
  7. end
  8.  
  9. local scr_x, scr_y = term.getSize()
  10.  
  11. local logo = {
  12.     xvel = 1, --math.random(0, 3) - 1.5,
  13.     yvel = 1, --math.random(0, 3) - 1.5,
  14.     x = scr_x / 2,
  15.     y = scr_y / 2,
  16.     img = nfte.loadImage("dvdlogo.nft")
  17. }
  18.  
  19. local render = function()
  20.     term.clear()
  21.     nfte.drawImage(logo.img, math.floor(logo.x), math.floor(logo.y))
  22. end
  23.  
  24. local max, min = math.max, math.min
  25.  
  26. local tick = function()
  27.     local imgXsize, imgYsize = nfte.getSize(logo.img)
  28.     local xWall = scr_x - imgXsize + 1
  29.     local yWall = scr_y - imgYsize + 1
  30.     logo.x = min(max(logo.x + logo.xvel, 1), xWall)
  31.     logo.y = min(max(logo.y + logo.yvel, 1), yWall)
  32.    
  33.     if math.floor(logo.x) == 1 or math.floor(logo.x) == xWall then
  34.         logo.xvel = -logo.xvel
  35.     end
  36.     if math.floor(logo.y) == 1 or math.floor(logo.y) == yWall then
  37.         logo.yvel = -logo.yvel
  38.     end
  39.     render()
  40. end
  41.  
  42. while true do
  43.     tick()
  44.     sleep(0.05)
  45. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement