The animation is a little quick in that example, but you get the idea. So right now I have a small "leaf falling" animation that can just be placed over any of the existing trees, the thing is, I don't want to over-use this animation, I only want it to appear on tree in the scene, every few seconds. So if there are 10 trees on screen, it would randomize among them, but at a relatively slow rate. Probably 1 random tree every 3-5 seconds.
The same goes for that little water splash animation there. Now I'm going to do something embarrassing and post my code, for how I have trees spawning on the map.
First I've got this big Quad for all of the tree graphics:
Code: Select all
quads = {
love.graphics.newQuad(0, 0, 16, 16, 64, 128), -- 1 big white
love.graphics.newQuad(32, 0, 16, 16, 64, 128), -- 2 big green
love.graphics.newQuad(32, 32, 16, 16, 64, 128), -- 3 big blue
love.graphics.newQuad(0, 32, 16, 16, 64, 128), -- 4 big orange
love.graphics.newQuad(0, 16, 16, 16, 64, 128), -- 5 med white
love.graphics.newQuad(0, 48, 16, 16, 64, 128), -- 6 med orange
love.graphics.newQuad(32, 48, 16, 16, 64, 128), -- 7 med blue
love.graphics.newQuad(32, 16, 16, 16, 64, 128), -- 8 med green
love.graphics.newQuad(16, 0, 16, 16, 64, 128), -- 9 2 white
love.graphics.newQuad(16, 32, 16, 16, 64, 128), -- 10 2 orange
love.graphics.newQuad(48, 0, 16, 16, 64, 128), -- 11 2 green
love.graphics.newQuad(48, 32, 16, 16, 64, 128), -- 12 2 blue
love.graphics.newQuad(16, 16, 16, 16, 64, 128), -- 13 single white
love.graphics.newQuad(16, 48, 16, 16, 64, 128), -- 14 single orange
love.graphics.newQuad(48, 16, 16, 16, 64, 128), -- 15 single green
love.graphics.newQuad(48, 48, 16, 16, 64, 128), -- 16 single blue
love.graphics.newQuad(0, 64, 16, 16, 64, 128), -- 17 water well
love.graphics.newQuad(16, 64, 16, 16, 64, 128), -- 18 empty well
love.graphics.newQuad(32, 64, 16, 16, 64, 128), -- 19 wide well empty
love.graphics.newQuad(48, 64, 16, 16, 64, 128), -- 20 wide well concrete
love.graphics.newQuad(0, 80, 16, 16, 64, 128), -- 21 small well empty
love.graphics.newQuad(16, 80, 16, 16, 64, 128), -- 22 2 sticks
love.graphics.newQuad(32, 80, 16, 16, 64, 128), -- 23 1 sm stick
love.graphics.newQuad(48, 80, 16, 16, 64, 128), -- 24 1 lrg stick
love.graphics.newQuad(0, 96, 16, 16, 64, 128), -- 25 house marker
love.graphics.newQuad(0, 96, 16, 16, 64, 128) -- 26 water float marker
}
Code: Select all
function drawTrees()
for i = 1, #map do
for l = 1, #map do
if map[i][l] ~= 0 then
love.graphics.drawq(images.tileset, quads[map[i][l]], mapToWorld(l-1, i-2))
end
end
end
end
Any ideas guys?