+Random Terrain Posted Monday at 08:20 AM Share Posted Monday at 08:20 AM Is there a better way to get the distance between two objects than using something like this? if player0y > missile0y then temp6 = player0y - missile0y if missile0y > player0y then temp6 = missile0y - player0y Seems like there would be a fancy math way that doesn't require two if-thens. Quote Link to comment Share on other sites More sharing options...
+splendidnut Posted Monday at 12:54 PM Share Posted Monday at 12:54 PM You might be thinking of the 'absolute value' math function found in most programming languages: temp = abs(player0y - missile0y) Which in bBasic, would be: temp6 = player0y - missile0y if temp6{7} then temp6 = -temp6 ;-- IF value is negative, THEN make it positive. NOTE: If the distance is greater than 127, this doesn't work, since big values would be interpreted as negative values due to the byte range limit. 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.