I am trying to get the drawings to work right. I cant seem to find whats wrong i am trying to make a bunch of my pictures draw in a row of 10 and idk whats wrong i see the grass appear and then it moves to the right and glitches out
(the code is in the draw function)
function love.load()
grass = love.graphics.newImage("images/grasstop.png")
grassx = 0
grassy = 300
num = 0
end
function love.draw()
for i = 1,10 do
num = num + 50
love.graphics.draw(grass,grassx+num,grassy)
end
end
Because you're moving it 50 pixels every frame, and if your machine is really good then that could be 50 pixels 500-1000 times a second. (Or 60 times a second if you use VSync.)
Look up dt and getDelta. Embrace them. They are your friend.
Edit: LOL, I misunderstood and didn't see that other part. Oh well. What micha says below is correct.
Last edited by Jasoco on Fri May 09, 2014 8:36 am, edited 2 times in total.
The problem is, that num is a global variable and it gets larger and larger each frame. To fix this you could either reset it to 0 in the beginning of the draw function or you could go completely without: