SKIP THE SHIPPING
Use code NOSHIP during checkout to save 40% on eligible eBooks, now through January 5. Shop now.
Rough Cuts are manuscripts that are developed but not yet published, available through Safari. Rough Cuts provide you access to the very latest information on a given topic and offer you the opportunity to interact with the author to influence the final publication.
This is the Rough Cut version of the printed book.
Want to start building great web games with HTML5 and JavaScript? Moving from Flash or other game platforms? Already building HTML5 games and want to get better and faster at it? This guide brings together everything you need: expert guidance, sample projects, and working code!
Evan Burchard walks you step-by-step through quickly building 10 popular types of games. Each chapter implements a game within a well-understood genre; introduces a different free, open source, and easy-to-use HTML5 game engine; and is accompanied with full JavaScript source code listings.
Each game recipe uses tested and well-proven patterns that address the development challenges unique to that genre, and shows how to use existing tools and engines to build complete substantial game projects in just hours. Need a quick JavaScript primer? Evan Burchard provides that, too!
Coverage includes
• Mastering an essential HTML5/JavaScript game development toolset: browser, text editor, terminal, JavaScript console, game engine, and more
• Accelerating development with external libraries and proven patterns
• Managing browser differences between IE, Firefox, and Chrome
• Getting up to speed on web development with a QUIZ game built with JavaScript, HTML, CSS, and JQuery
• Creating INTERACTIVE FICTION “gamebooks” that leverage new CSS3 features and impress.js
• Building PARTY games around the lightweight atom.js engine
• Developing PUZZLE games with the easel.js graphics rendering engine
• Writing PLATFORMERS with melon.js and its integrated tilemap editor
• Coding intense 2-player FIGHTING games for web browsers with game.js
• Building a SPACE SHOOTER with the jQuery-based gameQuery game engine
• Implementing pseudo-3D techniques like ray casting for an FPS (First Person Shooter) style game
• Producing a 16 bit RPG (Role Playing Game) complete with interfaces for dialog, inventories, and turn-based battles with enchant.js
• Building an isometric RTS (Real Time Strategy) game that incorporates server components along with node.js, socket.io, and crafty.js
• Engaging players with content that encourages exploration
Turn to The Web Game Developer’s Cookbook for proven, expert answers–and the code you need to implement them. It’s all you need to jumpstart any web game project!
Preface xiv
Acknowledgments xv
About the Author xvi
Introduction 1
Audience for This Book 2
Coding Style Conventions Used In This Book 2
How This Book Is Organized 3
How To Use This Book 4
1 Quiz 5
Recipe: Making the Questions 6
Recipe: Hiding and Showing Your Quiz 12
Recipe: Getting Your Questions Back 14
Recipe: The Shopping List 16
Recipe: Which Answers Are Correct? 21
Summary 24
2 Interactive Fiction (Zork, Choose Your Own Adventure Books) 27
Recipe: Styled Pages 28
Recipe: Goto Page 32
Recipe: Adding an Inventory with Drag and Drop 35
Recipe: Adding Complex Interactions 43
Recipe: Breadcrumb Trail 53
Recipe: A Dramatic Ending 56
Summary 58
3 Party (Rock Band, Mario Party) 59
Recipe: Creating a Sample Game in atom.js 60
Recipe: Drawing with Canvas 65
Recipe: Drawing Holes 67
Recipe: Drawing a Mole 70
Recipe: Putting the Moles in the Holes 73
Recipe: Dynamic Mole Peeking 77
Recipe: Bopping Moles 78
Wallowing in Despair with HTML5’s <audio> tag 82
Summary 84
4 Puzzle (Bejeweled) 85
Recipe: Rendering with easel.js 87
Recipe: Rendering More Than One Thing 91
Recipe: Creating Pairs 95
Recipe: Matching and Removing Pairs 97
Recipe: Hiding and Flipping the Pictures 100
Recipe: Winning and Losing 102
Recipe: Caching and Performance 106
Recipe: Matching Pairs Instead of Duplicates 109
Summary 115
5 Platformer (Super Mario Bros, Sonic the Hedgehog) 117
Getting Started with melon.js 118
Recipe: Creating a Tiled Map 118
Recipe: Starting the Game 120
Recipe: Adding a Character 124
Recipe: Building a Collision Map 127
Recipe: Walking and Jumping 128