garden/window.lua
2024-12-26 20:09:41 +09:00

33 lines
669 B
Lua

local w = {}
function w.new(inner, x, y, w, h)
local r = {
transform = love.math.newTransform(x, y),
width = w,
height = h
}
function r:transformPoint(x, y)
local x, y = transform:transformPoint(x, y)
if 0 <= x and x <= width and 0 <= y and y <= height then
return x, y
else
return nil
end
end
function r:mousepressed(m, x, y)
return inner:mousepressed(m, x, y)
end
function r:draw()
love.graphics.push()
love.graphics.setTransform(self.transform)
inner:draw()
love.graphics.pop()
end
return r
end
return w