| greggiles |
06-06-2012 01:42 AM |
Making a formula
I'm not sure how to write it out, but basically trying to make the 'zoom' value get higher as the player.y gets closer to the NPC's this.y
Here is what I got, and if I were to do full script with all values, it would be very very very very long. So looking for a more efficient way
PHP Code:
function onTimeOut() {
setTimer(0.05);
if (this.y in |player.y-5, player.y|)
{
this.zoom = 5;
}
if (this.y in |player.y-8, player.y-5|)
{
this.zoom = 4.5;
}
if (this.y in |player.y-11, player.y-8|)
{
this.zoom = 4;
}
if (this.y in |player.y-14, player.y-11|)
{
this.zoom = 3.5;
}
if (this.y in |player.y-17, player.y-14|)
{
this.zoom = 1;
}
if (this.y in |player.y-20, player.y-100|)
{
this.zoom = 0;
}
}
note: this is for the player being below the NPC
|