100% found this document useful (1 vote)
9 views

The Essential Guide to HTML5: Using Games to Learn HTML5 and JavaScript 3rd Edition Jeanine Meyer download

The document is a promotional and informational piece about 'The Essential Guide to HTML5: Using Games to Learn HTML5 and JavaScript' by Jeanine Meyer, along with links to download the book and other related titles. It includes details about the book's content, structure, and additional resources available for readers. The document also provides copyright information and mentions the availability of source code on GitHub.

Uploaded by

motatomodro
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
9 views

The Essential Guide to HTML5: Using Games to Learn HTML5 and JavaScript 3rd Edition Jeanine Meyer download

The document is a promotional and informational piece about 'The Essential Guide to HTML5: Using Games to Learn HTML5 and JavaScript' by Jeanine Meyer, along with links to download the book and other related titles. It includes details about the book's content, structure, and additional resources available for readers. The document also provides copyright information and mentions the availability of source code on GitHub.

Uploaded by

motatomodro
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 45

The Essential Guide to HTML5: Using Games to

Learn HTML5 and JavaScript 3rd Edition Jeanine


Meyer pdf download

https://ebookmeta.com/product/the-essential-guide-to-html5-using-
games-to-learn-html5-and-javascript-3rd-edition-jeanine-meyer/

Download more ebook from https://ebookmeta.com


We believe these products will be a great fit for you. Click
the link to download now, or visit ebookmeta.com
to discover even more!

Programming 101: Learn to Code Using the Processing


Programming Language, 2nd Edition Jeanine Meyer

https://ebookmeta.com/product/programming-101-learn-to-code-
using-the-processing-programming-language-2nd-edition-jeanine-
meyer/

Build Your Own 2D Game Engine and Create Great Web


Games: Using HTML5, JavaScript, and WebGL2 Kelvin Sung

https://ebookmeta.com/product/build-your-own-2d-game-engine-and-
create-great-web-games-using-html5-javascript-and-webgl2-kelvin-
sung/

Build your own 2D Game Engine and Create Great Web


Games Using HTML5 JavaScript and WebGL 1st Edition
Kelvin Sung Jebediah Pavleas Fernando Arnez Jason Pace

https://ebookmeta.com/product/build-your-own-2d-game-engine-and-
create-great-web-games-using-html5-javascript-and-webgl-1st-
edition-kelvin-sung-jebediah-pavleas-fernando-arnez-jason-pace/

Arithmetic L Functions and Differential Geometric


Methods Regulators IV May 2016 Paris Progress in
Mathematics 338 Pierre Charollois (Editor)

https://ebookmeta.com/product/arithmetic-l-functions-and-
differential-geometric-methods-regulators-iv-may-2016-paris-
progress-in-mathematics-338-pierre-charollois-editor/
Future Grid Scale Energy Storage Solutions Mechanical
and Chemical Technologies and Principles 1st Edition
Ahmad Arabkoohsar

https://ebookmeta.com/product/future-grid-scale-energy-storage-
solutions-mechanical-and-chemical-technologies-and-
principles-1st-edition-ahmad-arabkoohsar/

Galactic Empires Eight Novels of Deep Space Adventure


Patty Jansen M Pax Mark E Cooper Daniel Arenson Chris
Reher David Vandyke Joseph Lallo Felix R Savage

https://ebookmeta.com/product/galactic-empires-eight-novels-of-
deep-space-adventure-patty-jansen-m-pax-mark-e-cooper-daniel-
arenson-chris-reher-david-vandyke-joseph-lallo-felix-r-savage/

Blood of a Gladiator 1st Edition Ashley Gardner

https://ebookmeta.com/product/blood-of-a-gladiator-1st-edition-
ashley-gardner/

The Poetics and Hermeneutics of Pain and Pleasure 1st


Edition Bootheina Majoul

https://ebookmeta.com/product/the-poetics-and-hermeneutics-of-
pain-and-pleasure-1st-edition-bootheina-majoul/

English Grammar in Use Fifth Edition Without Exercises


Raymond Murphy

https://ebookmeta.com/product/english-grammar-in-use-fifth-
edition-without-exercises-raymond-murphy/
Introduction to Internet of Things in Management
Science and Operations Research Implemented Studies
International Series in Operations Research Management
Science 311
https://ebookmeta.com/product/introduction-to-internet-of-things-
in-management-science-and-operations-research-implemented-
studies-international-series-in-operations-research-management-
science-311/
The Essential Guide to
HTML5
Using Games to Learn HTML5
and JavaScript
Third Edition

Jeanine Meyer
The Essential Guide to HTML5: Using Games to Learn HTML5 and JavaScript
Jeanine Meyer
Purchase, NY, USA

ISBN-13 (pbk): 978-1-4842-8721-7 ISBN-13 (electronic): 978-1-4842-8722-4


https://doi.org/10.1007/978-1-4842-8722-4

Copyright © 2023 by Jeanine Meyer


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, Apress Media LLC: Welmoed Spahr
Acquisitions Editor: Divya Modi
Development Editor: James Markham
Coordinating Editor: Divya Modi
Copy Editor: Kim Wimpsett
Cover designed by eStudioCalamar
Cover image designed by Freepik (www.freepik.com)
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@springersbm.
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 booktranslations@springernature.com; for reprint,
paperback, or audio rights, please e-mail bookpermissions@springernature.com.
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 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 https://github.com/Apress/The-Essential-Guide-
to-HTML5-3rd-Edition-by-Jeanine-Meyer. For more detailed information, please visit www.apress.com/
source-code.
Printed on acid-free paper
To Annika, Daniel, Aviva, and Anne, and to Esther and Joseph,
who are still in our lives.
Table of Contents
About the Author����������������������������������������������������������������������������������������������������� xi

About the Technical Reviewer������������������������������������������������������������������������������� xiii


Acknowledgments���������������������������������������������������������������������������������������������������xv

Introduction�����������������������������������������������������������������������������������������������������������xvii

Chapter 1: The Basics����������������������������������������������������������������������������������������������� 1


Keywords�������������������������������������������������������������������������������������������������������������������������������������� 1
Introduction����������������������������������������������������������������������������������������������������������������������������������� 1
Critical Requirements������������������������������������������������������������������������������������������������������������������� 4
HTML5, CSS, and JavaScript Features������������������������������������������������������������������������������������������ 4
Basic HTML Structure and Tags���������������������������������������������������������������������������������������������������� 4
Using Cascading Style Sheets���������������������������������������������������������������������������������������������������� 10
JavaScript Programming������������������������������������������������������������������������������������������������������������ 14
Using a Text Editor���������������������������������������������������������������������������������������������������������������������� 16
Building the Applications������������������������������������������������������������������������������������������������������������ 19
Testing and Uploading the Application���������������������������������������������������������������������������������������� 25
Summary������������������������������������������������������������������������������������������������������������������������������������ 26

Chapter 2: Dice Game��������������������������������������������������������������������������������������������� 27


Introduction��������������������������������������������������������������������������������������������������������������������������������� 27
Critical Requirements����������������������������������������������������������������������������������������������������������������� 30
HTML5, CSS, and JavaScript Features���������������������������������������������������������������������������������������� 31
Pseudorandom Processing and Mathematical Expressions������������������������������������������������������� 32
Variables and Assignment Statements��������������������������������������������������������������������������������������� 33
Programmer-Defined Functions�������������������������������������������������������������������������������������������������� 35
Conditional Statements: if and switch���������������������������������������������������������������������������������������� 37
v
Table of Contents

