The following code should feature a rectangle that does not move, since it has two equal but opposite sets of instructions acting on it. But right now one set of code works, while the other (the one inside moveObject()) does not.
Code: Select all
function love.load()
ox,oy=0,0 -- object coordinates
function moveObject(ox,oy,s,dt) --should move object diagonally
ox=ox+s/2*dt oy=oy+s/2*dt
end
end
function love.update(dt)
local s=100 -- set the speed
--because the moveObject function uses negative s, the next two lines of code SHOULD cancel each other out. Right now that doesn't work.
moveObject(ox,oy,-s,dt)
ox=ox+s/2*dt oy=oy+s/2*dt
end
function love.draw()
love.graphics.rectangle('line',ox,oy,10,10)
end