-- Windows screensaver with love2d function love.load() love.graphics.setDefaultFilter("nearest", "nearest") -- get screen size wdw_w, wdw_h = love.graphics.getDimensions() -- Check command line options ssmode = "" for k, v in pairs(arg) do lv = string.lower(v) if lv == "/s" then ssmode = "fullscreen" elseif lv == "/c" then ssmode = "config" elseif lv == "/p" then ssmode = "preview" elseif lv == "/a" then ssmode = "passwordlock" end end if ssmode == "" then ssmode = "none" end if ssmode == "config" then love.event.quit() end if ssmode == "preview" then love.event.quit() end if ssmode == "passwordlock" then love.event.quit() end if ssmode == "none" then love.event.quit() end -- hide mouse cursor love.mouse.setVisible(false) min_dt = 1 / 60 next_time = love.timer.getTime() dx = wdw_w / 2 dy = dx / 3 x = wdw_w / 2 y = wdw_h / 2 r = wdw_w / 100 end function love.update(dt) next_time = next_time + min_dt if dt > 0.75 then return end -- move ball x = x + dx * dt y = y + dy * dt if (x - r) < 0 or (x + r) > wdw_w then dx = dx * -1 end if (y - r) < 0 or (y + r) > wdw_h then dy = dy * -1 end end function love.draw() -- clear screen love.graphics.setCanvas() love.graphics.clear(0, 0, 0, 1.0) -- draw ball love.graphics.setColor(0.1, 0.3, 1.0, 1.0) love.graphics.circle("fill", x, y, r) -- draw FPS love.graphics.setColor(0.5, 0.5, 0.5, 1.0) love.graphics.print("FPS: "..tostring(love.timer.getFPS()), 10, 10) if love.system.getOS() == "Windows" then -- wait local cur_time = love.timer.getTime() if next_time <= cur_time then next_time = cur_time else love.timer.sleep(next_time - cur_time) end end end function love.keypressed(key, isrepeat) -- Pressed any key to exit love.mouse.setVisible(true) love.event.quit() end function love.mousemoved( x, y, dx, dy, istouch ) -- Moved the mouse cursor a lot to exit if dx * dx + dy * dy >= 16 * 16 then love.mouse.setVisible(true) love.event.quit() end end