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
My canvas is scaled 8x8 and what I am trying to happen is the image to load up randomly spread down the height of the screen, they travel upwards until off the screen to then change image and start from the bottom again. I have passed all the right functions into the callback functions but I still don't know whats wrong.
Please help me. Thanks in advance, Kyle.
Like it clearly states in the title, the randomly generated images do not show up...
I will just upload my give my main.lua code because that is the only thing that uses this class.