Drawing on the Canvas��������������������������������������������������������������������������������������������������������������� 40


Displaying Text Output Using a Form������������������������������������������������������������������������������������������ 51
Building the Application and Making It Your Own����������������������������������������������������������������������� 52
Throwing a Single Die����������������������������������������������������������������������������������������������������������������� 54
Throwing Two Dice���������������������������������������������������������������������������������������������������������������������� 61
The Complete Game of Craps����������������������������������������������������������������������������������������������������� 68
Making the Application Your Own����������������������������������������������������������������������������������������������� 76
Testing and Uploading the Application���������������������������������������������������������������������������������������� 78
Summary������������������������������������������������������������������������������������������������������������������������������������ 79

Chapter 3: Bouncing Ball���������������������������������������������������������������������������������������� 81


Introduction��������������������������������������������������������������������������������������������������������������������������������� 81
Critical Requirements����������������������������������������������������������������������������������������������������������������� 86
HTML5, CSS, and JavaScript Features���������������������������������������������������������������������������������������� 87
Drawing a Ball or an Image or Images���������������������������������������������������������������������������������������� 88
Gradients with a Side Trip to Explain Arrays������������������������������������������������������������������������������� 91
Setting Up a Timing Event����������������������������������������������������������������������������������������������������������� 96
Calculating a New Position and Collision Detection�������������������������������������������������������������������� 98
Starting, Positioning and Restarting the video with use of an anonymous function����������� 102
Validation���������������������������������������������������������������������������������������������������������������������������������� 102
Stopping and Resuming Animation Triggered by Buttons��������������������������������������������������������� 104
HTML Page Reload�������������������������������������������������������������������������������������������������������������������� 105
Preloading Images�������������������������������������������������������������������������������������������������������������������� 105
Building the Application and Making It Your Own��������������������������������������������������������������������� 106
Testing and Uploading the Application�������������������������������������������������������������������������������������� 129
Summary���������������������������������������������������������������������������������������������������������������������������������� 130

Chapter 4: Cannonball and Slingshot������������������������������������������������������������������� 131


Introduction������������������������������������������������������������������������������������������������������������������������������� 131
Critical Requirements��������������������������������������������������������������������������������������������������������������� 135
HTML5, CSS, and JavaScript Features�������������������������������������������������������������������������������������� 136
Arrays and Programmer-Defined Objects��������������������������������������������������������������������������������� 137
vi
Table of Contents

Rotations and Translations for Drawing������������������������������������������������������������������������������������ 139


Drawing Line Segments������������������������������������������������������������������������������������������������������������ 145
Mouse Events for Pulling on the Slingshot������������������������������������������������������������������������������� 147
Changing the List of Items Displayed Using Array Splice��������������������������������������������������������� 149
Distance Between Points���������������������������������������������������������������������������������������������������������� 150
Building the Application and Making It Your Own��������������������������������������������������������������������� 151
Cannonball: With Cannon, Angle, and Speed����������������������������������������������������������������������������� 158
Slingshot: Using a Mouse to Set Parameters of Flight�������������������������������������������������������������� 168
Testing and Uploading the Application�������������������������������������������������������������������������������������� 179
Summary���������������������������������������������������������������������������������������������������������������������������������� 180

Chapter 5: The Memory (aka Concentration) Game���������������������������������������������� 181


Introduction������������������������������������������������������������������������������������������������������������������������������� 181
Critical Requirements��������������������������������������������������������������������������������������������������������������� 188
HTML5, CSS, JavaScript Features��������������������������������������������������������������������������������������������� 189
Representing Cards������������������������������������������������������������������������������������������������������������������� 190
Using Date for Timing���������������������������������������������������������������������������������������������������������������� 191
Providing a Pause��������������������������������������������������������������������������������������������������������������������� 192
Drawing Text����������������������������������������������������������������������������������������������������������������������������� 193
Drawing Polygons��������������������������������������������������������������������������������������������������������������������� 196
Shuffling Cards������������������������������������������������������������������������������������������������������������������������� 198
Implementing Clicking on a Card���������������������������������������������������������������������������������������������� 199
Preventing Certain Types of Cheating��������������������������������������������������������������������������������������� 200
Building the Application and Making It Your Own��������������������������������������������������������������������� 201
Testing and Uploading the Application�������������������������������������������������������������������������������������� 223
Summary���������������������������������������������������������������������������������������������������������������������������������� 224

Chapter 6: Quiz����������������������������������������������������������������������������������������������������� 225


Introduction������������������������������������������������������������������������������������������������������������������������������� 225
Critical Requirements for a Quiz Game������������������������������������������������������������������������������������� 230
HTML5, CSS, and JavaScript Features�������������������������������������������������������������������������������������� 231

vii
Table of Contents

Storing and Retrieving Information in Arrays���������������������������������������������������������������������������� 231


Creating HTML During Program Execution�������������������������������������������������������������������������������� 234
Using CSS in the Style Element������������������������������������������������������������������������������������������������ 236
Responding to Player Moves����������������������������������������������������������������������������������������������������� 237
Presenting Audio and Video������������������������������������������������������������������������������������������������������ 238
Checking the Player’s Answer��������������������������������������������������������������������������������������������������� 240
Building the Application and Making It Your Own��������������������������������������������������������������������� 241
Testing and Uploading the Application�������������������������������������������������������������������������������������� 252
Summary���������������������������������������������������������������������������������������������������������������������������������� 253

Chapter 7: Mazes�������������������������������������������������������������������������������������������������� 255


Keywords���������������������������������������������������������������������������������������������������������������������������������� 255
Introduction������������������������������������������������������������������������������������������������������������������������������� 255
Critical Requirements��������������������������������������������������������������������������������������������������������������� 263
HTML5, CSS, and JavaScript Features�������������������������������������������������������������������������������������� 264
Representation of Walls and the Token������������������������������������������������������������������������������������� 264
Mouse Events to Build and Position a Wall������������������������������������������������������������������������������� 265
Detecting the Arrow Keys���������������������������������������������������������������������������������������������������������� 266
Collision Detection: Token and Any Wall������������������������������������������������������������������������������������ 268
Using Local Storage������������������������������������������������������������������������������������������������������������������ 271
Encoding Data for Local Storage����������������������������������������������������������������������������������������������� 279
Radio Buttons���������������������������������������������������������������������������������������������������������������������������� 281
Building the Application and Making It Your Own��������������������������������������������������������������������� 282
Creating the Travel Maze Application���������������������������������������������������������������������������������������� 295
Testing and Uploading Application�������������������������������������������������������������������������������������������� 306
Summary���������������������������������������������������������������������������������������������������������������������������������� 307

Chapter 8: Rock, Paper, Scissors�������������������������������������������������������������������������� 309


Introduction������������������������������������������������������������������������������������������������������������������������������� 309
Critical Requirements��������������������������������������������������������������������������������������������������������������� 313
HTML5, CSS, and JavaScript Features�������������������������������������������������������������������������������������� 314

viii
Table of Contents

Providing Graphical Buttons for the Player������������������������������������������������������������������������������� 314


