[android-developers] Re: Lunar Lander "game loop" (was: Re: [android-developers] Re: How fast is the T-Mobile G1?)

2008-10-29 Thread Robert Green
Why redraw if nothing has changed? Also - how do you know if nothing has changed if you don't check for it? :) These are the reasons the main loop is the way it is. My main loop currently looks like this: private void update() { if (!isPaused) {

[android-developers] Re: Lunar Lander "game loop" (was: Re: [android-developers] Re: How fast is the T-Mobile G1?)

2008-10-29 Thread Stoyan Damov
Let me try to explain again - I don't want the # of updates to be == the # of redraws, and I'm fine with a variable # of game updates/sec, provided that this number is greater than the fastest movement of a sprite (e.g. 100 updates/sec for a sprite which moves at 100 px/sec). updatePhysics will su

[android-developers] Re: Lunar Lander "game loop" (was: Re: [android-developers] Re: How fast is the T-Mobile G1?)

2008-10-29 Thread Robert Green
Actually the correct way is not to lock in the number of updates to physics at a constant rate but instead to have the physics themselves be defined as a rate. For example, if you want to have a player moving at a rate of 1 virtual foot per second (let's say that's 5 pixels on screen for a 2d gam

[android-developers] Re: Lunar Lander "game loop" (was: Re: [android-developers] Re: How fast is the T-Mobile G1?)

2008-10-29 Thread Stoyan Damov
Thanks again, yes, something like that - I realize the question was more for a game development forum, not here, sorry. Basically I'd like the game loop to call updatePhysics, say, exactly 30 times/sec but render only when there's anything to render, sleep to preserve battery otherwise. Cheers O

[android-developers] Re: Lunar Lander "game loop" (was: Re: [android-developers] Re: How fast is the T-Mobile G1?)

2008-10-28 Thread hackbod
If you want to throttle your updates to something less than the screen refresh rate, you can just use SystemClock.uptimeMillis() to find the time between each draw and Object.sleep() or Object.wait() to suspend the thread until it is next time to draw. Is that what you are looking for? On Oct 28

[android-developers] Re: Lunar Lander "game loop" (was: Re: [android-developers] Re: How fast is the T-Mobile G1?)

2008-10-28 Thread Stoyan Damov
Thanks to you and Romain! So my follow up question is what is the maximum number of vertical syncs per second of a G1 phone? In other words, if the drawing code is really fast (e.g. if I don't invalidate the entire screen but just a tiny rectangle), what am I supposed to do in order to make an an

[android-developers] Re: Lunar Lander "game loop" (was: Re: [android-developers] Re: How fast is the T-Mobile G1?)

2008-10-28 Thread Romain Guy
If you look at the drawing code of the LunarLander, you will see somewhere that the code synchronizes (post and lock or something like this) on the Surface. This waits for the next vsync basically. On Tue, Oct 28, 2008 at 5:46 PM, Stoyan Damov <[EMAIL PROTECTED]> wrote: > > Hackbod, thanks for yo

[android-developers] Re: Lunar Lander "game loop" (was: Re: [android-developers] Re: How fast is the T-Mobile G1?)

2008-10-28 Thread Stoyan Damov
Hackbod, thanks for your reply. Could you elaborate on that, or point me to some link explaining it? Thanks, Stoyan On Wed, Oct 29, 2008 at 2:43 AM, hackbod <[EMAIL PROTECTED]> wrote: > > On Oct 28, 2:03 pm, "Stoyan Damov" <[EMAIL PROTECTED]> wrote: >> No shit batman? At what FPS? The max possib

[android-developers] Re: Lunar Lander "game loop" (was: Re: [android-developers] Re: How fast is the T-Mobile G1?)

2008-10-28 Thread hackbod
A little more info (I missed that the app has been changed to use a SurfaceView) -- the call to lock will block if you are running faster than the maximum frame rate. See here: http://code.google.com/android/reference/android/view/SurfaceHolder.html#lockCanvas() On Oct 28, 2:03 pm, "Stoyan Damo

[android-developers] Re: Lunar Lander "game loop" (was: Re: [android-developers] Re: How fast is the T-Mobile G1?)

2008-10-28 Thread hackbod
On Oct 28, 2:03 pm, "Stoyan Damov" <[EMAIL PROTECTED]> wrote: > No shit batman? At what FPS? The max possible on the device? Redrawing a > frame possibly hundreds of times per second w/o the physics even being > updated at all? You will not receive updates faster than the display refresh rate, th