View Single Post
  #5  
Old 06-06-2012, 02:10 AM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
Start by calculating the distance between the player and the object. If considering both the X and Y axis:
  • Distance between player X and object X: abs(player.x - this.x)
  • Distance between player Y and object Y: abs(player.y - this.y)
From that you can determine the actual distance between the player and the object (perhaps using the Euclidean distance formula). Once you have some number that represents the distance, you can then calculate your zoom.

(The use of abs in the examples above transforms a possibly negative number into a positive "absolute" number. This is because you might get a negative value depending on if the player is to the left or right or above or below the object X and Y coordinates you specify. Details on abs here.)
__________________
Skyld
Reply With Quote