Get distance between two points for tile based game
Some people that are making tile based games might be interested in the distance formula. The formula returns how many tiles it takes to get from one point to another on a grid. Most of you probably know this already, but here it is anyway..
VB Code:
Private Function Distance(X1 As Long, Y1 As Long, X2 As Long, Y2 As Long) As Long
Distance = (X2 - X1) + (Y2 - Y1)
End Function
For instance, if you wanted to determine the distance between tiles (2,8) and (9,14), you would use the formula like this..
That would then return 13 which is how many tiles it takes to get from point (2, 8) to point (9, 14). So for those who care, there it is.