Pro HTML5 Games

Book description

Build your next game on a bigger scale with Pro HTML5 Games. This book teaches you the essentials of advanced game programming in HTML5. You'll learn techniques that you can transfer to any area of HTML5 game development to make your own professional HTML5 games!

Led by an expert game programmer, you'll build two complete games in HTML5: a strategy puzzle game based on the Box2d physics engine and in the style of Angry Birds and a real-time strategy (RTS) game complete with units, buildings, path-finding, artificial intelligence, and multiplayer support. In the process, you'll learn how to do the following:

  • Create realistic physics in your game by incorporating the Box2d physics engine

  • Design large worlds with lots of characters and let users interact with them

  • Use sprite sheets, panning, parallax scrolling, and sound effects to build a more polished game

  • Incorporate pathfinding and steering to help characters navigate through your world

  • Create challenging levels with intelligent enemies by using decision trees, state machines, and scripted events

  • Add multiplayer in your games using Node.js and the WebSocket API

  • This book will help you take your HTML5/JavaScript programming experience to the next level. It gives you the knowledge and skills you need to develop more complex, bolder games and become an HTML5 games pro.

    What you'll learn

  • Creating realistic physics in your game by incorporating the Box2d physics engine

  • Designing large worlds with lots of characters and let users interact with them

  • Using sprite sheets, panning, parallax scrolling, and sound effects to build a more polished game

  • Incorporating pathfinding and steering to help characters navigate through your world

  • Creating challenging levels with intelligent enemies by using decision trees, state machines, and scripted events

  • Adding multiplayer in your games using Node.js and the WebSocket API

  • Who this book is for

    Pro HTML5 Games is meant for programmers who already have some HTML and JavaScript programming experience and who now want to learn to harness the power of HTML5 to build amazing-looking games but don't know where to begin.

    Readers who have experience making games in other languages such as Flash and would like to move to HTML5 will also find a lot of useful information in this book.

    If you do not feel confident about your game programming skills, don't worry. This book covers all the essentials needed to build these games so you can follow along and learn to design large, professional games in HTML5. The book will also point to resources and reference material for supplemental learning in case you are having trouble keeping up.

    With dedicated chapters on HTML5 basics, the Box2D engine, pathfinding and steering, combat and effective enemy AI, and multiplayer using Node.JS with WebSockets, you should get a lot from this book no matter how much game programming experience you have.

    Table of contents

    1. Title
    2. Dedication
    3. Contents at a Glance
    4. Contents
    5. About the Author
    6. About the Technical Reviewers
    7. Introduction
    8. Chapter 1: HTML5 and JavaScript Essentials
      1. The canvas Element
      2. The audio Element
      3. The image Element
      4. Animation: Timer and Game Loops
      5. Summary
    9. Chapter 2: Creating a Basic Game World
      1. Basic HTML Layout
      2. Creating the Splash Screen and Main Menu
      3. Level Selection
      4. Loading Images
      5. Loading Levels
      6. Animating the Game
      7. Handling Mouse Input
      8. Defining Our Game States
      9. Summary
    10. Chapter 3: Physics Engine Basics
      1. Box2D Fundamentals
      2. More Box2D Elements
      3. Tracking Collisions and Damage
      4. Drawing Our Own Characters
      5. Summary
    11. Chapter 4: Integrating The Physics Engine
      1. Defining Entities
      2. Adding Box2D
      3. Creating Entities
      4. Adding Entities to Levels
      5. Setting Up Box2D Debug Drawing
      6. Drawing the Entities
      7. Animating the Box2D World
      8. Loading the Hero
      9. Firing the Hero
      10. Ending the Level
      11. Collision Damage
      12. Drawing the Slingshot Band
      13. Changing Levels
      14. Adding Sound
      15. Summary
    12. Chapter 5: Creating the RTS Game World
      1. Basic HTML Layout
      2. Creating the Splash Screen and Main Menu
      3. Creating Our First Level
      4. Loading the Mission Briefing Screen
      5. Implementing the Game Interface
      6. Implementing Map Panning
      7. Summary
    13. Chapter 6: Adding Entities to Our World
      1. Defining Entities
      2. Defining Our First Entity: The Main Base
      3. Adding Entities to the Level
      4. Drawing the Entities
      5. Adding the Starport
      6. Adding the Harvester
      7. Adding the Ground Turret
      8. Adding the Vehicles
      9. Adding the Aircraft
      10. Adding the Terrain
      11. Selecting Game Entities
      12. Highlighting Selected Entities
      13. Summary
    14. Chapter 7: Intelligent Unit Movement
      1. Commanding Units
      2. Sending and Receiving Commands
      3. Processing Orders
      4. Implementing Aircraft Movement
      5. Pathfinding
      6. Defining Our Pathfinding Grid
      7. Implementing Vehicle Movement
      8. Collision Detection and Steering
      9. Deploying the Harvester
      10. Smoother Unit Movement
      11. Summary
    15. Chapter 8: Adding More Game Elements
      1. Implementing the Basic Economy
      2. Purchasing Buildings and Units
      3. Ending a Level
      4. Summary
    16. Chapter 9: Adding Weapons and Combat
      1. Implementing the Combat System
      2. Building Intelligent Enemy
      3. Adding a Fog of War
      4. Summary
    17. Chapter 10: Wrapping Up the Single-Player Campaign
      1. Adding Sound
      2. Building the Single-Player Campaign
      3. Summary
    18. Chapter 11: Multiplayer with WebSockets
      1. Using the WebSocket API with Node.js
      2. Building the Multiplayer Game Lobby
      3. Starting the Multiplayer Game
      4. Summary
    19. Chapter 12: Multiplayer Gameplay
      1. The Lock-Step Networking Model
      2. Ending the Multiplayer Game
      3. Implementing Player Chat
      4. Summary
    20. Index

    Product information

    • Title: Pro HTML5 Games
    • Author(s):
    • Release date: December 2012
    • Publisher(s): Apress
    • ISBN: 9781430247104