sonic-radiance/sonic-radiance.love/core/modules/assets/background.lua

26 lines
638 B
Lua

local Background = Object:extend()
function Background:new(filepath)
self.image = love.graphics.newImage(filepath)
self.batch = love.graphics.newSpriteBatch(self.image , 1000 )
self.width, self.height = self.image:getDimensions()
local w = math.floor(424 / self.width) * self.width + 1
local h = math.floor(240 / self.height) * self.height + 1
for i=-1, w do
for j=-1, h do
self.batch:add(i * self.width, j * self.height)
j = j + 1
end
i = i + 1
end
end
function Background:draw(ox, oy)
love.graphics.setColor(1, 1, 1)
love.graphics.draw(self.batch, ox, oy)
end
return Background