XNA Game Studio Express
zoomZ = 100;
shiftX = 0;
shiftY =0;
z0=100;
PZ = {x:50, y:250};
function f3dscale (z) {
var scale = zoomZ*z0/(z0+z);
return scale;
}
function f3dPoint (x, y, z) {
var x3d = (x+shiftX)*f3dscale(z)/100+PZ.x;
var y3d = (y+shiftY)*f3dscale(z)/100+PZ.y;
var pt = {x:x3d, y:y3d};
return pt;
}
So, for a ball with x,y,z
_x=f3dPoint(x,y,z).x;
_y=f3dPoint(x,y,z).y;
_xscale=_yscale=f3dscale(z);