I have a basic understanding of tile maps and movement, but I'm having trouble moving beyond that. My goal is to replicate the movement seen in NES games like Dragon Warrior and Final Fantasy. Here's the code I've been experimenting with:
function love.load() x = 0 y = 0 dx = 0 dy = 0 size = 64 t = 10 v = size / t end function love.draw() love.graphics.rectangle("fill", x, y, size, size) end function love.update(dt) x = x + (dx - x) * (v * dt) y = y + (dy - y) * (v * dt) end function love.keypressed(key) if key == "up" then dy = dy - size end if key == "down" then dy = dy + size end if key == "left" then dx = dx - size end if key == "right" then dx = dx + size end if key == "escape" then love.event.push("quit") end end
Currently I can press a button and the block will move a set distance, which is great, but it moves at a variable speed; it slows down as it approaches the end of it's movement.
Am I on the right track at the moment? I feel like I'm missing something in the math department.
Edited by StarHustler, 02 October 2013 - 12:07 PM.