-- fullscreen disp 01 function love.load() -- init -- set filter love.graphics.setDefaultFilter("nearest", "nearest") -- set canvas size scr_w = 640 scr_h = 480 canvas = love.graphics.newCanvas(scr_w, scr_h) -- get window width and height wdw_w, wdw_h = love.graphics.getDimensions() scr_scale = math.min((wdw_w / scr_w), (wdw_h / scr_h)) scr_ofsx = (wdw_w - (scr_w * scr_scale)) / 2 scr_ofsy = (wdw_h - (scr_h * scr_scale)) / 2 -- load image img = love.graphics.newImage("ufo_64x64_fullcol.png") -- make Quad imgs = {} for i=1,(8 * 4) do local ii = i - 1 local x = (ii % 8) * 64 local y = math.floor(ii / 8) * 64 imgs[ii] = love.graphics.newQuad(x, y, 64, 64, img:getDimensions()) end img_count = 9 img_count_time = 0 -- framerate steady min_dt = 1 / 60 next_time = love.timer.getTime() end function love.update(dt) -- update next_time = next_time + min_dt img_count_time = img_count_time + dt img_count = 9 + math.floor(15 * img_count_time) % 15 end function love.draw() -- set canvas love.graphics.setCanvas(canvas) -- draw BG love.graphics.setColor(0, 0, 255) love.graphics.rectangle("fill", 0, 0, scr_w, scr_h) -- draw sprite love.graphics.setColor(255, 255, 255) love.graphics.draw(img, imgs[img_count], 32, 32) -- unset canvas love.graphics.setCanvas() -- draw canvas to window love.graphics.setColor(255, 255, 255) love.graphics.draw(canvas, scr_ofsx, scr_ofsy, 0, scr_scale, scr_scale) 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) -- ESC to exit if key == "escape" then love.event.quit() end end