Game update and user interface
We have already covered a few update and interface mechanisms previously. A running game state can be changed by user input or internal AI algorithms:
Mostly, game update is called once per frame or once after a fixed time interval. Either way, an algorithm does its job to change the game state. You have learned about user input queues. On each game loop cycle, the input queues are being checked.
For example, a mobile game loop with a touch interface works as follows:
/* import proper view and implement touch listener */ public class MyGameView extends View implements View.OnTouchListener /* declare game state */ private MyGameState gameState; /* set listener */ public MyGameView (Context context) { super(context); setOnTouchListener(this); setFocusableInTouchMode(true); gameState = new MyGameState(); } /* override onTouch() and call state update on individual touch events */ @Override public boolean onTouch(View v, MotionEvent event) { if(event.getAction...