The simplest solution is to go for a constant scaling factor. Let's call the coordinates you handle with your vectors
world coordinates and the coordinates on screen
screen coordinates. You can transform between the two by simple multiplication:
Code: Select all
function sx,sy = worldToScreen(wx,wy)
sx = wx * scaleX
sy = wy * scaleY
end
function wx,wy = screenToWorld(sx,sy)
wx = sx / scaleX
wy = sy / scaleY
end
The variables scaleX and scaleY tell you how many pixels one world-coordinate-unit is. For example if you are using 32-by-32 pixel tiles, then scaleX and scaleY would be 32.
The next step would be scrolling. You could incorporate this into the two functions above by adding an offset. However, I suggest you use one of the camera libraries available (for example
gamera)