Generating the Computer Move������������������������������������������������������������������������������������������������ 319
Displaying Results Using Animation������������������������������������������������������������������������������������������ 325
Audio and DOM Processing������������������������������������������������������������������������������������������������������� 329
Starting Off�������������������������������������������������������������������������������������������������������������������������������� 331
Building the Application and Making It Your Own��������������������������������������������������������������������� 332
Testing and Uploading the Application�������������������������������������������������������������������������������������� 342
Summary���������������������������������������������������������������������������������������������������������������������������������� 343

Chapter 9: Guess a Word�������������������������������������������������������������������������������������� 345


Introduction������������������������������������������������������������������������������������������������������������������������������� 345
Critical Requirements��������������������������������������������������������������������������������������������������������������� 352
HTML5, CSS, and JavaScript Features�������������������������������������������������������������������������������������� 353
Storing a Word List as an Array Defined in an External Script File������������������������������������������� 353
Generating and Positioning HTML Markup, Then Changing the Markup to Buttons,
and Then Disabling the Buttons������������������������������������������������������������������������������������������������ 354
Creating the Feedback About Remaining Wrong Letters���������������������������������������������������������� 358
Maintaining the Game State and Determining a Win or Loss���������������������������������������������������� 359
Checking a Guess and Revealing Letters in the Secret Word by Setting textContent��������������� 360
Building the Application and Making It Your Own��������������������������������������������������������������������� 361
Testing and Uploading the Application�������������������������������������������������������������������������������������� 371
Summary���������������������������������������������������������������������������������������������������������������������������������� 371

Chapter 10: Blackjack������������������������������������������������������������������������������������������ 373


Introduction������������������������������������������������������������������������������������������������������������������������������� 373
Critical Requirements��������������������������������������������������������������������������������������������������������������� 380
HTML5, CSS, and JavaScript Features�������������������������������������������������������������������������������������� 381
Source for Images for Card Faces and Setting Up the Image Objects�������������������������������������� 381
Creating the Programmer-Defined Object for the Cards����������������������������������������������������������� 382
Starting a Game������������������������������������������������������������������������������������������������������������������������ 383
Dealing the Cards���������������������������������������������������������������������������������������������������������������������� 384
Shuffling the Deck�������������������������������������������������������������������������������������������������������������������� 389

ix
Table of Contents

Capturing Key Presses�������������������������������������������������������������������������������������������������������������� 390


Using Header and Footer Element Types���������������������������������������������������������������������������������� 392
Building the Application and Making It Your Own��������������������������������������������������������������������� 393
Testing and Uploading the Application�������������������������������������������������������������������������������������� 409
Summary���������������������������������������������������������������������������������������������������������������������������������� 410

Appendix: More Techniques for Drawing�������������������������������������������������������������� 411


C
 ircles and Arrows�������������������������������������������������������������������������������������������������������������������� 411
Overview������������������������������������������������������������������������������������������������������������������������������ 413
Details of Implementation��������������������������������������������������������������������������������������������������� 414
What You Learned���������������������������������������������������������������������������������������������������������������� 430
Crossing a Line (Jumping a Fence)������������������������������������������������������������������������������������������� 430
Overview������������������������������������������������������������������������������������������������������������������������������ 434
Details of Implementation��������������������������������������������������������������������������������������������������� 438
U
 sing Scalar Vector Graphics���������������������������������������������������������������������������������������������������� 451
Using SVG to Draw the HTML5 Logo����������������������������������������������������������������������������������������� 452
Overview������������������������������������������������������������������������������������������������������������������������������ 456
Details of Implementation��������������������������������������������������������������������������������������������������� 457
Using SVG to Draw and Modify a Cartoon��������������������������������������������������������������������������������� 465
Overview������������������������������������������������������������������������������������������������������������������������������ 466
Details of Implementation��������������������������������������������������������������������������������������������������� 467

Index��������������������������������������������������������������������������������������������������������������������� 479

x
About the Author
Jeanine Meyer is a professor emerita at Purchase College/
SUNY and past coordinator of the Mathematics/Computer
Science Board of Study. Before Purchase, she taught at
Pace University and before that worked as a research staff
member and manager in robotics and manufacturing
research at IBM Research and as a consultant for IBM’s
educational grant programs. She is the author or coauthor
of ten books on topics such as educational uses of multimedia, programming (three
published by Apress/Springer), databases, number theory, and origami.
She earned a PhD in computer science at the Courant Institute at New York
University, an MA in mathematics at Columbia University, and an SB (the college used
the Latin form) in mathematics from the University of Chicago. She is a member of Phi
Beta Kappa, Sigma Xi, Association for Women in Science, and Association for Computing
Machinery, and was a featured reviewer for ACM Computing Reviews.
For Jeanine, programming is both a hobby and a vocation. Every day she plays
computer puzzles online (including Words with Friends, various solitaire card games,
and Duolingo for Spanish, which she views as a game). She also participates in Daf
Yomi, the seven-and-a-half-year study of Talmud, which certainly has puzzle-solving
aspects. She tries The New York Times crossword puzzle many days but does better at the
mini-puzzle, KenKen, and Two Not Touch, in which she sometimes competes with her
children. She enjoys cooking, baking, eating, gardening, travel, and a moderate amount
of walking. She misses her mother, who inspired many family members to take up
piano, and her father, who gave Jeanine a love of puzzles. She is an active volunteer for
progressive causes and candidates.

xi
About the Technical Reviewer
Vadim Atamanenko is a software developer with more
than 20 years of experience. He participates in international
hackathons both as a judge and as a mentor and is a member
of the Harvard Square Business Association.
He has developed many complex solutions in various
business areas that have helped thousands of people
automate manual processes.
Currently he is the CIO at Freedom Holding Corp., but
he still finds time to regularly participate in international IT
conferences.
He enjoys meeting new people and sharing his knowledge. If you have a question for
him, visit https://www.linkedin.com/in/vadim-­atamanenko/.

xiii
Acknowledgments
Much appreciation to my students and colleagues at Purchase College/State University
of New York for their inspiration, stimulation, and support; and to family and friends
who indulge me in my use of family photos and video clips for my courses and my books.
Thanks to the crew at Apress and Springer for all their efforts.

xv
Introduction
When it was first released, there was considerable enthusiasm about the new capabilities
of HTML5, and even suggestions that no other technologies or products are necessary to
produce dynamic, engrossing, interactive websites. The excitement has not gone away,
and the new features are still exciting. HTML is HTML5. It now is possible, using just
HTML, Cascading Style Sheets, and JavaScript, to draw lines, arcs, circles, and ovals on
the screen and specify events and event handling to produce animation and respond to
user actions. You can include video and audio on your website with standard controls,
and you can include the video or audio in your application exactly when and where
needed. You can create forms that validate the input and provide immediate feedback
to users. You can use a facility similar to cookies to store information on the client
computer. And you can use new elements, such as headers and footers, to help structure
your documents. HTML, CSS, and JavaScript work together. You can use JavaScript to
create new HTML elements, and this is helped by what can be done with CSS.
This book is based on my teaching practices and past writings. Delving into the
features of a technology or general programming concepts is best done when there is a
need and a context. Games, especially familiar and simple ones, supply the context and
thus the motivation and much of the explanation. When learning a new programming
language, one of my first steps is to program the game of craps. Also, if I can build a
ballistics simulation with animation, such as the slingshot game, and make a video
or audio clip play when a specific condition occurs, I am happy. If I can construct my
own maze of walls, determine ways to provide visual as well as text feedback, and store
information on the player’s computer, I am ecstatic. That’s what we will do in this book.
As you learn how to build these simple games, you’ll build your expertise as well. I hope
you go on to make your own exciting, compelling applications.
This goal of this book, developed with considerable help from the Apress staff and
the technical reviewers, is to introduce you to programming, with the motivation of
implementing interactive websites to share with others.

