Right, ok. So in my example, I have Bitmaps being drawn to the Canvas (using an adaptation of SpriteMethodTest which I referred to a few days ago).
1) The Canvas.drawBitmap() method takes two floats as coordinates, so how can I avoid using them? Or if i was to pass 'integer' values, would that mean they were treated as such, regardless of the method signature? 2) Typical x and y points for my bitmaps are X: 281.01068 Y: 455.04297. When bitmaps get drawn to the screen, is this all wasted precision? Is drawing at 281.01068 any different from drawing at 281.31343? On Jun 8, 2:32 pm, Mark Murphy <[email protected]> wrote: > 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/commonsguyhttp://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

