Games on Symbian OS
Total Page:16
File Type:pdf, Size:1020Kb
Games on Symbian OS A Handbook for Mobile Development Games on Symbian OS A Handbook for Mobile Development Authors Fadi Chehimi, Leon Clarke (Ideaworks3D), Michael Coffey, Paul Coulton, Twm Davies, Roland Geisler, Nigel Hietala, Sam Mason, Peter Lykke Nielsen, Aleks Garo Pamir and Jo Stichbury (Lead author and editor) Contributors Sam Cartwright (Mobile Developer Lab), Tim Closs (Ideaworks3D), John Holloway (ZingMagic), David MacQueen (Screen Digest), Adam Taylor (Ideaworks3D) and Steve Townsend (Great Ape Software) Reviewed by Michael Aubert, Jan Bonnevier, Sam Cartwright, Martin de Jode, Brian Evans, Toby Gray, Martin Hardman, John Imhofe, Mathew Inwood, Mark Jacobs, Erik Jacobson, Rob James, Elina Koivisto, Kazuhiro Konishi, Mal Minhas, Ben Morris, Matthew O’Donnell, Matt Plumtree, Lane Roberts, Jesus Ruiz, Hartti Suomela, Steve Townsend, Shawn Van Every and Sally Vedros Head of Symbian Press Freddie Gjertsen Managing Editor Satu McNabb Copy Editor Lisa Voisin Copyright 2008 Symbian Software Ltd Published by John Wiley & Sons Ltd, The Atrium, Southern Gate, Chichester, West Sussex PO19 8SQ, England Telephone (+44) 1243 779777 Email (for orders and customer service enquiries): [email protected] Visit our Home Page on www.wileyeurope.com or www.wiley.com All Rights Reserved. No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except under the terms of the Copyright, Designs and Patents Act 1988 or under the terms of a licence issued by the Copyright Licensing Agency Ltd, 90 Tottenham Court Road, London W1T 4LP, UK, without the permission in writing of the Publisher. Requests to the Publisher should be addressed to the Permissions Department, John Wiley & Sons Ltd, The Atrium, Southern Gate, Chichester, West Sussex PO19 8SQ, England, or emailed to [email protected], or faxed to (+44) 1243 770620. Designations used by companies to distinguish their products are often claimed as trademarks. All brand names and product names used in this book are trade names, service marks, trademarks or registered trademarks of their respective owners. The Publisher is not associated with any product or vendor mentioned in this book. This publication is designed to provide accurate and authoritative information in regard to the subject matter covered. It is sold on the understanding that the Publisher is not engaged in rendering professional services. If professional advice or other expert assistance is required, the services of a competent professional should be sought. The Publisher and the Author make no representations or warranties with respect to the accuracy or completeness of the contents of this work and specifically disclaim all warranties, including without limitation any implied warranties of fitness for a particular purpose. The advice and strategies contained herein may not be suitable for every situation. In view of ongoing research, equipment modifications, changes in governmental regulations, and the constant flow of information relating to the use of experimental reagents, equipment, and devices, the reader is urged to review and evaluate the information provided in the package insert or instructions for each chemical, piece of equipment, reagent, or device for, among other things, any changes in the instructions or indication of usage and for added warnings and precautions. The fact that an organization or Website is referred to in this work as a citation and/or a potential source of further information does not mean that the author or the publisher endorses the information the organization or Website may provide or recommendations it may make. Further, readers should be aware that Internet Websites listed in this work may have changed or disappeared between when this work was written and when it is read. No warranty may be created or extended by any promotional statements for this work. Neither the Publisher nor the Author shall be liable for any damages arising herefrom. Copyright 2007 Nokia. All rights reserved. Nokia, N-Series, N-Gage QD, N-Gage Arena, Space Impact, Pathway to Glory, High Seize, Pro Series Golf, System Rush: Evolution and Mile High Pinball are trademarks or registered trademarks of Nokia Corporation. Other product and company names mentioned herein may be trademarks or trade names of their respective owners. The Bluetooth word mark and logos are registered trademarks owned by Bluetooth SIG, Inc. and any use of such marks by Symbian Software Ltd is under license. Other trademarks and trade names are those of their respective owners. All trademarks and logos that contain Java are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries Other Wiley Editorial Offices John Wiley & Sons Inc., 111 River Street, Hoboken, NJ 07030, USA Jossey-Bass, 989 Market Street, San Francisco, CA 94103-1741, USA Wiley-VCH Verlag GmbH, Boschstr. 12, D-69469 Weinheim, Germany John Wiley & Sons Australia Ltd, 42 McDougall Street, Milton, Queensland 4064, Australia John Wiley & Sons (Asia) Pte Ltd, 2 Clementi Loop #02-01, Jin Xing Distripark, Singapore 129809 John Wiley & Sons Canada Ltd, 6045 Freemont Blvd, Mississauga, Ontario, L5R 4J3, Canada Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be available in electronic books. British Library Cataloguing in Publication Data A catalogue record for this book is available from the British Library ISBN: 978-0-470-99804-5 Typeset in 10/12pt Optima by Laserwords Private Limited, Chennai, India Printed and bound in Great Britain by Bell & Bain, Glasgow This book is printed on acid-free paper responsibly manufactured from sustainable forestry in which at least two trees are planted for each one used for paper production. Contents Forewords ix About this Book xiii About the Authors xvii Editor’s Acknowledgements xxiii Part One: A Symbian Perspective on Mobile Games 1 Introduction 1 1.1 Why Games? 1 1.2 What Is Symbian? What Is Symbian OS? 2 1.3 Some Statistics 6 1.4 Games Platforms Compared 10 1.5 Types of Mobile Games 13 1.6 Who Plays Mobile Games? 16 1.7 Who’s Who in Mobile Game Creation? 17 1.8 Mobile Game Distribution: Routes to Market 20 1.9 The User Experience 25 1.10 Mobile Game Platforms 27 1.11 Portability and Compatibility 32 1.12 Smartphone Characteristics 37 1.13 The Future for Games on Symbian Smartphones 38 1.14 Summary 40 vi CONTENTS Part Two: Creating Native Games on Symbian OS v9 2 Symbian OS Game Basics 43 2.1 Introduction 43 2.2 The Game Loop 43 2.3 The Heartbeat Timer 46 2.4 Handling Input from the Keypad 49 2.5 Handling Input from the Screen 52 2.6 System Events 54 2.7 Memory Management and Disk Space 57 2.8 Maths and Floating Point Support 59 2.9 Tools and Further Reading 60 3 Graphics on Symbian OS 61 3.1 Introduction 61 3.2 Overview 62 3.3 On Frame Rate 64 3.4 About Display Memory 67 3.5 A Primer on Drawing on Symbian OS 68 3.6 Direct Screen Access 75 3.7 Double Buffering and Anti-Tearing 83 3.8 Pixel Color Representations 90 3.9 Loading and Manipulating Images 97 3.10 Scaling for Variable Screen Sizes and Resolutions 105 3.11 Rendering Text 111 3.12 Playing Video Clips 115 3.13 Less Useful APIs 121 3.14 Summary 121 4 Adding Audio to Games on Symbian OS 123 4.1 Introduction 123 4.2 Multimedia Framework (MMF) 124 4.3 Sound Effects 128 4.4 Background Music 142 4.5 Best Practice in Mobile Game Audio 150 4.6 What’s Next? 151 5 Multiplayer Games 157 5.1 Introduction 157 5.2 Local Multiplayer Games Over a Bluetooth Connection 159 5.3 Online Multiplayer Games 160 5.4 Airplay Online: A Multiplayer SDK and Service Solution 165 CONTENTS vii 5.5 N-Gage Arena 171 5.6 Other Online Multiplayer Solutions 174 5.7 Further Reading 174 6 Exploiting the Phone Hardware 175 6.1 Introduction 175 6.2 Camera 178 6.3 Location 188 6.4 3D Motion Sensors 198 6.5 Vibration 207 6.6 Summary 216 6.7 Acknowledgements 216 Part Three: Porting Games to Symbian OS 7 C/C++ Standards Support for Games Developers on Symbian OS 217 7.1 P.I.P.S. Is POSIX on Symbian OS 217 7.2 Open C 220 7.3 OpenKODE 224 7.4 OpenVG 227 7.5 OpenMAX 228 7.6 OpenSL ES 229 7.7 EGL 230 7.8 OpenGL ES 231 7.9 Get Your Fix 234 7.10 Enough Already! 236 7.11 Further Reading 237 8 The N-Gage Platform 239 8.1 A Brief History of N-Gage 239 8.2 N-Gage Platform: The Next Generation of Mobile Gaming 244 8.3 The N-Gage SDK 248 8.4 The N-Gage Application 256 8.5 Becoming an N-Gage Developer 262 8.6 Summary 264 viii CONTENTS Part Four: Java ME, DoJa and Flash Lite on Symbian OS 9 MIDP Games on Symbian OS 265 9.1 Introduction 265 9.2 Java ME 101 265 9.3 To Java ME or Not To Java ME? 270 9.4 Tools and SDKs 271 9.5 What About MIDP on Symbian OS? 272 9.6 Pausing for Breath 274 9.7 Living it Up 277 9.8 Game Architecture 280 9.9 Case Study: Third Degree 282 9.10 Did You Hear That SNAP? 289 9.11 And Another Thing ... 293 9.12 Further Reading 294 10 Games In Japan 297 10.1 Introduction 297 10.2 The Japanese Market 297 10.3 Enter DoJa! 299 10.4 DoJa 2.5 Overview 302 10.5 Porting MIDP to DoJa 310 10.6 DoJa and Eclipse 313 10.7 Mascot 316 10.8 Tokyo Titles 318 10.9 At The End Of The Day 319 11 Flash Lite Games on Symbian OS 321 11.1 Introduction 321 11.2 Flash Lite on Mobile Phones 323 11.3 Flash Lite Overview 324 11.4 Flash Lite Development Tools 329 11.5 Flash Lite Ecosystem 335 References and Resources 337 Appendix: Airplay 341 Index 351 Foreword Tim Closs, Chief Technology Officer, Ideaworks3D Ltd The mobile phone is not primarily a platform for playing games, and Symbian OS is not primarily a platform for writing games.