xvii
Introduction

• At the time of updating this book, browser support for HTML5


features is close to complete. The applications have been tested using
Chrome and Safari. However, it is important to keep in mind that
browsers can change.

• My focus is on plain HTML and JavaScript because it has been my


experience that knowledge and experience with the basics is the
best introduction. Frameworks and libraries exist and continue to be
developed and refined, and at some point, these tools are appropriate
to study. This is especially true if you work in an organization that
has adopted specific tools. You can turn to these topics after getting
comfortable with the basics. Note that I have updated my HTML5
and JavaScript Projects book, which is a step up from this one in level
of complexity.

Who Is This Book For?


This book is for people who want to learn how HTML, JavaScript, and Cascading Style
Sheets can serve to build dynamic, exciting websites. It’s for you if you know something
about programming and want to see what the current versions of HTML and JavaScript
offer. It’s also for you if you have no programming experience whatsoever. Perhaps you’re
a web designer or website owner and you want to know how to make things happen
behind the scenes or how to request features from programmers.
With this book, we want to showcase the new(er) features of HTML5 and demystify
the art of programming. Programming is an art, and creating appealing games and
other applications requires talent and attention to the audience. However, if you can put
together words to form sentences and put together sentences to form paragraphs, then
you can program.

How Is This Book Structured?


The book consists of ten chapters plus an appendix, each organized around a familiar
game or similar application. There is considerable redundancy in the chapters, so you can
skip around if you like, though the games do get more complex as the book progresses.
Each chapter starts by describing the application and listing the technical features and
programming concepts that will be covered. We look first at the critical requirements in a
xviii
Introduction

general sense: what we need to implement the application, independent of any specific
technology. We then focus on the features of HTML5, JavaScript, Cascading Style Sheets, and
general programming methodologies that satisfy the requirements. Finally, we examine the
implementation of each application in detail. I break out the code line by line in a table, with
comments next to each line. In the cases where multiple versions of a game are described,
only the new lines of code may be explained in detail. This isn’t to deprive you of information
but to encourage you to see what is similar and what is different, and to demonstrate how
you can build applications in stages. It certainly is appropriate to consult the commented
programs on an as-­needed basis. Each chapter includes suggestions on how to make the
application your own and how to test and upload the application to a website. The summary
at the end of each chapter highlights what you’ve learned and what you’ll find ahead.
The appendix was added in this edition to provide more advanced examples of
creating and manipulating graphics on the screen using algebra and geometry and
Scalar Vector Graphics images.

Conventions Used in This Book


The applications in this book are HTML documents. The JavaScript is in a script
element in the head element, and the CSS is in the style element in the head element.
The body element contains the static HTML, including any canvas elements. Several
examples depend on external image files, and one example requires external video files
and audio files and another external audio files.

Layout Conventions
To keep this book as clear as possible, the following text conventions are used throughout:

• Code is presented in fixed-width font.

• The complete code for each application is presented in a table, with


each statement explained with a comment.

• Pseudocode is written in italic fixed-width font.


• Sometimes code won’t fit on a single line in a book. Where this
happens, I use an arrow like this: ↪.

So, with these formalities out of the way, let’s get started.
xix
Another Random Scribd Document
with Unrelated Content
With the restoration of the Bourbons in 1815, the French
romantic school of literature was ushered into existence; the three
Coriphaes of which were De Lavigne, De Lamartine, and
Chateaubriand. Schiller, Young, and Milton, seemed to have been
their models; but the modern prose writers soon followed the lyric
poets in their imitations of the romantic schools of England and
Germany; and we have since had French pupils of Fielding, Smollet,
Hoffmann, and Jean Paul Richter. Eugene Sue at first imitated
Fennimore Cooper; but he soon gave into the “tendency novels,” on
the Miss Martineau style of treating political and domestic economy.
But his great genius, and the rich resources of his imagination, soon
made him shoot by his dull originals, and he has since grappled
successfully with religion, morals, and politics; in all which combats
he may be said to have come out victorious; for he has nearly, if not
altogether, annihilated his antagonists.
The Feuilleton literature which has grown in proportion to the
decline of essays and memoirs, has opened a new field to the
romantic pens of France, and has made that style of writing popular
with the masses. Since then the abuse of it has passed all bounds;
half a dozen writers have absorbed the Feuilletons of all the large
sheets published in the capital—so that talents less known and
appreciated must content themselves with some feudal tenure under
one of these literary lords; for it must not be imagined that writers
like Sue, Alexandre Dumas, Soulié, &c., do their own works, or are
put to the necessity of even inventing the incidents of their stories.
All this is done for them by their literary vassals, who work for five
francs a day, while their masters, who occasionally correct the
phraseology of some chapter, but whose principal business it is,
when matters come to a crisis, to furnish the dénouement and the
conclusion, to which they put their name, receive hundreds of
thousands for their contributions.
But what the feudal writers of the romantic school of France have
not attempted till lately was to imitate Shakspeare on the stage.
Hitherto the modern dramas of Victor Hugo were more in the melo-
dramatic line, and as such admirably adapted to the taste of the
frequenters of the theatre de la Porte St. Martin. But Victor Hugo
was a brave man, and with the popularity acquired among the
masses, soon forced his way to the French academy, as Lucien
Bonaparte, at the head of his grenadiers, forced the legislative
assembly of the republic to close its sessions. He got in and seated
himself, and has since had strength enough to draw some of his best
friends after him, notwithstanding all the opposition of the classic
Molé, who has even pronounced a discourse against Alfred de Vigny.
Alexandre Dumas, the Créol of the Isle of Bourbon (the French
use the term Créol as a sort of embellishment to a Mulatto) is the
greatest literary factotum of France now living. He imitates every
thing—history, comedy, tragedy, novels, and romance, and will with
great difficulty be kept from “the forty” qui en savant comme quatre.
[1]
His Monte Christo is an imitation of “The Wandering Jew;” his Age
of Louis XIV. and XV., an important commentary on Voltaire; but his
chef d’œuvre we have now before us;—it is nothing less than a new
version of Shakspeare’s Hamlet!
The present Feuilleton literature of France is, properly speaking,
the commercial or shop-keeper literature of the day, in which a few
thoughts abstracted from some greater works are carefully spun out
and disposed of at retail prices; or, to use a still better figure, a
ragout with all sorts of spices, but made from a piece of meat which
has served to appease the appetite of hundreds. There is a perfect
dearth of ideas in all of them, and a morbid desire for ornament.
The form is everywhere more valuable than the substance—the
elegance of style superior to the naked thought. It is the process of
the gold-beater, who, with a single grain of that precious metal,
covers the backs of a whole library.
The taste for Shakspeare is, in France, of recent origin. Since the
performance of Macready on the French boards, Parisian audiences
have become acquainted with ghosts, witches, and the whole
laboratory of philosophical superstition in which the British bard
surpassed all others, ancient and modern. Still Shakspeare remained
unintelligible or unpalatable to many, notwithstanding the learned
reviews of the Revue de deux Mondes, and the Revue de Paris, both
of which strove to show that though in point of abstract genius
Shakspeare may have possessed more than Racine, Voltaire, and
Corneille put together, still he lacked that scenic arrangement, and
that peculiar close connection between cause and effect which
distinguishes the dramatic works of France. “Shakspeare’s Hamlet is
a philosophical dissertation,” said a French writer, “in a dramatic
form.” “There is no reason for Hamlet’s madness”—“none in the
world for Ophelia’s ravings, who ought to spurn the taunts and
insults of her coward lover,” &c.
All these criticisms have moved Alexandre Dumas to try his hand
at the work, and to correct the logic and dramatic arrangement of
“the British savage, who occasionally found a pearl on a dunghill.”
The work of the French Creole is admirable of its kind; but equally
“unintelligible” in regard to the scenic arrangements. Hamlet is as
much a coward in the French play as he is in the English, only a little
less philosophical; and instead of Laertes and the king being killed,
the queen poisoned, and what not, the ghost takes charge of eternal
justice and finishes them off himself. Why he does not do so, in the
first act, immediately after his appearance, is an enigma; but as that
would have saved the remaining four acts—which would not have
answered the views of Alexandre Dumas—it was necessary that
Hamlet—the only character who survives in the French play—should
do some courting, and the queen and king some talking and
feasting, all according to the rules of the French drama. We cannot
refrain, by way of a rich treat, from giving the readers of the
magazine the closing scene of Dumas’s play. It will speak for itself,
and save us the necessity of further comment.

