ID:2495660
 
Code:
mob/proc
cell_transition(var/prev_x,var/next_x,var/prev_y,var/next_y)
var/curr_x
var/curr_y
var/t=0
var/t_rate=0.02
while(t<1)
curr_x=prev_x + ((next_x - prev_x) * t)
curr_y=prev_y + ((next_y - prev_y) * t)
t+=t_rate
camera.step_x=round(curr_x*256,1) //256 is the size of the screen horizontally, measured in pixels
camera.step_y=round(curr_y*224,1) //224 is the size of the screen vertically, measured in pixels
sleep(0.16)
curr_x=prev_x + ((next_x - prev_x) * t)
curr_y=prev_y + ((next_y - prev_y) * t)
cell_x=next_x
cell_y=next_y


Problem description:

I'm working on a game inspired by the older Legend of Zelda games. I wrote a script to interpolate screen cells (the panning seen moving from one screen to another). It more or less works fine, though it does have an issue (which might be a processing issue) that causes the interpolation to chug fierce when the cells have larger integers than 0,0.

I've included a gif demonstrating this issue.

If any of you more experienced folks might have an idea or need further information, please let me know (and yes that code could be written better, of course).