When the framerate drops, its not too much, but it's defidently noticable.
Here's my setup..
Code: Select all
particle = {}
function particle:spawn(x,y,xvel,yvel,pic)
table.insert(particle, {timer = 0, x = x, y = y, pic = pic, xvel = xvel, yvel = yvel,height = 16 / 4, width = 16 / 4})
end
function particle:draw()
for i,v in ipairs(particle) do
if player.x > v.x - renderdistance and
player.x > v.x + renderdistance + v.width then
love.graphics.setColor(255,255,255)
love.graphics.draw(v.pic,v.x,v.y,0,0.2,0.2)
end
end
end
function particle:mech(dt)
for i,v in ipairs(particle) do
v.timer = v.timer + dt
v.x = v.x + v.xvel * dt
v.y = v.y + v.yvel * dt
v.xvel = v.xvel * (1 - math.min(dt*player.friction, 1)) --Use the players friction variable, cause I'm lazy.
v.yvel = v.yvel + player.gravity * dt
if v.timer > 3 then
table.remove(particle, i)
end
end
for i,v in ipairs(tile) do
for ia,va in ipairs(particle) do
if va.x > v.x - renderdistance and
va.x < v.x + renderdistance + 16 / 4 then
if va.y + va.height > v.y and
va.y + va.height < v.y + (v.height / 2) and
va.x + va.width > v.x + 1 and
va.x < v.x + v.width - 1 and
va.kind ~= "fence" and
va.kind ~= "turrent" then
va.y = v.y - va.height
va.yvel = 0
va.xvel = 0
va.xvel = va.xvel
va.yvel = va.yvel
end
if va.x + va.width > v.x and
va.x < v.x + (v.width / 2) and
va.y + va.height > v.y + 1 and
va.y < v.y + v.height - 1 and
va.kind ~= "fence" and
va.kind ~= "turrent" then
va.xvel = 0
va.yvel = 0
va.xvel = va.xvel
va.yvel = va.yvel
end
if va.x < v.x + v.width and
va.x > v.x + (v.width / 2) and
va.y + va.height > v.y + 1 and
va.y < v.y + v.height - 1 and
va.kind ~= "fence" and
va.kind ~= "turrent" then
va.xvel = 0
va.yvel = 0
va.yvel = va.yvel
va.xvel = va.xvel
end
if va.y < v.y + v.height and
va.y > v.y + (v.height / 2) and
va.x + va.width > v.x + 1 and
va.x < v.x + v.width - 1 and
va.kind ~= "fence" and
va.kind ~= "turrent" then
va.yvel = 0
va.xvel = 0
va.yvel = va.yvel
va.xvel = va.xvel
end
end
end
end
end