Professional HTML5 Mobile Game Development
Published byJohn Wiley & Sons, Inc.10475 Crosspoint BoulevardIndianapolis, IN 46256 www.wiley.com
Copyright 2012 by Pascal Rettig
Published by John Wiley & Sons, Inc., Indianapolis, Indiana
Published simultaneously in Canada
ISBN: 978-1-118-30132-6
ISBN: 978-1-118-30133-3 (ebk)ISBN: 978-1-118-42144-4 (ebk)ISBN: 978-1-118-43394-2 (ebk)
Manufactured in the United States of America
10 9 8 7 6 5 4 3 2 1
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 as permitted under Sections 107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization through payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 646-8600. Requests to the Publisher for permission should be addressed to the Permissions Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030, (201) 748-6011, fax (201) 748-6008, or online at http://www.wiley.com/go/permissions .
Limit of Liability/Disclaimer of Warranty: 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 warranties of fitness for a particular purpose. No warranty may be created or extended by sales or promotional materials. The advice and strategies contained herein may not be suitable for every situation. This work is sold with the understanding that the publisher is not engaged in rendering legal, accounting, or other professional services. If professional assistance is required, the services of a competent professional person should be sought. Neither the publisher nor the author shall be liable for damages arising herefrom. The fact that an organization or Web site 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 Web site may provide or recommendations it may make. Further, readers should be aware that Internet Web sites listed in this work may have changed or disappeared between when this work was written and when it is read.
For general information on our other products and services please contact our Customer Care Department within the United States at (877) 762-2974, outside the United States at (317) 572-3993 or fax (317) 572-4002.
Wiley publishes in a variety of print and electronic formats and by print-on-demand. Some material included with standard print versions of this book may not be included in e-books or in print-on-demand. If this book refers to media such as a CD or DVD that is not included in the version you purchased, you may download this material at http://booksupport.wiley.com . For more information about Wiley products, visit www.wiley.com .
Library of Congress Control Number: 2012942105
Trademarks: Wiley, the Wiley logo, Wrox, the Wrox logo, Programmer to Programmer, and related trade dress are trademarks or registered trademarks of John Wiley & Sons, Inc. and/or its affiliates, in the United States and other countries, and may not be used without written permission. All other trademarks are the property of their respective owners. John Wiley & Sons, Inc., is not associated with any product or vendor mentioned in this book.
This book is dedicated to my wife, business partner, best friend, and all-around support system, Martha. Thank You.
Credits
Executive Editor
Carol Long
Project Editor
Jennifer Lynn
Technical Editor
Chris Ullman
Production Editor
Christine Mugnolo
Copy Editor
San Dee Phillips
Editorial Manager
Mary Beth Wakefield
Freelancer Editorial Manager
Rosemarie Graham
Associate Director of Marketing
David Mayhew
Marketing Manager
Ashley Zurcher
Business Manager
Amy Knies
Production Manager
Tim Tate
Vice President and Executive Group Publisher
Richard Swadley
Vice President and Executive Publisher
Neil Edde
Associate Publisher
Jim Minatel
Project Coordinator, Cover
Katie Crocker
Compositor
Jeff Lytle, Happenstance Type-O-Rama
Proofreader
Nancy Carrasco
Indexer
Johnna VanHoose Dinse
Cover Designer
Ryan Sneed
Cover Image
Daniel Schweinert / iStockPhoto
About the Author
Pascal Rettig is a lifelong programmer who got his start programming by writing BASIC games on the Apple II at the ripe age of 7. Pascal has a Bachelor of Science and a Master of Engineering in computer science and electrical engineering from the Massachusetts Institute of Technology 02 and has been hacking and building stuff on the web since 1995. Pascal built the HTML5 game-based language learning system GamesForLanguage.com in 2011 and is currently a partner at the interactive web agency Cykod. He organizes one of the countrys oldest monthly HTML5 Game Development meetups in Boston each month and runs the HTML5 Game Development news site html5gamedevelopment.org .
About the Technical Editor
Chris Ullman is a senior software developer at MIG, specializing in .NET, and a technical editor/author, who has spent many years stewing in web-related technologies, like a teabag left too long in the pot. Coming from a computer science background, he gravitated toward MS solutions during the summer of ASP (1997). He cut his teeth on Wrox Press ASP guides, and since then he has edited or contributed to more than 30 books, most notably as lead author for Wroxs bestselling Beginning ASP/ASP.NET 1.x/2 series. These days he lives out on the moors of Cornwall and spends his non-computing time running, writing music, and attempting with his wife, Kate, to curb the enthusiasm of three very boisterous children.
Acknowledgments
Id like to thank my wife, Martha, who not only had to put up with me spending every moment of free time I had writing this book (while working on two startups) but also was gracious enough to design all the custom game art used in this book, ensuring that readers arent stuck with the dreaded curse of programmer art.
Id also like to thank my family for supporting me in this endeavor and continuing to accept me as a family member despite my best efforts to lock myself away for the duration.
Id like to particularly thank my editors, Carol Long, Jennifer Lynn, and San Dee Phillips, for helping a newbie author through the process of turning some pages of code into a cohesive book; and technical reviewer Chris Ullman, who did his best to ensure this book made it to print as error-free as possible.
Lastly, Id like to thank the Boston HTML5 Game Development community. Boston has an incredible technology community, and being around such motivated, smart people keeps me learning, energized, and constantly hacking away at new projects.
Introduction
The gaming world and the web have been on a collision course with each other since social games began bringing gaming to the masses and helped make what was once a subculture a mainstream, mass-market phenomenon. Throw mobile into the mix and suddenly you have a massive phenomenon that is going to become more important as more devices get into peoples hands.
Next page