Contents

Preface

About the Author

Chapter 1. Introduction

1.1. Snail Bait

1.2. HTML5 Game Development Best Practices

1.3. Special Features

1.4. Snail Bait’s HTML and CSS

1.5. Snail Bait’s Humble Beginning

1.6. The Use of JavaScript in This Book

1.7. Conclusion

1.8. Exercises

Chapter 2. Raw Materials and Development Environment

2.1. Using Developer Tools

2.2. Obtaining Assets

2.3. Using CSS Backgrounds

2.4. Generating Favicons

2.5. Shortening the Coding Cycle

2.6. Conclusion

2.7. Exercises

Chapter 3. Graphics and Animation

3.1. Drawing Graphics and Images with the HTML5 canvas Element

3.2. Implementing Smooth HTML5 Animations

3.3. Implementing a Game Loop

3.4. Calculating Frame Rates

3.5. Scrolling the Background

3.6. Creating Time-Based Motion

3.7. Reversing Scroll Direction

3.8. Drawing Animation Frames

3.9. Using 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

5.1. Define Snail Bait’s Chrome

5.2. Fade Elements In and Out with CSS Transitions

5.3. Fade Any Element In or Out That Has a CSS Transition Associated with Its Opacity

5.4. Implement the Loading Screen

5.5. Reveal the Game

5.6. Conclusion

5.7. Exercises

Chapter 6. Sprites

6.1. Sprite Objects

6.2. Incorporate Sprites into a Game Loop

6.3. Implement Sprite Artists

6.4. Create and Initialize a Game’s Sprites

6.5. Define Sprites with Metadata

6.6. Scrolling Sprites

6.7. Conclusion

6.8. Exercises

Chapter 7. Sprite Behaviors

7.1. Behavior Fundamentals

7.2. Runner Behaviors

7.3. The Runner’s Run Behavior

7.4. Flyweight Behaviors

7.5. Game-Independent Behaviors

7.6. Combining Behaviors

7.7. Conclusion

7.8. Exercises

Chapter 8. Time, Part I: Finite Behaviors and Linear Motion

8.1. Implement an Initial Jump Algorithm

8.2. Shift Responsibility for Jumping to the Runner

8.3. Implement the Jump Behavior

8.4. Time Animations with Stopwatches

8.5. Refine the Jump Behavior

8.6. Implement Linear Motion

8.7. Pause Behaviors

8.8. Conclusion

8.9. Exercises

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 Systems

10.1. Snail Bait’s Time System

10.2. Create and Start the Time System

10.3. Incorporate the Time System into Snail Bait

10.4. Redefine the Current Time for Stopwatches and Animation Timers

10.5. Implement the Time System

10.6. Conclusion

10.7. Exercises

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

12.1. Falling

12.2. Incorporating Gravity

12.3. Collision Detection, Redux

12.4. Conclusion

12.5. Exercises

Chapter 13. Sprite Animations and Special Effects

13.1. Implement Sprite Animations

13.2. Create Special Effects

13.3. Choreograph Effects

13.4. Conclusion

13.5. Exercises

Chapter 14. Sound and Music

14.1. Create Sound and Music Files

14.2. Load Music and Sound Effects

14.3. Specify Sound and Music Controls

14.4. Play Music

14.5. Play Music in a Loop

14.6. Play Sound Effects

14.7. Turn Sound On and Off

14.8. Conclusion

14.9. Exercises

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 Idiosyncracies 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

16.1. Smoking Holes

16.2. Use Smoking Holes

16.3. Implement Smoking Holes

16.4. Pause Smoking Holes

16.5. Conclusion

16.6. Exercises

Chapter 17. User Interface

17.1. Keep Score

17.2. Add a Lives Indicator

17.3. Display Credits

17.4. Tweet Player Scores

17.5. Warn Players When the Game Runs Slowly

17.6. Implement a Winning Animation

17.7. Conclusion

17.8. Exercises

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’s JavaScript in Snail Bait

19.3. Implement 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

20.1. Design the User Interface

20.2. Create the Spritesheet

20.3. Instantiate the Game

20.4. Implement Sprites

20.5. Implement Sprite Behaviors

20.6. Draw the Bullet Canvas

20.7. Implementing Touch-Based Controls for Mobile Devices

20.8. Conclusion

Glossary

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
13.59.197.213