Code: Select all
clouds = {}
clouds.__index = clouds
function clouds.init()
local cld = {}
setmetatable(cld, clouds)
cld.batch = {}
for i=1, 9 do
table.insert(cld.batch, {love.graphics.newImage("graphics/cloud"..math.random(3)..".png"), math.random(width - 32), (i - 1)*1.92})
end
cld.v = 1
return cld
end
function clouds:draw()
love.graphics.setColor(255,255,255,255)
for i=1, #self.batch do
love.graphics.draw(self.batch[i][1], self.batch[i][2], self.batch[i][3])
end
end
function clouds:update(dt)
for i=1, #self.batch do
self.batch[i][3] = self.batch[i][3] + self.v * 20
if self.batch[i][3] < -16 then
self.batch[i][3] = height
self.batch[i][2] = math.random(width - 32)
self.batch[i][1] = love.graphics.newImage("graphics/cloud"..math.random(3)..".png")
end
end
if self.v < 10 then
self.v = self.v + dt
end
end
Please help me. Thanks in advance, Kyle.