Chapter 4. Infrastructure

Topics in This Chapter

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

Many aspects of game programming have nothing to do with gameplay. Displaying instructions, pausing games, transitioning between levels, and displaying game credits are just some features that game developers implement besides gameplay. Those features, however, contribute a great deal to the ...

Get Core HTML5 2D Game Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.