• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Game Loop

I'm making a game, and I'm currently improving my Game loop. Currently it looks like this:
Code:
    boolean mRender = false;
    long mLastRTime = 0;
    long mTimeDiff = 0;

    public void onDrawFrame( GL10 aGL ) 
    {
        try
        {
            long lBeforeTime = System.nanoTime();
            long lAfterTime;
            long lAfterUTime;
            
            if ( mRunning )
            {
                mUpdater.Update( ( float )( mTimeDiff / 1000000L ) * 0.001f );
                lAfterUTime = System.nanoTime();
                Log.i("Game", "Updating");
                if( lAfterUTime - mLastRTime > Global.mTimeStep * 1000000 )
                {
                    Log.i("Game", "Rendering");
                    
                    mLastRTime = System.nanoTime();
                    mRenderer.Render();
                }
                
                lAfterTime = System.nanoTime();
                mTimeDiff = lAfterTime - lBeforeTime;

            }
            else
            {
                this.finish();
            }
            
        }
        catch ( final Exception aException )
        {
            Log.e( "Game", aException.toString() );
        }
    }
It works pretty well but, I might have missed something. Do any of you have anything to say about how I could possibly improve my loop?
 
Back
Top Bottom