take a look at this talk http://code.google.com/events/io/sessions/WritingRealTimeGamesAndroid.html
He has a bunch of slides comparing various methods for rendering 2d sprite type objects. On Jun 24, 6:39 pm, Chris Stockton <chrisstockto...@gmail.com> wrote: > Hello, > > I am faced with a challenge of drawing destructable terrain. My current and > surely naive approach is as follows. Excuse formatting, posting from my g1 > and don't have the code with me so the math in the rectf might be wrong be > advised, but it does work, visually; it is just a fps nerf. > > Terrain is 720 px wide, terrain square is 4px, worst case total terrain > columns to be drawn is 720/4 = 180, currently I draw a 4x4 bitmap, using the > rectf arg to stretch/transform its height. > > [code] > Static public float[] mapUpperBounds = ... 25.0f, 27.0f. 29.0f ... 150.0f, > 148.0f ... 1.0f > Static public Rect mSourceRect = new Rect(0, 0, 4, 4); > ... > For(int I = 0; I < 180; i++) { > // call my graphics lib, if opengl is avail > // it transforms the request into a matrix > // and draws it in a way identical to canvas > G.drawBitmap(handle, mRectSource, new RectF( > // each float is the upper boundary, > // with a width of 4 I just slowly > // crawl across the map from left to right > I*4, > > // we strech the bitmap from the > // upper boundary down to the > // bottom of the map > canvasHeight - mapUpperBounds[I], > canvasWidth - ((I*4)+4), > mapUpperBounds[I] > ) > );} > > [/code] > > My thoughts : > -180 calls to the graphics lib is crazy furthermore the fact I draw a bitmap > might be bad too. > -Drawline perhaps is cheaper? Haven't tried it yet just came to mind > -when zoomed in closely this becomes more and more trival, I won't render if > it is out of the view point. > -Have the background image contain the 'tiles' and chunk into it as the > terrain explodes? Math might be a little complex, but if all explosions were > circular might be cheaper, question is how expensive is drawCircle (or > whatever method would be appropiate, I could see up to 400+ exploisons per > game) > > I'm sure this problem has been solved before, just not by me :P thank you > for your patience. > > Regards, > > -Chris --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---