[1] The Calembourg perpetrated by Piron, who was


never admitted a member of the Academy.

Hamlet, the Ghost, the King, Laertes, Gertrude,


Courtiers.

Hamlet. L’ombre! l’ombre!


Viens voir tes meurtriers mourir, fantôme sombre!
King. (Under Hamlet’s hand.) A l’aide!
Hamlet. (To the Courtiers on a sign of the Ghost.)
Laissez-nous.
(Hesitation among the Courtiers.)
Il n’en ferait pas deux! Le feu roi, n’est ce pas?
Roi de votre existence et de votre agonie?
Il sied qu’entre nous cinq la pièce soit finis.
Sortez—tous! (All intimidated slowly leave the stage.)
A présent, vous trois, le voyez-vous?
Laertes. Dieu puissant! Le roi mort!
King. Mon père!
Gertrude. Mon époux!
Laertes. Grâce!
Ghost. Oui ton sang, trop prompt t’entraina vers l’abîme,
Laërte, et le seigneur t’a puni pour ton crime;
Mais, tu le trouveras; car il sonde les cœurs,
Moins sévère là-haut. Laërte prie et meurs.
(Laertes dies.)
Gertrude. Pitié! Pitié!
Ghost. Ta faute était ton amour même
Pauvre femme! et Jésu vous aime quand on aime!
Va, ton cœur a lavé ta honte avec tes pleur;
Femme ici, reine au ciel, Gertrude éspère et meurs.
(Gertrude dies.)
King. Pardon!
Ghost. Pas de pardon! va meurtrier infâme
Va; pour ton crime affreux, dans leur circle de flamme
Satan et les enfers n’ont pas trop de douleur;
Va, traitre incestueux, va!—désespère et meurs!
(King dies.)
Hamlet. Et moi, vais-je rester triste orphelin sur terre,
Et respirer, cet air imprégné de misère?
Tragédien choisi pour le courroux de Dieu,
Si j’ai mal pris mon rôle, et mal saisi mon jeu,
Si, tremblant de mon œuvre, et lassé sans combattre,
Pour un que tu voulais j’en ai fait mourir quatre,
Oh! parle, est-ce que Dieu ne pardonnera pas:
Père, et quel châtiment m’attend donc?
Ghost. Tu vivra!

One can see that Dumas snatches a grace beyond the reach of
the usual drama. The ghost acts the part of the Lord’s messenger,
and pronounces sentence on each culprit. The queen is “a woman
here,” and “an angel there;” because she loved much—the king is
too well served in going to the devil, Laertes dies with some hope of
salvation; but Hamlet lives to repent of his sins; having by his
cowardice killed four persons instead of one! This is French stage
logic. As to the language it is the most trite and commonplace, that
one can hear in front of the theatre from the hackmen; and the
tragic muse is certainly not that one of the hallowed nine which
particularly favors the author of Monte Christo.
F. J. G.
THE GLEANER.
She stands, as radiant as the morn
When rosy splendors fill the air:
Her white arms hold the golden corn,
Itself less glowing than her hair.

She stands, a simple peasant girl,


Yet lovelier than the proudest queen;
For wreathing smile and glossy curl
More potent are than jeweled sheen.
E. M. S.
Engd by Rawdon, Wright & Hatch

The Gleaner.
Engraved expressly for Graham’s Magazine
REVIEW OF NEW BOOKS.

Christine, and Other Poems. By Thomas Buchanan Read.


Boston: Wm. D. Ticknor & Co. 1 vol. 12mo.

This is a volume to make “the cold reviewer’s rhyme-freezing


face,” melt into smiles. It is the production of a young painter, who
has already won an honorable reputation as an artist. Several of the
poems have been printed in various periodicals, and in that form
attracted considerable attention: but the majority, we believe, are
now published for the first time. They evince refinement of thought
and sentiment, richness and warmth of fancy, and singular delicacy
and strength in the use of language. Perhaps the finest characteristic
of their diction is the feeling they display of the harmony of sound
and color, in the expression of thought and emotion. The music of
the verse corresponds to the imagery which flushes through it, and
thus the figures which the poet’s prolific fancy conjures up, are all
endowed with life and motion—or rather seem to make the harmony
in which they move. His thoughts and sentiment give continual
evidence of being born in music. This is a test which few rhymes will
bear, and of itself proves the possession of the true poetic feeling.
The poetry of Mr. Read is essentially musical thought.
Among the excellent pieces contained in this volume, we would
call the attention of our readers to the dreamy beauty of Christine
and the Bride of Dottenburg—the elevated feeling which animates
the dilating imaginations of the sonnet “To the Master Bards”—the
mystical charm of The Winnower, Inez, Arise, The Twins, the Windy
Night—and the pensive beauty and sweetness of A Leaf From the
Past and Sunlight on the Threshold. Throughout the volume is
manifested an imagination to discern and express the poetical
aspects of things. We hope that a collection of poems so rich in
thought and feeling, and richer still in promise, will have the
extended circulation it merits.

Dealings with the Firm of Dombey and Son, Wholesale,


Retail, and for Exportation. By Charles Dickens. With
Illustrations by H. K. Browne. New York: Wiley &
Putnam.

From the numbers already published of this new novel by


