Book description
Game programming offers a wealth of creative and business opportunities, and it’s never been more accessible. In Core HTML5 2D Game Programming, best-selling author David Geary shows you how to use freely available browser tools and open source resources to create video games that run in desktop browsers and on mobile devices.
Geary walks you step by step through every aspect of implementing a sophisticated arcade-style game entirely from scratch, without using proprietary game frameworks. Packed with code, this full-color tutorial gives you the in-depth understanding you need to design and build any kind of HTML5 2D game on your own, whether you use a framework or not.
A clearly written, accessible, and exhaustive guide to implementing games, this book leaves no stone unturned, showing you how to
Create smooth, flicker-free animations
Implement motion that’s unaffected by your game’s underlying animation frame rate
Animate sprites (graphical objects) to make them sparkle, explode, etc.
Layer multi-channel sound effects on top of a soundtrack
Warp time to create nonlinear effects, such as jumping or bouncing
Control the flow of time through your game with a time system
Implement particle systems that simulate natural phenomena
Efficiently detect collisions between sprites
Create a developer backdoor containing special features
Use Node.js and socket.io to transfer real-time metrics to a server
Employ a heads-up display to show high scores stored on a server
Understand the nuances of implementing HTML5 games for mobile devices
Through expertly written code that’s easy to understand, and prose that cuts to the chase, Geary illuminates every corner of game development. Everyone from novice game programmers to professional game developers will find this book invaluable as both a tutorial and a reference.
All of the book’s source code, including chapter-specific versions of the game discussed in the book, are available at corehtml5games.com.
Table of contents
- About This eBook
- Title Page
- Copyright Page
- Contents
- Preface
- Acknowledgments
- About the Author
- Chapter 1. Introduction
- Chapter 2. Raw Materials and Development Environment
-
Chapter 3. Graphics and Animation
- 3.1 Draw Graphics and Images with the HTML5 canvas Element
- 3.2 Implement Smooth HTML5 Animations
- 3.3 Implement a Game Loop
- 3.4 Calculate Frame Rates
- 3.5 Scroll the Background
- 3.6 Create Time-Based Motion
- 3.7 Reverse Scroll Direction
- 3.8 Draw Animation Frames
- 3.9 Use Parallax to Create the Illusion of Depth
- 3.10 Conclusion
- 3.11 Exercises
-
Chapter 4. Infrastructure
- 4.1 Encapsulate Game Functions in a JavaScript Object
- 4.2 Understand JavaScript’s Persnickety this Reference
- 4.3 Handle Keyboard Input
- 4.4 Pause or Resume the Game When the Player Presses the p Key
- 4.5 Freeze the Game to Ensure It Resumes Exactly Where It Left Off
- 4.6 Pause the Game When the Window Loses Focus
- 4.7 Resume a Paused Game with an Animated Countdown
- 4.8 Conclusion
- 4.9 Exercises
- Chapter 5. Loading Screens
- Chapter 6. Sprites
- Chapter 7. Sprite Behaviors
- Chapter 8. Time, Part I: Finite Behaviors and Linear Motion
-
Chapter 9. Time, Part II: Nonlinear Motion
- 9.1 Understand Time and Its Derivatives
- 9.2 Use Animation Timers and Easing Functions to Implement Nonlinear Jumping
- 9.3 Implement Animation Timers
- 9.4 Implement Easing Functions
- 9.5 Fine-tune Easing Functions
- 9.6 Implement a Realistic Bounce Behavior
- 9.7 Randomize Behaviors
- 9.8 Implement Nonlinear Color Changes with Animation Timers and Easing Functions
- 9.9 Conclusion
- 9.10 Exercises
- Chapter 10. Time, Part III: Time Systems
-
Chapter 11. Collision Detection
- 11.1 The Collision Detection Process
- 11.2 Collision Detection Techniques
- 11.3 Snail Bait’s Collision Detection
- 11.4 Select Candidates for Collision Detection
- 11.5 Detect Collisions Between the Runner and Another Sprite
- 11.6 Process Collisions
- 11.7 Optimize Collision Detection
- 11.8 Monitor Collision Detection Performance
- 11.9 Implement Collision Detection Edge Cases
- 11.10 Conclusion
- 11.11 Exercises
- Chapter 12. Gravity
- Chapter 13. Sprite Animations and Special Effects
- Chapter 14. Sound and Music
-
Chapter 15. Mobile Devices
- 15.1 Run Snail Bait on Mobile Devices
- 15.2 Detect Mobile Devices
- 15.3 Scale Games to Fit Mobile Devices
- 15.4 Change Instructions Underneath the Game’s Canvas
- 15.5 Change the Welcome Screen
- 15.6 Incorporate Touch Events
- 15.7 Work Around Sound Idiosyncrasies on Mobile Devices
- 15.8 Add an Icon to the Home Screen and Run Without Browser Chrome
- 15.9 Conclusion
- 15.10 Exercises
- Chapter 16. Particle Systems
- Chapter 17. User Interface
-
Chapter 18. Developer Backdoor
- 18.1 Snail Bait’s Developer Backdoor
- 18.2 The Developer Backdoor’s HTML and CSS
- 18.3 Reveal and Hide the Developer Backdoor
- 18.4 Update the Developer Backdoor’s Elements
- 18.5 Implement the Developer Backdoor’s Checkboxes
- 18.6 Incorporate the Developer Backdoor Sliders
- 18.7 Implement the Backdoor’s Ruler
- 18.8 Conclusion
- 18.9 Exercises
-
Chapter 19. On the Server: In-game Metrics, High Scores, and Deployment
- 19.1 Node.js and socket.io
- 19.2 Include socket.io JavaScript in Snail Bait
- 19.3 Create a Simple Server
- 19.4 Create a Socket on the Server
- 19.5 Start the Server
- 19.6 Create a Socket on the Client and Connect to the Server
- 19.7 Record In-game Metrics
- 19.8 Manage High Scores
- 19.9 Deploy Snail Bait
- 19.10 Upload Files to a Server
- 19.11 Conclusion
- 19.12 Exercises
- Chapter 20. Epilogue: Bodega’s Revenge
- Glossary
- Index
Product information
- Title: Core HTML5 2D Game Programming
- Author(s):
- Release date: July 2014
- Publisher(s): Pearson
- ISBN: 9780133564280
You might also like
video
HTML5 2D Game Development
Learn how to implement 2D video games, using the HTML5 Canvas element and HTML5’s support for …
book
Building a 2D Game Physics Engine: Using HTML5 and JavaScript
Build your very own 2D physics-based game engine simulation system for rigid body dynamics. Beginning from …
book
Core HTML5 Canvas: Graphics, Animation, and Game Development
One of HTML5’s most exciting features, Canvas provides a powerful 2D graphics API that lets you …
book
HTML5 Game Development by Example : Beginner's Guide - Second Edition
Make the most of HTML5 techniques to create exciting games from scratch Get to grips with …