Saturday, May 22, 2010

Saturday, May 22, 2010

Writing Real-Time Games For Android Redux
Chris Pruett May 2010

Saturday, May 22, 2010

Please Wave Me, Bro!

http://bit.ly/c5nm4w

3

Google Confidential

Saturday, May 22, 2010

Intro
• I’m a Developer Advocate for Android.
– My focus is games.

• Before I joined Google, I was a video game programmer.
– I guess I’m still a video game programmer. – But that’s not my title. – It’s complicated.

4

Google Confidential

Saturday, May 22, 2010

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 Google Confidential Saturday. May 22. 2010 .

2010 . May 22.6 Google Confidential Saturday.

• Android Market had < 5000 apps 7 Google Confidential Saturday.May 2009 • Android 1. 2010 . May 22. • The G1 was the (only) device.5 had just been released.

Now: Discrete Device Classes Second Generation First Generation 8 Google Confidential Saturday. 2010 . May 22.

2” HVGA (480x320) screen • ~5000 verts/frame @ 30 fps* • ~1024 verts/frame @ 60 fps* • Android 1. various 1. colored verts 9 Google Confidential Saturday. May 22. • 3.6 • About 60% of the market right now *Textured. unlit.0 integrated ATI GPU.1 extensions.5 / 1.First Generation Devices • 528mhz ARM11 CPU (at ~400mhz) • Qualcomm MSM7200A chipset • OpenGL ES 1. 2010 .

1 + extensions • WVGA (800x480) screen • ~27000 verts/frame @ 30 fps* • Typically fill-limited to 30 fps • Android 1.1 ghz CPUs • Snapdragon. unlit. 2010 . OMAP3 • OpenGL ES 2.6 ~ Android 2.0.1 • Almost 40% of the market right now • First device shipped in December 2009 *Textured. colored verts 10 Google Confidential Saturday. 1.Second Generation Devices • 600 mhz . May 22.

Device Diversity • Screen Size / Density • Input Hardware – Trackball? D-Pad? Keyboard? Multi Touch? – Standardized API for input events.Texture Format: ATITC? PVRTC? ETC1? . 2010 . • OpenGL Driver . May 22. • Everything is a Motion Event or Key Event – All devices have a touch screen.1? 2.OpenGL 1.GL_EXTENSIONS content? 11 Google Confidential Saturday. orientation sensor.0? . accelerometer.

1 Android 1. 2010 .6: screen size support. May 22.5 Android 1.Android 1.5 Android 1.6 28% as of 5/12/2010 source: http://developer.Android 1.Android 2.5: all basic functionality.6 Android 2.com/resources/dashboard/platform-versions. . 1% 34% Android 1.0: OpenGL ES 2.0 support.Android in the Wild • Android OS version .android.1 Other 37% Android 2. .html 12 Google Confidential Saturday.

floating point units – Verts.1 – Static VBO. texture. May 22. no mip maps. colors – 512x512x16 texture.Detailed Performance • OpenGL ES 1. 2010 . no compression – Variable scene complexity 13 Google Confidential Saturday.

Cross-Device View 32 ms Results of testing with HeightMapProfiler 14 Google Confidential Saturday. May 22. 2010 .

More Verts! ~1000 ms 32 ms Results of testing with HeightMapProfiler 15 Google Confidential Saturday. 2010 . May 22.

Level of Detail is Your Friend 16 Google Confidential Saturday. 2010 . May 22.

Level of Detail is Your Friend 4 FPS 16 FPS 35 FPS 16 Google Confidential Saturday. May 22. 2010 .

• ETC1 texture compression is most compatible. • Design to scale between low end and high end.Performance Best Practices • Use VBOs! • Minimize VBO selection. axis-aligned texture blits. • Most WVGA devices are all fill bound. • No point in using the NDK just to issue GL commands. (and. Target 30 fps. • draw_texture is the fast path for 2D. 2010 . all state change) • Use floating point verts. 17 Google Confidential Saturday. May 22. as usual.0 is the faster path on devices that support it. • GLES2. • Simple 2D games might not need OpenGL. – GL_EXTENSIONS is your friend.