Dickens, we think it promises to be one of the most entertaining of
his works. With some drawback on the excellence of the
characterization, arising from his desire to produce startling comic
effects, the characteristics of the work are the same as those
displayed in the others, and they are as good. Mr. Dombey is
overcharged in the delineation almost to caricature, but he still
vividly suggests the character intended to be hit. The class to which
he belongs richly deserves satire, as pomposity is as habitual a vice
in a large number of Englishmen as the hypocrisy of Pecksniff. Miss
Tox promises to be as interesting as Miss Miggs, in “Barnaby Rudge.”
Mrs. Chick will give room for much satire on the obvious hypocrisies
of character. Polly Richards is a grand portrait, overflowing with
humanity, and true to the first principles of the heart. Miss Nipper is
a good specimen of the snappish domestic, proudly vulgar and
insolently low. Florence, the heroine, is an exquisite creation, not yet
fully developed, but as promising almost as Little Nell. Walter is
capital, and will go directly to the heart of all boys of spirit. The
other characters are of various degrees of merit and originality, but
all add something to the interest of the work.
The peculiar humor of Dickens, or his power of blending satire
wit, fancy and humor together, is very prominent in “Dombey and
Son.” His pathos is no less observable. The felicities of expression
scattered over the narrative, would alone reward its patient perusal.
The style of Dickens is worthy of study for its beautiful and sparkling
peculiarities. It is one of the most original in English literature, and is
the exact measure of his genius. His qualities as a novelist cannot be
disconnected from his style. A criticism of his diction involves a
statement of all his powers and peculiarities, for they interpenetrate
it, and give it all its life and character.

Nell Gwynne: or the Court of the Stuarts. An Historical


Romance. By W. Harrison Ainsworth: Philada. Carey &
Hart.

Ainsworth is well known as the most prominent of the English


novelists of intrigue, rascality, and horror. In the present work he has
a fine subject for his peculiar powers—the delineation of the court of
Charles II.—a good-natured rascal, who bartered away the interests
and honor of England for money and mistresses, and who was
surrounded by companions worthy of himself. Nell Gwynne was one
of the least vixenish of his mistresses, and she is the heroine of Mr.
Ainsworth’s novel. The opening scene of the book is appropriately
laid in “The Devil’s Alley;” and through this alley most of the
characters go. Mr. Ainsworth himself has been journeying through it
ever since he commenced his career as a romancer; and he has
been the humble means of leading others in the same path.

Lives of Donne, Wotton, Hooker, Herbert, and Sanderson.


By Isaak Walton. New York: Wiley & Putnam. 2 Parts.
12mo.

It is singular that this should be the first American edition of so


celebrated a work. Isaak Walton has always been a favorite with
readers, and his “Lives” have held a prominent place among choice
books. The most extravagant admiration has been expressed for
them by men of the finest genius. Wordsworth says, in not the least
beautiful of his sonnets, that
—“The feather whence the pen
Was shaped, that traced the lives of these good men,
Dropt from an angel’s wing.”

We never knew a case where the book was read without giving
delight. Indeed it nestles close to the heart. There is a quaint,
cunning, quiet beauty to it, which wins upon the mind, and gently
forces assent to its excellence. Such a book is balm to a sensitive
and irritable spirit. It is read with some such feeling as might be
excited by a benediction from Chaucer’s good parson. Every one
who desires to “possess himself in much quietness,” whose brain has
been fretted and stung by the morbid creations of the Satanic school
of letters, should devote his days and nights to Isaak Walton, as
Johnson advised the style-monger to devote himself to Addison. The
sweet serenity which breathes through the whole book, joined to the
sly quaint beauty of the expression, cannot fail to charm every mind
not wholly debauched by the “storm-and-pressure” style now in
vogue. The men to whom the book relates, are among the saints of
English literature; men who combined great learning and greater
intellect, with sweetness of disposition and repose of manner. We
can hardly conceive of a reader rising from the perusal of these
“Lives” without having some of their many amenities infused into his
heart.

Transcriber’s Notes:
Table of Contents has been added for reader convenience. Archaic
spellings and hyphenation have been retained. Punctuation has been
corrected without note. Other errors have been corrected as noted
below. For illustrations, some caption text may be missing or
incomplete due to condition of the originals available for preparation
of the eBook.

page 93, after Kate, stupified ==> after Kate, stupefied


page 93, be so forciby depicted ==> be so forcibly depicted
page 94, a strange forboding feeling, ==> a strange foreboding
feeling,
page 96, suffering. His commisseration was ==> suffering. His
commiseration was
page 97, that was irresistable. ==> that was irresistible.
page 97, been put hors du combat, ==> been put hors de combat,
page 101, abandoned villany are, ==> abandoned villainy are,
page 101, frighthen children and ==> frighten children and
page 103, had thus accidently met my ==> had thus accidentally
met my
page 107, coolness of villany, he ==> coolness of villainy, he
page 108, that such wound caused ==> that such wounds caused
page 109, in the grasp of villany, ==> in the grasp of villainy,
page 112, me. Your’s is a ==> me. Yours is a
page 117, In the Chrisa di Santa ==> In the Chiesa di Santa
page 123, your’re for putting it ==> you’re for putting it
page 123, but it it is almost too ==> but it is almost too
page 128, Every thing was en regle, ==> Every thing was en règle,
page 128, half-deck of your’s is ==> half-deck of yours is
page 128, soften the underderstanding.” ==> soften the
understanding.”
page 130, another up in it’s ==> another up in its
page 133, milliner and matua-maker in ==> milliner and mantua-
maker in
page 136, gave Hasting’s wine that ==> gave Hastings wine that
page 138, while be was out of ==> while he was out of
page 139, almost stiched her ==> almost stitched her
page 139, and mantua-makers accounts! ==> and mantua-maker’s
accounts!
page 139, looks, is if they ==> looks, as if they
page 139, ‘That he eat five ==> ‘That he ate five
page 139, where thy will wind ==> where they will wind
page 140, The murmer of the ==> The murmur of the
page 142, to furnish the denouement ==> to furnish the
dénouement
page 143, qui en savent comme quatre ==> qui en savant comme
quatre
page 143, Moins sevère là-haut ==> Moins sévère là-haut
page 143, Laërte prie and meurs. ==> Laërte prie et meurs.
page 143, Jesu vous aime quand ==> Jésu vous aime quand
page 143, va!—desespère et meurs ==> va!—désespère et meurs
page 143, cet air impregné de ==> cet air imprégné de
page 143, Tragedièn choisi pour ==> Tragédien choisi pour
page 143, j’en nai fait mourir ==> j’en ai fait mourir
page 144, Firm of Domby and Son ==> Firm of Dombey and Son
page 144, in “Domby and Son.” His ==> in “Dombey and Son.” His
*** END OF THE PROJECT GUTENBERG EBOOK GRAHAM'S
MAGAZINE, VOL. XXX, NO. 2, FEBRUARY 1847 ***

Updated editions will replace the previous one—the old editions


will be renamed.

Creating the works from print editions not protected by U.S.


copyright law means that no one owns a United States
copyright in these works, so the Foundation (and you!) can copy
and distribute it in the United States without permission and
without paying copyright royalties. Special rules, set forth in the
General Terms of Use part of this license, apply to copying and
distributing Project Gutenberg™ electronic works to protect the
PROJECT GUTENBERG™ concept and trademark. Project
Gutenberg is a registered trademark, and may not be used if
you charge for an eBook, except by following the terms of the
trademark license, including paying royalties for use of the
Project Gutenberg trademark. If you do not charge anything for
copies of this eBook, complying with the trademark license is
very easy. You may use this eBook for nearly any purpose such
as creation of derivative works, reports, performances and
research. Project Gutenberg eBooks may be modified and
printed and given away—you may do practically ANYTHING in
the United States with eBooks not protected by U.S. copyright
law. Redistribution is subject to the trademark license, especially
commercial redistribution.

