Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Variables
- white = Color.new(255, 255, 255)
- black = Color.new(0, 0, 0)
- -- Configuration
- fenixBackground = "default.png"
- -- Set wallpaper
- wallpaper = Image.load(fenixBackground)
- -- Taskbar
- taskbar = Image.load("taskbar.png")
- taskbarHover = Image.load("hover.png")
- -- Draw mouse
- drawCursor = Image.load("mouse.png")
- -- Mouse settings
- Cursor = { x = 100, y = 100, img = drawCursor }
- -- Analog movement for mouse
- function mouseCursor()
- pad = Controls.read()
- anaX = pad:analogX()
- anaY = pad:analogY()
- if anaX > 50 then
- Cursor.x = Cursor.x + 3
- end
- if anaX < -50 then
- Cursor.x = Cursor.x - 3
- end
- if anaY > 50 then
- Cursor.y = Cursor.y + 3
- end
- if anaY < -50 then
- Cursor.y = Cursor.y - 3
- end
- end
- -- Initialize homescreen
- function initDesktop()
- -- Show wallpaper
- screen:blit(0, 0, wallpaper, 0, 0, 480, 272, true)
- -- Show taskbar
- screen:blit(0, 0, taskbar, 0, 0, 480, 37, true)
- -- Time
- screen:print(400,12,getTime,white)
- -- Taskbar items
- screen:print(10,12, "Applications", white)
- screen:print(130,12, "System", white)
- end
- -- Taskbar hovering and actions
- function uiTaskbar()
- -- Applications
- if (Cursor.x + 18 > 10) and (Cursor.x < 10 + 110) and (Cursor.y + 23 > 12) and (Cursor.y < 12 + 12) then
- -- Display hover image
- screen:blit(5, 17, taskbarHover, 0, 0, 98, 14, true)
- -- Check if mouse is clicked
- end
- end
- -- Return offscreen
- while true do
- -- Erase screen
- screen:clear()
- -- Get time
- getTime = os.date("%I:%M %p")
- -- Execute main
- initDesktop()
- -- Collision checks
- uiTaskbar()
- -- Mouse cursor
- screen:blit(Cursor.x,Cursor.y,Cursor.img)
- mouseCursor()
- -- Loop
- screen.flip()
- screen.waitVblankStart()
- end
Add Comment
Please, Sign In to add comment