Android Writing Real Time Games Android
-
Upload
nuno-sousa -
Category
Documents
-
view
224 -
download
0
Transcript of Android Writing Real Time Games Android
-
8/2/2019 Android Writing Real Time Games Android
1/59
Saturday, May 22, 2010
-
8/2/2019 Android Writing Real Time Games Android
2/59
Saturday, May 22, 2010
-
8/2/2019 Android Writing Real Time Games Android
3/59
Writing Real-Time GamesFor Android ReduxChris PruettMay 2010
Saturday, May 22, 2010
-
8/2/2019 Android Writing Real Time Games Android
4/59
Google Confidential
Please Wave Me, Bro!
3
http://bit.ly/c5nm4w
Saturday, May 22, 2010
http://www.google.com/url?q=http%3A%2F%2Fbit.ly%2Fc5nm4w&sa=D&usg=ALhdy28bg6s3fjC7u7L_-SWFDBcg3_w2Mwhttp://www.google.com/url?q=http%3A%2F%2Fbit.ly%2Fc5nm4w&sa=D&usg=ALhdy28bg6s3fjC7u7L_-SWFDBcg3_w2Mw -
8/2/2019 Android Writing Real Time Games Android
5/59
Google Confidential
Intro
Im a Developer Advocate for Android.
My focus is games.
Before I joined Google, I was a video game programmer.
I guess Im still a video game programmer.
But thats not my title.
Its complicated.
4
Saturday, May 22, 2010
-
8/2/2019 Android Writing Real Time Games Android
6/59
Google Confidential
Agenda
How the World Has Changed
Device Classes
Performance Benchmarks
Game Architecture for Android
Using OpenGL ES
Using the NDK
Tips and Tricks
Android Market for Games
Traits of Successful Titles Replica Island
Lessons Learned
5
Saturday, May 22, 2010
-
8/2/2019 Android Writing Real Time Games Android
7/59
Google Confidential6
Saturday, May 22, 2010
-
8/2/2019 Android Writing Real Time Games Android
8/59
Google Confidential
May 2009
Android 1.5 had just been released.
The G1 was the (only) device.
Android Market had < 5000 apps
7
Saturday, May 22, 2010
-
8/2/2019 Android Writing Real Time Games Android
9/59
Google Confidential
First GenerationSecond Generation
8
Now: Discrete Device Classes
Saturday, May 22, 2010
-
8/2/2019 Android Writing Real Time Games Android
10/59
528mhz ARM11 CPU (at ~400mhz) Qualcomm MSM7200A chipset
OpenGL ES 1.0 integrated ATI GPU, various 1.1 extensions.
3.2 HVGA (480x320) screen
~5000 verts/frame @ 30 fps*
~1024 verts/frame @ 60 fps*
Android 1.5 / 1.6
About 60% of the market right now
Google Confidential
First Generation Devices
*Textured, unlit, colored verts
9
Saturday, May 22, 2010
-
8/2/2019 Android Writing Real Time Games Android
11/59
Google Confidential
Second Generation Devices
*Textured, unlit, colored verts
600 mhz - 1 ghz CPUs Snapdragon, OMAP3
OpenGL ES 2.0, 1.1 + extensions
WVGA (800x480) screen
~27000 verts/frame @ 30 fps*
Typically fill-limited to 30 fps
Android 1.6 ~ Android 2.1
Almost 40% of the market right now
First device shipped in December 2009
10
Saturday, May 22, 2010
-
8/2/2019 Android Writing Real Time Games Android
12/59
Google Confidential
Device Diversity
Screen Size / Density
Input Hardware
Trackball? D-Pad? Keyboard? Multi Touch?
Standardized API for input events.
Everything is a Motion Event or Key Event
All devices have a touch screen, accelerometer, orientationsensor.
OpenGL Driver
- Texture Format: ATITC? PVRTC? ETC1?
- OpenGL 1.1? 2.0?
- GL_EXTENSIONS content?
11
Saturday, May 22, 2010
-
8/2/2019 Android Writing Real Time Games Android
13/59
Google Confidential
Android in the Wild
Android OS version
- Android 1.5: all basic functionality.- Android 1.6: screen size support.
- Android 2.0: OpenGL ES 2.0 support.
Android 1.5Android 1.6Android 2.1Other
1%
37%
28%
34%
Android 1.5
Android 1.6
Android 2.1
as of 5/12/2010source: http://developer.android.com/resources/dashboard/platform-versions.html
12
Saturday, May 22, 2010
http://developer.android.com/resources/dashboard/platform-versions.htmlhttp://developer.android.com/resources/dashboard/platform-versions.htmlhttp://developer.android.com/resources/dashboard/platform-versions.htmlhttp://developer.android.com/resources/dashboard/platform-versions.html -
8/2/2019 Android Writing Real Time Games Android
14/59
OpenGL ES 1.1
Static VBO, floating point units
Verts, texture, colors
512x512x16 texture, no mip maps, no compression
Variable scene complexity
Google Confidential
Detailed Performance
13
Saturday, May 22, 2010
-
8/2/2019 Android Writing Real Time Games Android
15/59
Google Confidential
Cross-Device View
32 ms
Results of testing with HeightMapProfiler
14
Saturday, May 22, 2010
-
8/2/2019 Android Writing Real Time Games Android
16/59
Google Confidential
More Verts!
~1000 ms
32 ms
Results of testing with HeightMapProfiler
15
Saturday, May 22, 2010
-
8/2/2019 Android Writing Real Time Games Android
17/59
Google Confidential
Level of Detail is Your Friend
16
Saturday, May 22, 2010
-
8/2/2019 Android Writing Real Time Games Android
18/59
Google Confidential
Level of Detail is Your Friend
16
4 FPS 16 FPS 35 FPS
Saturday, May 22, 2010
-
8/2/2019 Android Writing Real Time Games Android
19/59
Google Confidential
Performance Best Practices
Use VBOs!
Minimize VBO selection. (and, as usual, all state change)
Use floating point verts.
ETC1 texture compression is most compatible.
draw_texture is the fast path for 2D, axis-aligned texture blits.
No point in using the NDK just to issue GL commands.
Most WVGA devices are all fill bound. Target 30 fps.
Design to scale between low end and high end.
GL_EXTENSIONS is your friend. Simple 2D games might not need OpenGL.
GLES2.0 is the faster path on devices that support it.
17
Saturday, May 22, 2010
-
8/2/2019 Android Writing Real Time Games Android
20/59
Google Confidential
Drawing in Replica Island
Sprites: draw_texture
Background: draw_texture
Tile layers: VBOs18Saturday, May 22, 2010
-
8/2/2019 Android Writing Real Time Games Android
21/59
Google Confidential
Third Attempt
Single VBO, draw scanlines of tiles
19
Saturday, May 22, 2010
-
8/2/2019 Android Writing Real Time Games Android
22/59
Google Confidential
Agenda
How the World Has Changed
Device Classes
Performance Benchmarks
Game Architecture for Android
Using OpenGL ES
Using the NDK
Tips and Tricks
Android Market for Games
Traits of Successful Titles Replica Island
Lessons Learned
20
STAGECOM
PLETE
Saturday, May 22, 2010
-
8/2/2019 Android Writing Real Time Games Android
23/59
Google Confidential
Dual Thread Approach
21
Activity
SurfaceHolder
RenderingThread
OpenGL ESContext
GameThread
SoundPool
Android Framework
Input Events
Input Events
Saturday, May 22, 2010
-
8/2/2019 Android Writing Real Time Games Android
24/59
Google Confidential
Render Thread
Surfac
RenderingThread
OpenCon
ead
GLSurfaceView
22
Saturday, May 22, 2010
-
8/2/2019 Android Writing Real Time Games Android
25/59
-
8/2/2019 Android Writing Real Time Games Android
26/59
Google Confidential
GLSurfaceView.Renderer
class AwesomeGameRenderer implements GLSurfaceView.Renderer {
publicvoid onSurfaceCreated(GL10 gl, EGLConfig config) {
// One-time GL setup goes here
}
publicvoid onSurfaceChanged(GL10 gl, int w, int h) { // Viewport operations go here.
}
publicvoid onDrawFrame(GL10 gl) {
// Draw the frame
}
}
24
Saturday, May 22, 2010
-
8/2/2019 Android Writing Real Time Games Android
27/59
Activity
SurfaceHolder
RenderingThread
OpenGL ESContext
GameThread
SoundPool
Android Framework
Input Events
Input Events
Google Confidential
With the NDK
NativeCode
NativeCode
25
Saturday, May 22, 2010
-
8/2/2019 Android Writing Real Time Games Android
28/59
Google Confidential
Rendering Natively
class AwesomeGameRenderer implements GLSurfaceView.Renderer {
static {System.loadLibrary("nativegamelib");
}
privatestaticnativevoid nativeGameInit();
privatestaticnativevoid nativeGameResize(int w, int h);
privatestaticnativevoid nativeDrawFrame();
publicvoid onSurfaceCreated(GL10 gl, EGLConfig config) {
// One-time GL setup goes here
nativeGameInit();
}
publicvoid onSurfaceChanged(GL10 gl, int w, int h) {
// Viewport operations go here.nativeGameResize(w, h);
}
publicvoid onDrawFrame(GL10 gl) {
// Draw the frame
nativeDrawFrame();
}26
Saturday, May 22, 2010
-
8/2/2019 Android Writing Real Time Games Android
29/59
Google Confidential
EGL Context and Pausing
VRAM
27
Saturday, May 22, 2010
-
8/2/2019 Android Writing Real Time Games Android
30/59
Google Confidential
EGL Context and Pausing
VRAM
27
Saturday, May 22, 2010
-
8/2/2019 Android Writing Real Time Games Android
31/59
Google Confidential
EGL Context and Pausing
VRAM
27
Saturday, May 22, 2010
-
8/2/2019 Android Writing Real Time Games Android
32/59
Google Confidential
EGL Context and Pausing
VRAM
27
Saturday, May 22, 2010
-
8/2/2019 Android Writing Real Time Games Android
33/59
Google Confidential
EGL Context and Pausing
VRAM
28
Saturday, May 22, 2010
-
8/2/2019 Android Writing Real Time Games Android
34/59
Google Confidential
Replica Island Pause Problem
29
Saturday, May 22, 2010
-
8/2/2019 Android Writing Real Time Games Android
35/59
Google Confidential
#1 Takeaway: Customizable Controls
30
Saturday, May 22, 2010
-
8/2/2019 Android Writing Real Time Games Android
36/59
Google Confidential
Original Input System
31
Activity
Thread
InputSystem
Game
MotionEvents
KeyEvents
Track Ball
Saturday, May 22, 2010
-
8/2/2019 Android Writing Real Time Games Android
37/59
Google Confidential
Original Input System
32
Activity
Thread
InputSystem
Game
MotionEvents
KeyEvents
Track Ball
Touch Screen OrientationSensor
Saturday, May 22, 2010
-
8/2/2019 Android Writing Real Time Games Android
38/59
Google Confidential
Original Input System
33
Activity
Thread
InputSystem
Game
MotionEvents
KeyEvents
Track Ball
Touch Screen OrientationSensor
Keyboard
Tilt Controls
D-Pad
Saturday, May 22, 2010
-
8/2/2019 Android Writing Real Time Games Android
39/59
Google Confidential
Current Input System
34
Activity
Thread
InputSystem
Game
MotionEvents
KeyEvents
InputInterfaceRaw State
JumpTiltMovement Attack
Saturday, May 22, 2010
-
8/2/2019 Android Writing Real Time Games Android
40/59
Google Confidential
Agenda
How the World Has Changed
Device Classes
Performance Benchmarks
Game Architecture for Android
Using OpenGL ES
Using the NDK
Tips and Tricks
Android Market for Games
Traits of Successful Titles
Replica Island
Lessons Learned
35
STAGECOM
PLETE
RANKACHIEVED:S
Saturday, May 22, 2010
-
8/2/2019 Android Writing Real Time Games Android
41/59
Google Confidential
Traits of the Most Successful Games
36
Supports 1.5 Screen Shots Free Version Average Price
Most Popular Paid 100% 90% 90% $3.45
Most Downloaded Paid 90% 70% 80% $3.38
Most Popular Free 100% 60% - -
Most Downloaded Free 100% 50% - -
Based on top 10 titles across all game categories.
Saturday, May 22, 2010
-
8/2/2019 Android Writing Real Time Games Android
42/59
Google Confidential
Almost Done
37
Saturday, May 22, 2010
-
8/2/2019 Android Writing Real Time Games Android
43/59
Google Confidential
Couple of Months
38
f(May 2009 + Couple of Months) = March 2010?
Saturday, May 22, 2010
-
8/2/2019 Android Writing Real Time Games Android
44/59
Google Confidential
Replica Island Marketing Plan
Web site
Blog
Press releases sent to Android blogs
Provide download QR Code
39
Total Marketing Spend: $0.00
Saturday, May 22, 2010
-
8/2/2019 Android Writing Real Time Games Android
45/59
Google Confidential
Replica Island Marketing Plan
Web site
Blog
Press releases sent to Android blogs
Provide download QR Code
40
Total Marketing Spend: $0.00Total Marketing Spend: $39.95
Saturday, May 22, 2010
-
8/2/2019 Android Writing Real Time Games Android
46/59
Google Confidential
Replica Island Marketing Plan
Web site
Blog
Press releases sent to Android blogs
Provide download QR Code
41
Total Marketing Spend: $0.00Total Marketing Spend: $39.95
Total Marketing Spend: $0.00
(sorry Nicholai)
Saturday, May 22, 2010
-
8/2/2019 Android Writing Real Time Games Android
47/59
Google Confidential
Replica Island: First 60 Days
42
0
100000
200000
300000
400000
500000
600000
3/9/10
3/10/10
3/11/10
3/12/10
3/13/10
3/14/10
3/15/10
3/16/10
3/17/10
3/18/10
3/19/10
3/20/10
3/21/10
3/22/10
3/23/10
3/24/10
3/25/10
3/26/10
3/27/10
3/28/10
3/29/10
3/30/10
3/31/10
4/1/10
4/2/10
4/3/10
4/4/10
4/5/10
4/6/10
4/7/10
4/8/10
4/9/10
4/10/10
4/11/10
4/12/10
4/13/10
4/14/10
4/15/10
4/16/10
4/17/10
4/18/10
4/19/10
4/20/10
4/21/10
4/22/10
4/23/10
4/24/10
4/25/10
4/26/10
4/28/10
4/29/10
4/30/10
5/1/10
5/2/10
5/3/10
5/4/10
5/5/10
5/6/10
5/7/10
5/8/10
5/9/10
Replica Island Installs: First 60 Days
Saturday, May 22, 2010
-
8/2/2019 Android Writing Real Time Games Android
48/59
Google Confidential
Replica Island: First 60 Days
43
Replica Island Installs: First 60 Days
First Update
PressReleases,YouTube
GizmodoArticle
Added toFeatured List
SecondUpdate
ThirdUpdate
FourthUpdate
Saturday, May 22, 2010
-
8/2/2019 Android Writing Real Time Games Android
49/59
Google Confidential
Couple of Months
44
f(May 2009 + Couple of Months) =Mediocre Game
f(May 2009 + Couple of Months) = March 2010?
Saturday, May 22, 2010
-
8/2/2019 Android Writing Real Time Games Android
50/59
Google Confidential
Problem: Crappy Tools
45
Saturday, May 22, 2010
-
8/2/2019 Android Writing Real Time Games Android
51/59
Google Confidential
Solution: Automated User Feedback
46
Saturday, May 22, 2010
-
8/2/2019 Android Writing Real Time Games Android
52/59
Google Confidential
Listen to your users
47
Saturday, May 22, 2010
-
8/2/2019 Android Writing Real Time Games Android
53/59
Google Confidential
Listen to your users... they are hilarious
48
Saturday, May 22, 2010
-
8/2/2019 Android Writing Real Time Games Android
54/59
Google Confidential
Listen to your users... they are fascinating
49
Saturday, May 22, 2010
-
8/2/2019 Android Writing Real Time Games Android
55/59
Google Confidential
Listen to your users... they are fascinating
49
Threats?!
Challenge = Bug?
Saturday, May 22, 2010
-
8/2/2019 Android Writing Real Time Games Android
56/59
Google Confidential
Other Lessons Learned
User bug reports are highly
unreliable. Different Strokes.
Extremely Casual
Extremely Hard Core
Dynamic Difficulty Adjustment?
50
Market placement isnt static! Respond to feedback!
Early Prototype = Good, but dont skimp on testing and tools.
Communicate in as many ways as possible.
Saturday, May 22, 2010
-
8/2/2019 Android Writing Real Time Games Android
57/59
Saturday, May 22, 2010
-
8/2/2019 Android Writing Real Time Games Android
58/59
Its not really about innovation so muchas exploring interestingness.
Jonathan Blow, author ofBraid
Saturday, May 22, 2010
-
8/2/2019 Android Writing Real Time Games Android
59/59
Useful Links
http://bit.ly/c5nm4w
Hot Wave Technology, Live Now!
http://developer.android.com
The start.
http://code.google.com/p/apps-for-android/
Home to SpriteMethodTest,HeightMapProfiler, and other samples.
http://replicaisland.net
Game, blog, source, etc.
http://replicaisland.net/http://code.google.com/p/apps-for-android/http://developer.android.com/http://replicaisland.net/http://replicaisland.net/http://code.google.com/p/apps-for-android/http://code.google.com/p/apps-for-android/http://developer.android.com/http://developer.android.com/http://www.google.com/url?q=http%3A%2F%2Fbit.ly%2Fc5nm4w&sa=D&usg=ALhdy28bg6s3fjC7u7L_-SWFDBcg3_w2Mwhttp://www.google.com/url?q=http%3A%2F%2Fbit.ly%2Fc5nm4w&sa=D&usg=ALhdy28bg6s3fjC7u7L_-SWFDBcg3_w2Mw