START: FULL LICENSE


THE FULL PROJECT GUTENBERG LICENSE
PLEASE READ THIS BEFORE YOU DISTRIBUTE OR USE THIS WORK

To protect the Project Gutenberg™ mission of promoting the


free distribution of electronic works, by using or distributing this
work (or any other work associated in any way with the phrase
“Project Gutenberg”), you agree to comply with all the terms of
the Full Project Gutenberg™ License available with this file or
online at www.gutenberg.org/license.

Section 1. General Terms of Use and


Redistributing Project Gutenberg™
electronic works
1.A. By reading or using any part of this Project Gutenberg™
electronic work, you indicate that you have read, understand,
agree to and accept all the terms of this license and intellectual
property (trademark/copyright) agreement. If you do not agree
to abide by all the terms of this agreement, you must cease
using and return or destroy all copies of Project Gutenberg™
electronic works in your possession. If you paid a fee for
obtaining a copy of or access to a Project Gutenberg™
electronic work and you do not agree to be bound by the terms
of this agreement, you may obtain a refund from the person or
entity to whom you paid the fee as set forth in paragraph 1.E.8.

1.B. “Project Gutenberg” is a registered trademark. It may only


be used on or associated in any way with an electronic work by
people who agree to be bound by the terms of this agreement.
There are a few things that you can do with most Project
Gutenberg™ electronic works even without complying with the
full terms of this agreement. See paragraph 1.C below. There
are a lot of things you can do with Project Gutenberg™
electronic works if you follow the terms of this agreement and
help preserve free future access to Project Gutenberg™
electronic works. See paragraph 1.E below.
1.C. The Project Gutenberg Literary Archive Foundation (“the
Foundation” or PGLAF), owns a compilation copyright in the
collection of Project Gutenberg™ electronic works. Nearly all the
individual works in the collection are in the public domain in the
United States. If an individual work is unprotected by copyright
law in the United States and you are located in the United
States, we do not claim a right to prevent you from copying,
distributing, performing, displaying or creating derivative works
based on the work as long as all references to Project
Gutenberg are removed. Of course, we hope that you will
support the Project Gutenberg™ mission of promoting free
access to electronic works by freely sharing Project Gutenberg™
works in compliance with the terms of this agreement for
keeping the Project Gutenberg™ name associated with the
work. You can easily comply with the terms of this agreement
by keeping this work in the same format with its attached full
Project Gutenberg™ License when you share it without charge
with others.

1.D. The copyright laws of the place where you are located also
govern what you can do with this work. Copyright laws in most
countries are in a constant state of change. If you are outside
the United States, check the laws of your country in addition to
the terms of this agreement before downloading, copying,
displaying, performing, distributing or creating derivative works
based on this work or any other Project Gutenberg™ work. The
Foundation makes no representations concerning the copyright
status of any work in any country other than the United States.

1.E. Unless you have removed all references to Project


Gutenberg:

1.E.1. The following sentence, with active links to, or other


immediate access to, the full Project Gutenberg™ License must
appear prominently whenever any copy of a Project
Gutenberg™ work (any work on which the phrase “Project
Gutenberg” appears, or with which the phrase “Project
Gutenberg” is associated) is accessed, displayed, performed,
viewed, copied or distributed:

This eBook is for the use of anyone anywhere in the United


States and most other parts of the world at no cost and
with almost no restrictions whatsoever. You may copy it,
give it away or re-use it under the terms of the Project
Gutenberg License included with this eBook or online at
www.gutenberg.org. If you are not located in the United
States, you will have to check the laws of the country
where you are located before using this eBook.

1.E.2. If an individual Project Gutenberg™ electronic work is


derived from texts not protected by U.S. copyright law (does not
contain a notice indicating that it is posted with permission of
the copyright holder), the work can be copied and distributed to
anyone in the United States without paying any fees or charges.
If you are redistributing or providing access to a work with the
phrase “Project Gutenberg” associated with or appearing on the
work, you must comply either with the requirements of
paragraphs 1.E.1 through 1.E.7 or obtain permission for the use
of the work and the Project Gutenberg™ trademark as set forth
in paragraphs 1.E.8 or 1.E.9.

1.E.3. If an individual Project Gutenberg™ electronic work is


posted with the permission of the copyright holder, your use and
distribution must comply with both paragraphs 1.E.1 through
1.E.7 and any additional terms imposed by the copyright holder.
Additional terms will be linked to the Project Gutenberg™
License for all works posted with the permission of the copyright
holder found at the beginning of this work.

1.E.4. Do not unlink or detach or remove the full Project


Gutenberg™ License terms from this work, or any files
containing a part of this work or any other work associated with
Project Gutenberg™.

1.E.5. Do not copy, display, perform, distribute or redistribute


this electronic work, or any part of this electronic work, without
prominently displaying the sentence set forth in paragraph 1.E.1
with active links or immediate access to the full terms of the
Project Gutenberg™ License.

1.E.6. You may convert to and distribute this work in any binary,
compressed, marked up, nonproprietary or proprietary form,
including any word processing or hypertext form. However, if
you provide access to or distribute copies of a Project
Gutenberg™ work in a format other than “Plain Vanilla ASCII” or
other format used in the official version posted on the official
Project Gutenberg™ website (www.gutenberg.org), you must,
at no additional cost, fee or expense to the user, provide a copy,
a means of exporting a copy, or a means of obtaining a copy
upon request, of the work in its original “Plain Vanilla ASCII” or
other form. Any alternate format must include the full Project
Gutenberg™ License as specified in paragraph 1.E.1.

1.E.7. Do not charge a fee for access to, viewing, displaying,


performing, copying or distributing any Project Gutenberg™
works unless you comply with paragraph 1.E.8 or 1.E.9.

1.E.8. You may charge a reasonable fee for copies of or


providing access to or distributing Project Gutenberg™
electronic works provided that:

• You pay a royalty fee of 20% of the gross profits you derive
from the use of Project Gutenberg™ works calculated using the
method you already use to calculate your applicable taxes. The
fee is owed to the owner of the Project Gutenberg™ trademark,
but he has agreed to donate royalties under this paragraph to
the Project Gutenberg Literary Archive Foundation. Royalty
payments must be paid within 60 days following each date on
which you prepare (or are legally required to prepare) your
periodic tax returns. Royalty payments should be clearly marked
as such and sent to the Project Gutenberg Literary Archive
Foundation at the address specified in Section 4, “Information
about donations to the Project Gutenberg Literary Archive
Foundation.”

• You provide a full refund of any money paid by a user who


notifies you in writing (or by e-mail) within 30 days of receipt
that s/he does not agree to the terms of the full Project
Gutenberg™ License. You must require such a user to return or
destroy all copies of the works possessed in a physical medium
and discontinue all use of and all access to other copies of
Project Gutenberg™ works.

• You provide, in accordance with paragraph 1.F.3, a full refund of


any money paid for a work or a replacement copy, if a defect in
the electronic work is discovered and reported to you within 90
days of receipt of the work.

• You comply with all other terms of this agreement for free
distribution of Project Gutenberg™ works.

1.E.9. If you wish to charge a fee or distribute a Project


Gutenberg™ electronic work or group of works on different
terms than are set forth in this agreement, you must obtain
permission in writing from the Project Gutenberg Literary
Archive Foundation, the manager of the Project Gutenberg™
trademark. Contact the Foundation as set forth in Section 3
below.

