没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
Pro HTML5
Games
Learn to Build your Own Games
using HTML5 and JavaScript
—
Second Edition
—
Aditya Ravi Shankar
Pro HTML5 Games
Learn to Build your Own Games using
HTML5 and JavaScript
Second Edition
Aditya Ravi Shankar
Pro HTML5 Games: Learn to Build your Own Games using HTML5 and JavaScript
Aditya Ravi Shankar
Bangalore, India
ISBN-13 (pbk): 978-1-4842-2909-5 ISBN-13 (electronic): 978-1-4842-2910-1
DOI 10.1007/978-1-4842-2910-1
Library of Congress Control Number: 2017956216
Copyright © 2017 by Aditya Ravi Shankar
This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the
material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation,
broadcasting, reproduction on microfilms or in any other physical way, and transmission or information
storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now
known or hereafter developed.
Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with
every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an
editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark.
The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are
not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to
proprietary rights.
While the advice and information in this book are believed to be true and accurate at the date of publication,
neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or
omissions that may be made. The publisher makes no warranty, express or implied, with respect to the
material contained herein.
Managing Director: Welmoed Spahr
Editorial Director: Todd Green
Acquisitions Editor: Louise Corrigan
Development Editor: James Markham
Technical Reviewer: Gaurav Mishra
Coordinating Editor: Nancy Chen
Copy Editor: Bill McManus
Compositor: SPi Global
Indexer: SPi Global
Artist: SPi Global
Distributed to the book trade worldwide by Springer Science+Business Media New York,
233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail
orders-ny@springer-sbm.com, or visit www.springeronline.com. Apress Media, LLC is a California LLC
and the sole member (owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc).
SSBM Finance Inc is a Delaware corporation.
For information on translations, please e-mail rights@apress.com, or visit http://www.apress.com/
rights-permissions.
Apress titles may be purchased in bulk for academic, corporate, or promotional use. eBook versions and
licenses are also available for most titles. For more information, reference our Print and eBook Bulk Sales
web page at http://www.apress.com/bulk-sales.
Any source code or other supplementary material referenced by the author in this book is available to
readers on GitHub via the book’s product page, located at www.apress.com/9781484229095. For more
detailed information, please visit http://www.apress.com/source-code.
Printed on acid-free paper
Contents at a Glance
About the Author ��������������������������������������������������������������������������������������������������� xiii
About the Technical Reviewer ���������������������������������������������������������������������������������xv
■Chapter 1: HTML5 and JavaScript Essentials �������������������������������������������������������� 1
■Chapter 2: Creating a Basic Game World ������������������������������������������������������������� 21
■Chapter 3: Physics Engine Basics ����������������������������������������������������������������������� 47
■Chapter 4: Integrating the Physics Engine ���������������������������������������������������������� 73
■Chapter 5: Creating a Mobile Game ������������������������������������������������������������������� 115
■Chapter 6: Creating the RTS Game World ���������������������������������������������������������� 137
■Chapter 7: Adding Entities to Our World ������������������������������������������������������������ 167
■Chapter 8: Intelligent Unit Movement ���������������������������������������������������������������� 211
■Chapter 9: Adding More Game Elements ����������������������������������������������������������� 243
■Chapter 10: Adding Weapons and Combat �������������������������������������������������������� 283
■Chapter 11: Wrapping Up the Single-Player Campaign ������������������������������������� 319
■Chapter 12: Multiplayer with WebSockets �������������������������������������������������������� 353
■Chapter 13: Multiplayer Gameplay �������������������������������������������������������������������� 381
■Chapter 14: Essential Game Developer Toolkit �������������������������������������������������� 409
Index ��������������������������������������������������������������������������������������������������������������������� 421
iii
Contents
About the Author ��������������������������������������������������������������������������������������������������� xiii
About the Technical Reviewer ���������������������������������������������������������������������������������xv
■Chapter 1: HTML5 and JavaScript Essentials �������������������������������������������������������� 1
A Basic HTML5 Page �������������������������������������������������������������������������������������������������������� 1
The canvas Element ��������������������������������������������������������������������������������������������������������� 2
Drawing Rectangles �������������������������������������������������������������������������������������������������������������������������������4
Drawing Complex Paths �������������������������������������������������������������������������������������������������������������������������5
Drawing Text ������������������������������������������������������������������������������������������������������������������������������������������� 7
Customizing Drawing Styles (Colors and Textures) �������������������������������������������������������������������������������� 8
Drawing Images ��������������������������������������������������������������������������������������������������������������������������������������9
Transforming and Rotating ������������������������������������������������������������������������������������������������������������������� 11
The audio Element ���������������������������������������������������������������������������������������������������������� 12
The image Element �������������������������������������������������������������������������������������������������������� 15
Image Loading �������������������������������������������������������������������������������������������������������������������������������������� 16
Sprite Sheets ���������������������������������������������������������������������������������������������������������������������������������������� 17
Animation: Timer and Game Loops ��������������������������������������������������������������������������������� 18
requestAnimationFrame �����������������������������������������������������������������������������������������������������������������������19
Summary ������������������������������������������������������������������������������������������������������������������������ 20
■Chapter 2: Creating a Basic Game World ������������������������������������������������������������� 21
Basic HTML Layout ��������������������������������������������������������������������������������������������������������� 21
Creating the Splash Screen and Main Menu ������������������������������������������������������������������ 22
Level Selection ��������������������������������������������������������������������������������������������������������������� 27
Loading Images �������������������������������������������������������������������������������������������������������������� 30
v
剩余431页未读,继续阅读
资源评论
chencourage
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功