May 22. 2010 Tile layers:VBOs .Drawing in Replica Island Background: draw_texture Sprites: draw_texture 18 Google Confidential Saturday.

2010 . draw scanlines of tiles 19 Google Confidential Saturday.Third Attempt Single VBO. May 22.

Agenda • How the World Has Changed – Device Classes – Performance Benchmarks S GE TA OM C TE LE P • 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 Google Confidential Saturday. May 22. 2010 .

May 22. 2010 .Dual Thread Approach Android Framework Input Events Activity Input Events OpenGL ES Context Surface Holder Game Thread Rendering Thread Sound Pool 21 Google Confidential Saturday.

May 22.Input Events Render Thread GLSurfaceView Rendering Thread OpenGL Conte me ead SurfaceH 22 Google Confidential Saturday. 2010 .

} @Override protected void onResume() { super. } Google Confidential 23 } Saturday. AwesomeGameRenderer renderer = new AwesomeGameRenderer(). mGLView.onResume(). } @Override protected void onPause() { super.onPause().Activity + GLSurfaceView public class GameActivity extends Activity { private GLSurfaceView mGLView. 2010 .onCreate(savedInstanceState).setRenderer(renderer). mGLView = new GLSurfaceView(this). May 22. mGLView.onPause(). @Override protected void onCreate(Bundle savedInstanceState) { super. setContentView(mGLView). mGLView.onResume().

Renderer class AwesomeGameRenderer implements GLSurfaceView. May 22. } public void onDrawFrame(GL10 gl) { // Draw the frame } } 24 Google Confidential Saturday. EGLConfig config) { // One-time GL setup goes here } public void onSurfaceChanged(GL10 gl.GLSurfaceView. 2010 . int h) { // Viewport operations go here.Renderer { public void onSurfaceCreated(GL10 gl. int w.

2010 .With the NDK Android Framework Input Events Activity Input Events Native Code Game Thread Native Code Rendering Thread OpenGL ES Context Surface Holder Sound Pool 25 Google Confidential Saturday. May 22.

int h).Renderer { static { System.Rendering Natively class AwesomeGameRenderer implements GLSurfaceView. } public void onSurfaceChanged(GL10 gl. nativeGameResize(w.loadLibrary("nativegamelib"). int h) { // Viewport operations go here. } private static native void nativeGameInit(). int w. h). } public void onDrawFrame(GL10 gl) { // Draw the frame nativeDrawFrame(). private static native void nativeDrawFrame(). 26 } Google Confidential Saturday. May 22. private static native void nativeGameResize(int w. EGLConfig config) { // One-time GL setup goes here nativeGameInit(). 2010 . public void onSurfaceCreated(GL10 gl.

May 22.EGL Context and Pausing VRAM 27 Google Confidential Saturday. 2010 .

2010 . May 22.EGL Context and Pausing VRAM 27 Google Confidential Saturday.

EGL Context and Pausing VRAM 27 Google Confidential Saturday. May 22. 2010 .

2010 .EGL Context and Pausing VRAM 27 Google Confidential Saturday. May 22.

May 22.EGL Context and Pausing VRAM 28 Google Confidential Saturday. 2010 .

2010 . May 22.Replica Island Pause Problem 29 Google Confidential Saturday.

#1 Takeaway: Customizable Controls 30 Google Confidential Saturday. May 22. 2010 .

Original Input System Activity Thread MotionEvents KeyEvents Input System Track Ball Game 31 Google Confidential Saturday. May 22. 2010 .

Original Input System Activity Thread MotionEvents KeyEvents Input System Track Ball Touch Screen Orientation Sensor Game 32 Google Confidential Saturday. 2010 . May 22.

Original Input System Activity Thread MotionEvents KeyEvents D-Pad Input System Track Ball Tilt Controls Game Orientation Sensor Keyboard Touch Screen 33 Google Confidential Saturday. 2010 . May 22.

May 22.Current Input System Activity Thread MotionEvents KeyEvents Input System Input Interface Raw State Movement Tilt Game Attack Jump 34 Google Confidential Saturday. 2010 .

May 22. 2010 .Agenda • How the World Has Changed – Device Classes – Performance Benchmarks S GE TA OM C TE LE P • Game Architecture for Android – Using OpenGL ES – Using the NDK – Tips and Tricks RANK ACHI E VED: S • Android Market for Games – Traits of Successful Titles – Replica Island – Lessons Learned 35 Google Confidential Saturday.

45 $3.Traits of the Most Successful Games Supports 1. 36 Google Confidential Saturday.38 - Based on top 10 titles across all game categories. 2010 .5 Most Popular Paid Most Downloaded Paid Most Popular Free Most Downloaded Free Screen Shots Free Version Average Price 100% 90% 100% 100% 90% 70% 60% 50% 90% 80% - $3. May 22.

2010 . May 22.“Almost Done” 37 Google Confidential Saturday.

May 22. 2010 .“Couple of Months” f(May 2009 + “Couple of Months”) = March 2010? 38 Google Confidential Saturday.

2010 .00 39 Google Confidential Saturday. May 22.Replica Island Marketing Plan • Web site • Blog • Press releases sent to Android blogs • Provide download QR Code Total Marketing Spend: $0.

Replica Island Marketing Plan • Web site • Blog • Press releases sent to Android blogs • Provide download QR Code Total Marketing Spend: $0. 2010 .00 Total Marketing Spend: $39. May 22.95 40 Google Confidential Saturday.

Replica Island Marketing Plan • Web site • Blog • Press releases sent to Android blogs • Provide download QR Code Total Marketing Spend: $0. May 22.00 (sorry Nicholai) 41 Google Confidential Saturday.00 Total Marketing Spend: $39. 2010 .95 Total Marketing Spend: $0.

42 Saturday. May 22. 2010 Replica Island: First 60 Days Google Confidential 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 0 Replica Island Installs: First 60 Days .

2010 Replica Island: First 60 Days Google Confidential 100000 200000 300000 400000 500000 600000 First Update Press Releases. May 22.43 Saturday. YouTube Gizmodo Article Added to Featured List Second Update Third Update Fourth Update 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 0 Replica Island Installs: First 60 Days .

“Couple of Months” f(May 2009 + “Couple of Months”) = March 2010? f(May 2009 + “Couple of Months”) = Mediocre Game 44 Google Confidential Saturday. 2010 . May 22.

May 22. 2010 .Problem: Crappy Tools 45 Google Confidential Saturday.

May 22.Solution: Automated User Feedback 46 Google Confidential Saturday. 2010 .

2010 . May 22.Listen to your users 47 Google Confidential Saturday.

. May 22. they are hilarious 48 Google Confidential Saturday. 2010 ..Listen to your users.

2010 . they are fascinating 49 Google Confidential Saturday.Listen to your users. May 22...

. May 22. they are fascinating Threats?! Challenge = Bug? 49 Google Confidential Saturday. 2010 ..Listen to your users.

Other Lessons Learned • User bug reports are highly unreliable. – Extremely Casual – Extremely Hard Core – Dynamic Difficulty Adjustment? • Market placement isn’t static! Respond to feedback! • Early Prototype = Good. May 22. 2010 . • Different Strokes. • Communicate in as many ways as possible. but don’t skimp on testing and tools. 50 Google Confidential Saturday.

Saturday. May 22. 2010 .

author of Braid Saturday.“It’s not really about innovation so much as exploring interestingness.” Jonathan Blow. May 22. 2010 .

Useful Links • http://bit. etc. May 22. 2010 .com – The start. HeightMapProfiler.google.com/p/apps-for-android/ – Home to SpriteMethodTest. and other samples.net – Game. 52 Google Confidential Saturday. source. Live Now! • http://developer. • http://code. blog. •http://replicaisland.ly/c5nm4w – Hot Wave Technology.android.

Sign up to vote on this title
UsefulNot useful