I'm having trouble using dt with a frogger clone I'm making. dt works but it doesn't loop the cars back around like I want it to. Here are the parts of the code that matter. I'm pretty sure I understand the problem, I just don't know how to fix it exactly. I think the variables in volks:new() have changed so when I put a volks:new() it is taking the current variables so it just keeps moving forward. How would I make it so it loops?
volks = {}
function volks:new()
vw = {
act_x_vw =0,
act_y_vw =315,
grid_x_vw = 0,
grid_y_vw =315,
speed = 30,
w =60,
h = 20,
imgbuggy = love.graphics.newImage("img/buggy.png"),
act_x_vwt = 0,
act_y_vwt =160,
grid_x_vwt = 0,
grid_y_vwt =160,
}
setmetatable(vw,{__index = volks})
return vw
end
function volks:update(dt)
if vw.act_x_vw ~= (580) then
vw.act_x_vw= vw.act_x_vw + vw.speed * dt
end
if vw.grid_x_vw ~= (580) then
vw.grid_x_vw = vw.grid_x_vw + vw.speed * dt
end
if vw.act_x_vw == (580) then
volks:new()
end
if vw.grid_x_vw == (580) then
volks:new()
end
end
ahh thank you so much, I am not sure why I had both act_x_vw and grid_x_vw, got rid of one of them. I think I originally wanted it to be okay with collision with the frog, but it seems fine.