0%

Book Description

Build fully-featured, highly interactive multiplayer games with HTML5

In Detail

Developing an online game can be just as much fun as playing it. However, orchestrating multiple clients and keeping everyone in sync with a game server, reducing and managing network latency (all the while preventing cheating), and making sure every player has an excellent experience can quickly become overwhelming.

This book will teach you how to develop games that support multiple players interacting in the same game world, and show you how to perform network programming operations in order to implement such systems. It covers the fundamentals of game networking by developing a real-time multiplayer game of Tic-tac-toe before moving on to convert an existing 2D single-player snake game to multiplayer, using a more scalable game design for online gaming.

Finally you will be tackling more advanced networking topics, allowing you to handle problems such as server queries from multiple users and making your multiplayer games more secure and less prone to cheating.

What You Will Learn

  • Design games using various multiplayer models
  • Create authoritative game servers
  • Develop game clients that communicate and synchronize with other clients through WebSockets
  • Write responsive multiplayer games using client prediction
  • Upgrade an existing single-player game by adding multiplayer mechanics
  • Use state-of-the-art technologies to make the development process and its end product enjoyable to programmers and amazing to the player
  • Create peer-to-peer gaming using WebRTC

Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.

Table of Contents

  1. Multiplayer Game Development with HTML5
    1. Table of Contents
    2. Multiplayer Game Development with HTML5
    3. Credits
    4. About the Author
    5. About the Reviewers
    6. www.PacktPub.com
      1. Support files, eBooks, discount offers, and more
        1. Why subscribe?
        2. Free access for Packt account holders
    7. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Conventions
      5. Reader feedback
      6. Customer support
        1. Downloading the example code
        2. Downloading the color images of this book
        3. Errata
        4. Piracy
        5. Questions
    8. 1. Getting Started with Multiplayer Game Programming
      1. Understanding the basics of networking
        1. Peer-to-peer networking
        2. Client-server networking
        3. Networking protocols – UDP and TCP
        4. Network sockets
      2. Socket programming in JavaScript
        1. The WebSocket protocol
          1. Creating a client-side WebSocket
      3. Game clients
      4. Game servers
      5. Putting it all together – Tic-tac-toe
        1. Node.js – the center of the universe
          1. The /Player.js class
          2. The /BoardServer.js class
          3. The /server.js class
          4. The /public/js/Board.js class
          5. The /public/js/app.js class
      6. Summary
    9. 2. Setting Up the Environment
      1. JavaScript outside the browser with Node.js
        1. Node.js
        2. Installing Node.js
      2. Writing modular JavaScript
        1. CommonJS
        2. RequireJS
      3. Managing Node.js packages with Npm
      4. Managing frontend packages with Bower
        1. Browserify
      5. Automating your workflow
        1. Grunt
        2. Gulp
      6. Summary
    10. 3. Feeding a Snake in Real Time
      1. Hello world for game development
        1. Setting up the game
          1. package.json
          2. Index.jade
        2. The game modules
          1. Game.js
          2. snake.js
        3. Other supporting modules
          1. app.client.js
      2. The game loop
        1. Frame rate independence
        2. Time-based game loop
        3. Multiple game loops
      3. Implementing an authoritative server
        1. Game server interface
        2. Updating the game client
      4. Understanding the game loop
        1. Game client's game loop
        2. Game server's game loop
      5. Lobby and room system
        1. Implementing the lobby
        2. Implementing the rooms
      6. Matching players within game rooms
        1. Inviting friends into your world
        2. Auto-matching
        3. Skill-based matching
      7. Socket.io
        1. Installing Socket.io
        2. Client-side Socket.io
      8. Summary
    11. 4. Reducing Network Latency
      1. Dealing with network latency
        1. Synchronizing clients in lockstep
      2. Fixed-time step
      3. Synchronizing the clients
      4. Predicting the future with a local game server
        1. Reporting user input
      5. Error correction
        1. Play through the intent, but not the outcome
        2. How close is close enough?
        3. Smooth user experience
      6. Summary
    12. 5. Leveraging the Bleeding Edge
      1. HTML5 – the final frontier
      2. Maximizing your game with the fullscreen mode
      3. Better controlling with gamepad
      4. Peer-to-peer with WebRTC
      5. Capturing the moment with Media Capture
      6. Summary
    13. 6. Adding Security and Fair Play
      1. Common security vulnerabilities
        1. Encryption over the wire
        2. Script injection
        3. Server validation
        4. Artificial intelligence
      2. Building secure games and applications
        1. Authoritative server
        2. Session-based gameplay
        3. Security through obscurity
      3. Reinventing the wheel
        1. Npm install validator
        2. Npm install js-sha512
        3. Npm install closure compiler
      4. Fair play and the user experience
      5. Summary
    14. Index
3.144.172.38