等轴游戏的坐标体系分红3种; post
普通的笛卡尔坐标系; orm
正则网格坐标; blog
仿射网格坐标; 游戏
其中正则网格的宽度和高度是 仿射网格宽度 高度的一半; io
关键就是找到这三种坐标的转换公式: function
SIZEX, SIZEY 是菱形网格宽度高度的一半, class
从笛卡尔坐标到正则网格 im
function cartesianToNormal(x, y)
return round(x/SIZEX), round(y/SIZEY)
end next
从正则网格到仿射网格
function normalToAffine(nx, ny)
return round((ny-nx)/2), round((nx+ny)/2)
end
img