Apress Pro HTML5 Games (2012).pdf

(12761 KB) Pobierz
993007294.002.png
For your convenience Apress has placed some of the front
matter material after the index. Please use the Bookmarks
and Contents at a Glance links to access them.
993007294.003.png 993007294.004.png
Contents at a Glance
About the Author �������������������������������������������������������������������������������������������������������������� xiii
About the Technical Reviewers ����������������������������������������������������������������������������������������� xv
Introduction �������������������������������������������������������������������������������������������������������������������� �� xvii
Chapter 1: HTML5 and JavaScript Essentials
������������������������������������������������������������������� 1
Chapter 2: Creating a Basic Game World
������������������������������������������������������������������������ 19
Chapter 3: Physics Engine Basics
���������������������������������������������������������������������������������� 39
Chapter 4: Integrating The Physics Engine
�������������������������������������������������������������������� �� 65
Chapter 5: Creating the RTS Game World
�������������������������������������������������������������������� �� 101
Chapter 6: Adding Entities to Our World
���������������������������������������������������������������������� �� 125
Chapter 7: Intelligent Unit Movement
�������������������������������������������������������������������������� �� 165
Chapter 8: Adding More Game Elements
��������������������������������������������������������������������� �� 195
Chapter 9: Adding Weapons and Combat
��������������������������������������������������������������������� 231
Chapter 10: Wrapping Up the Single-Player Campaign
������������������������������������������������ 263
Chapter 11: Multiplayer with WebSockets
������������������������������������������������������������������� 293
Chapter 12: Multiplayer Gameplay
������������������������������������������������������������������������������ �� 319
Index�������������������������������������������������������������������������������������������������������������������������������� 341
v
993007294.005.png
Introduction
Welcome to Pro HTML5 Games .
In writing this book, I wanted to create the resource that I wish someone had given me when I was starting out
learning game programming.
Unlike other books with abstract examples that you will never ever use, this book will show you irsthand how
HTML5 can be used to make complete, working games.
I speciically chose a physics engine game and a real-time strategy game as examples because between the two,
these genres encompass all the elements needed to build most of the game types that are popular today.
As you follow along, you will learn all the essential elements needed to create games in HTML5 and then see
how these elements come together to form professional-looking games.
By the end of this book, I hope you will walk away with the conidence and the resources to start making amazing
games of your own in HTML5.
Who his 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 ind a lot of useful information in this book.
If you do not feel conident about your game programming skills, don’t worry. his book covers all the essentials
needed to build these games so you can follow along and learn to design large, professional games in HTML5. he
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, pathinding and steering, combat and efective
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.
How his Book Is Structured
Pro HTML5 Games takes you through the process of building two complete games over the course of 12 chapters.
In the irst four chapters, you will build Froot Wars , a Box2D engine–based physics game similar to the very
popular Angry Birds .
Chapter 1 discusses the basic elements of HTML5 needed to build games, such as drawing and animating on the
canvas, playing audio, and using sprite sheets.
Chapter 2 covers building a basic game framework with splash screens, game menus, an asset loader, and a basic
level with parallax scrolling.
Chapter 3 is a detailed introduction to the Box2D physics engine and shows how Box2D can be used to model a
game world.
Chapter 4 shows how to integrate the game framework with the Box2D engine, add sounds, and add music to
create a complete working physics game.
xvii
993007294.001.png
IntroduCtIon
he second game in the book is an RTS game with both a single-player campaign mode and a multiplayer mode.
You will build the single-player campaign over the next six chapters.
Chapter 5 covers building a basic game framework with splash screens, game menus, an asset loader, and a basic
level with panning using the mouse.
Chapter 6 adds diferent entities such as vehicles, aircraft, and buildings to the game.
Chapter 7 shows how to add intelligent unit movement to the game using a combination of pathinding and
steering steps.
Chapter 8 adds some more elements such as an economy and a trigger-based system that allows scripting events.
Chapter 9 covers implementing a weapons and combat system in the game.
Chapter 10 wraps up the single-player by showing how to create several challenging single-player levels using
the framework developed so far.
Finally, in the last two chapters, you will look at building the multiplayer component of the RTS game.
Chapter 11 discusses the basics of using the WebSocket API with Node.js and creating a multiplayer game lobby.
Chapter 12 covers implementing a framework for multiplayer gameplay using the lock-step networking model
and compensating for network latency while maintaining game synchronization.
Downloading the Code
he code for the examples shown in this book is available on the Apress web site, www.apress.com . You can ind a link
on the book’s information page on the Source Code/Downloads tab. his tab is located underneath the Related Titles
section of the page.
Contacting the Author
Should you have any questions or feedback, you can contact the author through the dedicated page on his
web site at www.adityaravishankar.com/pro-html5-games/ . He can also be reached via e-mail at
xviii
Zgłoś jeśli naruszono regulamin