PHP Code:
function onTimeOut() {
temp.dist_x = player.x - findimg(200).x;
temp.dist_y = player.y - findimg(200).y;
temp.len = (this.dist_x * this.dist_x + this.dist_y * this.dist_y) ^ 0.5;
findImg(200).zoom = (temp.len>1 ? temp.len : 1);
}
|
Looks like you copied this from a bad script example.
Why not just do
PHP Code:
temp.len = (this.dist_x^2 + this.dist_y^2)^0.5;
I think it also helps to know where these formulas come from... so just so people know
it's Pythagoras' theorem:a^2+b^2 = c^2 which re-arranges to c = sqrt(a^2+b^2)
and you can find the square root of something without the square root function by using powers which is 0.5
so it's c = (a^2+b^2)^0.5
Only reason i'm saying all this is because I beleive anyone who's striving to be a decent programmer should have a fair bit of base maths knowledge.