Neilz wrote: > Hi all. I've read this in a few articles, that one should avoid > floating point operations within the physics update of a game. > > But how do you really achieve this? Surely all half decent games are > going to involve this kind of maths?
Use integer math. > Does it mean, convert all your variables to int, or use double > instead, or simply just cut it out as much as possible? For example, look at the Google Maps API, compared to the Location API. A Location object has a double for getLatitude() and getLongitude(). For light uses, that's fine. However, for Google Maps, trying to do everything in floating point would get too slow. Hence, the GeoPoint class has latitude and longitude as integer microdegrees -- 1E6 times the double value in degrees. This allows Google Maps to maintain a fair bit of precision while sticking with integer math. What you need to do for your game is come up with appropriate units of measurement such that you won't need fractional units, for whatever degree of precision you want. For example, instead of kilometers, do your calculations in meters, or centimeters, or millimeters. -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy Warescription: Three Android Books, Plus Updates, One Low Price! -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

