-- Helloworld like tic80 on love2d function love.load() love.graphics.setDefaultFilter("nearest", "nearest") -- load image img = love.graphics.newImage("obj.png") -- set Quad anime = {} for i = 0, 1 do -- set x, y, w, h, sw, sh anime[i + 1] = love.graphics.newQuad(i * 16, 0, 16, 16, img:getDimensions()) end img_scale = 8 x = (love.graphics.getWidth() - 16 * img_scale) / 2 -- centring y = love.graphics.getHeight() * 0.25 t = 0 end function love.update(dt) -- move object by key input local spd = 240 * dt if love.keyboard.isDown("up") then y = y - spd end if love.keyboard.isDown("down") then y = y + spd end if love.keyboard.isDown("left") then x = x - spd end if love.keyboard.isDown("right") then x = x + spd end t = t + dt end function love.draw() -- clear screen love.graphics.clear(0.4, 0.7, 0.8, 1.0) -- draw image local n = 1 + math.floor(t / 0.3) % #anime local angle = math.rad(0) local scale = img_scale love.graphics.setColor(1.0, 1.0, 1.0, 1.0) love.graphics.draw(img, anime[n], x, y, angle, scale, scale) -- draw text local tx = (love.graphics.getWidth() - 8 * 12) / 2 -- centering local ty = love.graphics.getHeight() * 0.75 love.graphics.print("HELLO WORLD!", tx, ty) love.graphics.print("FPS: " .. tostring(love.timer.getFPS()), 2, 2) end function love.keypressed(key, isrepeat) if key == "escape" then -- ESC key to exit love.event.quit() end end