Guest User

Untitled

a guest
Nov 23rd, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. -- Variables
  2. white = Color.new(255, 255, 255)
  3. black = Color.new(0, 0, 0)
  4.  
  5. -- Configuration
  6. fenixBackground = "default.png"
  7.  
  8. -- Set wallpaper
  9. wallpaper = Image.load(fenixBackground)
  10.  
  11. -- Taskbar
  12. taskbar = Image.load("taskbar.png")
  13. taskbarHover = Image.load("hover.png")
  14.  
  15. -- Draw mouse
  16. drawCursor = Image.load("mouse.png")
  17.  
  18. -- Mouse settings
  19. Cursor = { x = 100, y = 100, img = drawCursor }
  20.  
  21. -- Analog movement for mouse
  22. function mouseCursor()
  23. pad = Controls.read()
  24. anaX = pad:analogX()
  25. anaY = pad:analogY()
  26.  
  27. if anaX > 50 then
  28. Cursor.x = Cursor.x + 3
  29. end
  30.  
  31. if anaX < -50 then
  32. Cursor.x = Cursor.x - 3
  33. end
  34.  
  35. if anaY > 50 then
  36. Cursor.y = Cursor.y + 3
  37. end
  38.  
  39. if anaY < -50 then
  40. Cursor.y = Cursor.y - 3
  41. end
  42. end
  43.  
  44. -- Initialize homescreen
  45. function initDesktop()
  46. -- Show wallpaper
  47. screen:blit(0, 0, wallpaper, 0, 0, 480, 272, true)
  48.  
  49. -- Show taskbar
  50. screen:blit(0, 0, taskbar, 0, 0, 480, 37, true)
  51.  
  52. -- Time
  53. screen:print(400,12,getTime,white)
  54.  
  55. -- Taskbar items
  56. screen:print(10,12, "Applications", white)
  57. screen:print(130,12, "System", white)
  58. end
  59.  
  60. -- Taskbar hovering and actions
  61. function uiTaskbar()
  62. -- Applications
  63. if (Cursor.x + 18 > 10) and (Cursor.x < 10 + 110) and (Cursor.y + 23 > 12) and (Cursor.y < 12 + 12) then
  64. -- Display hover image
  65. screen:blit(5, 17, taskbarHover, 0, 0, 98, 14, true)
  66. -- Check if mouse is clicked
  67. end
  68. end
  69.  
  70. -- Return offscreen
  71. while true do
  72. -- Erase screen
  73. screen:clear()
  74. -- Get time
  75. getTime = os.date("%I:%M %p")
  76. -- Execute main
  77. initDesktop()
  78. -- Collision checks
  79. uiTaskbar()
  80. -- Mouse cursor
  81. screen:blit(Cursor.x,Cursor.y,Cursor.img)
  82. mouseCursor()
  83. -- Loop
  84. screen.flip()
  85. screen.waitVblankStart()
  86. end
Add Comment
Please, Sign In to add comment