Game Development Reference
In-Depth Information
Windows Native Application
Our Portable Game
Initialization
OnStart()
Java Activity
Main loop
OnMouseMove()
Native Android Library
WinAPI
Window
Function
Pull system
messages
OnMouseDown()
SendMotion() JNI callback
DrawFrame() JNI callback
OnMouseUp()
Update game
state
Update game
state
OnTimer()
JNI calls
OnDrawFrame()
Render frame
Render frame
Shutdown
OnStop()
ExitNative() JNI callback
The rest of the topic is centered on this kind of architecture and the game functionality will be
implemented inside these portable On...() callbacks.
There is yet another important note. Responding to timer events to create animation can be
done on Windows with the SetTimer() call and the WM_TIMER message handler. We get
to that in Chapter 2 , Porting Common Libraries, when we speak about rigid body physics
simulations. However, it is much better to organize a ixed time-step main loop, which is
explained later in the topic.
See also
F Chapter 6 , Unifying OpenGL ES 3 and OpenGL 3
F The recipe Implementing the main loop in Chapter 8 , Writing a Match-3 Game
Unifying the cross-platform code
Right now, we have two different versions of a simple program ( Win_Min2 and App3 ). Let us
see how to unify the common parts of the code.
 
Search WWH ::




Custom Search