{ "selector": "source.lua", "cmd": ["c:\\Program Files\\LOVE\\love", "${project_path:${folder}}"] }
function love.load() end function love.update(dt) end function love.draw() end
local habrImage, width, height function love.load() habrImage = love.graphics.newImage("habr.png") width = love.graphics.getWidth() height = love.graphics.getHeight() end function love.update(dt) end function love.draw() love.graphics.draw(habrImage, width / 2 - habrImage:getWidth() / 2, height / 2 - habrImage:getHeight() / 2) end
love.graphics.setBackgroundColor(255, 255, 255)
local habrImage, width, height, state, rotation, scale, ox, oy, delta -- function love.load() habrImage = love.graphics.newImage("habr.png") width = love.graphics.getWidth() height = love.graphics.getHeight() state = "none" resetVariables() end -- function resetVariables() rotation = 0 scale = 1 ox = 0 oy = 0 delta = 1 end -- function love.keypressed(key, unicode) if key == "r" then state = "rotation" resetVariables() elseif key == "s" then state = "scalling" resetVariables() elseif key == "m" then state = "moving" resetVariables() elseif key == "space" then -- (: state = "none" resetVariables() end end -- function love.update(dt) if state == "rotation" then -- rotation = rotation + delta * dt elseif state == "scalling" then -- scale = scale + delta * dt elseif state == "moving" then -- , : -- -- -- delta = delta + delta * dt local radius = 50 ox = radius * math.sin(delta) oy = radius * math.cos(delta) end end -- function love.draw() -- love.graphics.setBackgroundColor(255, 255, 255) -- love.graphics.draw(habrImage, width / 2 - habrImage:getWidth() / 2, height / 2 - habrImage:getHeight() / 2, rotation, scale, scale, ox, oy) end
Source: https://habr.com/ru/post/202540/
All Articles