1.F.

1.F.1. Project Gutenberg volunteers and employees expend


considerable effort to identify, do copyright research on,
transcribe and proofread works not protected by U.S. copyright
law in creating the Project Gutenberg™ collection. Despite these
efforts, Project Gutenberg™ electronic works, and the medium
on which they may be stored, may contain “Defects,” such as,
but not limited to, incomplete, inaccurate or corrupt data,
transcription errors, a copyright or other intellectual property
infringement, a defective or damaged disk or other medium, a
computer virus, or computer codes that damage or cannot be
read by your equipment.

1.F.2. LIMITED WARRANTY, DISCLAIMER OF DAMAGES - Except


for the “Right of Replacement or Refund” described in
paragraph 1.F.3, the Project Gutenberg Literary Archive
Foundation, the owner of the Project Gutenberg™ trademark,
and any other party distributing a Project Gutenberg™ electronic
work under this agreement, disclaim all liability to you for
damages, costs and expenses, including legal fees. YOU AGREE
THAT YOU HAVE NO REMEDIES FOR NEGLIGENCE, STRICT
LIABILITY, BREACH OF WARRANTY OR BREACH OF CONTRACT
EXCEPT THOSE PROVIDED IN PARAGRAPH 1.F.3. YOU AGREE
THAT THE FOUNDATION, THE TRADEMARK OWNER, AND ANY
DISTRIBUTOR UNDER THIS AGREEMENT WILL NOT BE LIABLE
TO YOU FOR ACTUAL, DIRECT, INDIRECT, CONSEQUENTIAL,
PUNITIVE OR INCIDENTAL DAMAGES EVEN IF YOU GIVE
NOTICE OF THE POSSIBILITY OF SUCH DAMAGE.

1.F.3. LIMITED RIGHT OF REPLACEMENT OR REFUND - If you


discover a defect in this electronic work within 90 days of
receiving it, you can receive a refund of the money (if any) you
paid for it by sending a written explanation to the person you
received the work from. If you received the work on a physical
medium, you must return the medium with your written
explanation. The person or entity that provided you with the
defective work may elect to provide a replacement copy in lieu
of a refund. If you received the work electronically, the person
or entity providing it to you may choose to give you a second
opportunity to receive the work electronically in lieu of a refund.
If the second copy is also defective, you may demand a refund
in writing without further opportunities to fix the problem.

1.F.4. Except for the limited right of replacement or refund set


forth in paragraph 1.F.3, this work is provided to you ‘AS-IS’,
WITH NO OTHER WARRANTIES OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO WARRANTIES OF
MERCHANTABILITY OR FITNESS FOR ANY PURPOSE.

1.F.5. Some states do not allow disclaimers of certain implied


warranties or the exclusion or limitation of certain types of
damages. If any disclaimer or limitation set forth in this
agreement violates the law of the state applicable to this
agreement, the agreement shall be interpreted to make the
maximum disclaimer or limitation permitted by the applicable
state law. The invalidity or unenforceability of any provision of
this agreement shall not void the remaining provisions.

1.F.6. INDEMNITY - You agree to indemnify and hold the


Foundation, the trademark owner, any agent or employee of the
Foundation, anyone providing copies of Project Gutenberg™
electronic works in accordance with this agreement, and any
volunteers associated with the production, promotion and
distribution of Project Gutenberg™ electronic works, harmless
from all liability, costs and expenses, including legal fees, that
arise directly or indirectly from any of the following which you
do or cause to occur: (a) distribution of this or any Project
Gutenberg™ work, (b) alteration, modification, or additions or
deletions to any Project Gutenberg™ work, and (c) any Defect
you cause.

Section 2. Information about the Mission


of Project Gutenberg™
Project Gutenberg™ is synonymous with the free distribution of
electronic works in formats readable by the widest variety of
computers including obsolete, old, middle-aged and new
computers. It exists because of the efforts of hundreds of
volunteers and donations from people in all walks of life.

Volunteers and financial support to provide volunteers with the


assistance they need are critical to reaching Project
Gutenberg™’s goals and ensuring that the Project Gutenberg™
collection will remain freely available for generations to come. In
2001, the Project Gutenberg Literary Archive Foundation was
created to provide a secure and permanent future for Project
Gutenberg™ and future generations. To learn more about the
Project Gutenberg Literary Archive Foundation and how your
efforts and donations can help, see Sections 3 and 4 and the
Foundation information page at www.gutenberg.org.

Section 3. Information about the Project


Gutenberg Literary Archive Foundation
The Project Gutenberg Literary Archive Foundation is a non-
profit 501(c)(3) educational corporation organized under the
laws of the state of Mississippi and granted tax exempt status
by the Internal Revenue Service. The Foundation’s EIN or
federal tax identification number is 64-6221541. Contributions
to the Project Gutenberg Literary Archive Foundation are tax
deductible to the full extent permitted by U.S. federal laws and
your state’s laws.

The Foundation’s business office is located at 809 North 1500


West, Salt Lake City, UT 84116, (801) 596-1887. Email contact
links and up to date contact information can be found at the
Foundation’s website and official page at
www.gutenberg.org/contact
Section 4. Information about Donations to
the Project Gutenberg Literary Archive
Foundation
Project Gutenberg™ depends upon and cannot survive without
widespread public support and donations to carry out its mission
of increasing the number of public domain and licensed works
that can be freely distributed in machine-readable form
accessible by the widest array of equipment including outdated
equipment. Many small donations ($1 to $5,000) are particularly
important to maintaining tax exempt status with the IRS.

The Foundation is committed to complying with the laws


regulating charities and charitable donations in all 50 states of
the United States. Compliance requirements are not uniform
and it takes a considerable effort, much paperwork and many
fees to meet and keep up with these requirements. We do not
solicit donations in locations where we have not received written
confirmation of compliance. To SEND DONATIONS or determine
the status of compliance for any particular state visit
www.gutenberg.org/donate.

While we cannot and do not solicit contributions from states


where we have not met the solicitation requirements, we know
of no prohibition against accepting unsolicited donations from
donors in such states who approach us with offers to donate.

International donations are gratefully accepted, but we cannot


make any statements concerning tax treatment of donations
received from outside the United States. U.S. laws alone swamp
our small staff.

Please check the Project Gutenberg web pages for current


donation methods and addresses. Donations are accepted in a
number of other ways including checks, online payments and
credit card donations. To donate, please visit:
www.gutenberg.org/donate.

Section 5. General Information About


Project Gutenberg™ electronic works
Professor Michael S. Hart was the originator of the Project
Gutenberg™ concept of a library of electronic works that could
be freely shared with anyone. For forty years, he produced and
distributed Project Gutenberg™ eBooks with only a loose
network of volunteer support.

Project Gutenberg™ eBooks are often created from several


printed editions, all of which are confirmed as not protected by
copyright in the U.S. unless a copyright notice is included. Thus,
we do not necessarily keep eBooks in compliance with any
particular paper edition.

Most people start at our website which has the main PG search
facility: www.gutenberg.org.

This website includes information about Project Gutenberg™,


including how to make donations to the Project Gutenberg
Literary Archive Foundation, how to help produce our new
eBooks, and how to subscribe to our email newsletter to hear
about new eBooks.

You might also like