You are on page 1of 54

Cross Over to HTML5 Game

Development: Use Your Programming


Experience to Create Mobile Games 1st
Edition Zarrar Chishti (Auth.)
Visit to download the full and correct content document:
https://textbookfull.com/product/cross-over-to-html5-game-development-use-your-pro
gramming-experience-to-create-mobile-games-1st-edition-zarrar-chishti-auth/
More products digital (pdf, epub, mobi) instant
download maybe you interests ...

Pro HTML5 Games. Learn to build your own Games using


HTML5 and JavaScript Aditya Ravi Shankar

https://textbookfull.com/product/pro-html5-games-learn-to-build-
your-own-games-using-html5-and-javascript-aditya-ravi-shankar/

Create Computer Games Design and Build Your Own Game


Patrick Mccabe

https://textbookfull.com/product/create-computer-games-design-
and-build-your-own-game-patrick-mccabe/

Unity 2017 Game AI Programming Leverage the power of


Artificial Intelligence to program smart entities for
your games Raymundo Barrera

https://textbookfull.com/product/unity-2017-game-ai-programming-
leverage-the-power-of-artificial-intelligence-to-program-smart-
entities-for-your-games-raymundo-barrera/

Uncopyable How to Create an Unfair Advantage Over Your


Competition 2nd Edition Steve Miller

https://textbookfull.com/product/uncopyable-how-to-create-an-
unfair-advantage-over-your-competition-2nd-edition-steve-miller/
Mastering LibGDX Game Development Leverage the power of
LibGDX to create a fully functional customizable RPG
game for your own commercial title 1st Edition Hoey
Patrick
https://textbookfull.com/product/mastering-libgdx-game-
development-leverage-the-power-of-libgdx-to-create-a-fully-
functional-customizable-rpg-game-for-your-own-commercial-
title-1st-edition-hoey-patrick/

Work on Your Game: Use the Pro Athlete Mindset to


Dominate Your Game in Business, Sports, and Life Dre
Baldwin

https://textbookfull.com/product/work-on-your-game-use-the-pro-
athlete-mindset-to-dominate-your-game-in-business-sports-and-
life-dre-baldwin/

Game Programming in C Creating 3D Games Creating 3D


Games Sanjay Madhav

https://textbookfull.com/product/game-programming-in-c-
creating-3d-games-creating-3d-games-sanjay-madhav/

Nlp Made Easy How to Use Neuro Linguistic Programming


to Change Your Life Ali Campbell

https://textbookfull.com/product/nlp-made-easy-how-to-use-neuro-
linguistic-programming-to-change-your-life-ali-campbell/

Uncopyable How to Create an Unfair Advantage Over Your


Competition Updated and Expanded Edition Steve Miller

https://textbookfull.com/product/uncopyable-how-to-create-an-
unfair-advantage-over-your-competition-updated-and-expanded-
edition-steve-miller/
Cross Over to
HTML5 Game
Development
Use Your Programming Experience to
Create Mobile Games

Zarrar Chishti
Cross Over to HTML5
Game Development
Use Your Programming
Experience to Create
Mobile Games

Zarrar Chishti
Cross Over to HTML5 Game Development: Use Your Programming
Experience to Create Mobile Games
Zarrar Chishti
Glasgow, United Kingdom

ISBN-13 (pbk): 978-1-4842-3290-3 ISBN-13 (electronic): 978-1-4842-3291-0


https://doi.org/10.1007/978-1-4842-3291-0

Library of Congress Control Number: 2017961309


Copyright © 2017 by Zarrar Chishti
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.
Cover image designed by Freepik
Managing Director: Welmoed Spahr
Editorial Director: Todd Green
Acquisitions Editor: Aaron Black
Development Editor: James Markham
Technical Reviewer: Massimo Nardone
Coordinating Editor: Jessica Vakili
Copy Editor: Kim Burton-Weisman
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/978-1-4842-3290-3. For
more detailed information, please visit http://www.apress.com/source-code.
Printed on acid-free paper
Table of Contents
About the Author��������������������������������������������������������������������������������vii
About the Technical Reviewer�������������������������������������������������������������ix
Acknowledgments�������������������������������������������������������������������������������xi
Preface����������������������������������������������������������������������������������������������xiii

Chapter 1: Introduction������������������������������������������������������������������������1
Introducing Our Game: Space Zombies������������������������������������������������������1
Setting up Your Work Environment�������������������������������������������������������������4
Part 1: Setting up Our Folders������������������������������������������������������������������������������������� 4
Part 2: Setting up Our Files������������������������������������������������������������������������������������������ 6

Hosting and Media Files���������������������������������������������������������������������������10


Part 1: Your Computer vs. Hosting Servers ��������������������������������������������������������������� 10
Part 2: Download the Media for Your Project������������������������������������������������������������� 11

Chapter 2: In the Beginning, There Was HTML������������������������������������15


Hello World�����������������������������������������������������������������������������������������������15
Background Image�����������������������������������������������������������������������������������18
Adding the Rest of the Images�����������������������������������������������������������������20

Chapter 3: Time to Apply a Little CSS�������������������������������������������������23


Start with a Quick Test�����������������������������������������������������������������������������24
Our Background Image����������������������������������������������������������������������������28
Our Other Images�������������������������������������������������������������������������������������32

iii
Table of Contents

Chapter 4: Apply Intelligence with JavaScript�����������������������������������37


Why Do We Need to Resize?���������������������������������������������������������������������37
How Do We Universally Resize?���������������������������������������������������������������38
Let’s Resize Our Images���������������������������������������������������������������������������46

Chapter 5: Take a Shot: Part 1������������������������������������������������������������51


Changing Our Cursor and Registering a Click������������������������������������������51
Making Our Gun Act More Realistic����������������������������������������������������������55
Animating the Gun with Sprite Sheets�����������������������������������������������������60
Part 1������������������������������������������������������������������������������������������������������������������������� 60
Part 2������������������������������������������������������������������������������������������������������������������������� 63
Part 3������������������������������������������������������������������������������������������������������������������������� 64
Part 4������������������������������������������������������������������������������������������������������������������������� 68

Reloading Our Gun�����������������������������������������������������������������������������������71


Firing Our Gun������������������������������������������������������������������������������������������78
One Last Thing…�������������������������������������������������������������������������������������81

Chapter 6: Where Are the Zombies?���������������������������������������������������85


Creating a Zombie: Part 1�������������������������������������������������������������������������85
Creating a Zombie: Part 2�������������������������������������������������������������������������86
Moving the Zombie Closer������������������������������������������������������������������������95
Creating All the Zombies��������������������������������������������������������������������������99
Generating a Zombie Life Cycle��������������������������������������������������������������102

Chapter 7: Take a Shot: Part 2����������������������������������������������������������107


Hitting a Zombie�������������������������������������������������������������������������������������107
Making the Hits Count����������������������������������������������������������������������������113

iv
Table of Contents

Zombie Down!����������������������������������������������������������������������������������������119
Part 1: Create Six Bubble Zombie Elements������������������������������������������������������������ 120
Part 2: Activate the Counter Bubble Zombie������������������������������������������������������������ 129
Part 3: Animate the Bubble Zombies����������������������������������������������������������������������� 136

Reloading the Gun����������������������������������������������������������������������������������146


Clean up the Depths and Click Zones�����������������������������������������������������157
Part 1: Ensuring Gun Fire����������������������������������������������������������������������������������������� 157
Part 2: Zombie Depth Levels������������������������������������������������������������������������������������ 163

Intro Splash and “Game Over” Screens�������������������������������������������������171


Part 1: Images Folder���������������������������������������������������������������������������������������������� 171
Part 2: Stopping and Starting���������������������������������������������������������������������������������� 172

Chapter 8: Add Some Bling to Our Game������������������������������������������191


What’s the Score?����������������������������������������������������������������������������������192
Sprinkle of Special Effects���������������������������������������������������������������������203
Part 1: Get Started��������������������������������������������������������������������������������������������������� 204
Part 2: Displaying the Effects���������������������������������������������������������������������������������� 204

Turn up the Sound Effects����������������������������������������������������������������������219


Part 1: Getting Started��������������������������������������������������������������������������������������������� 220
Part 2: Adding Sound Effects����������������������������������������������������������������������������������� 220

Embedding the Game�����������������������������������������������������������������������������225


Part 1: Getting Started��������������������������������������������������������������������������������������������� 225
Part 2: Modify the default.html File������������������������������������������������������������������������� 226

Game Over. Restart?�������������������������������������������������������������������������������244

Index�������������������������������������������������������������������������������������������������247

v
About the Author
Zarrar Chishti is a software and games
development consultant with over 500 games
developed for companies around the world. He
is sought after to advise on the development
of viral games for major marketing campaigns.
His consultancy and development firm include
prestigious companies such as Turner Media,
British Airways and Channel 4 among the
many clients that keep coming back when a
new product or service is being launched.
After graduating from Glasgow University
in 1996 with a prestigious joint honors degree in Software Engineering,
Zarrar contracted as a software developer in both London and L.A. for 5
years. In 2001 he opened his own software firm in Glasgow and within 2
years was employing 10 staff. This was to grow to 30 in 2005 when he began
to offer games development to his clients.
One of the most notable game projects Zarrar has produced includes
an interactive comic for the popular Ben 10 TV series. The project was a
notable success that took his firm 10 months to deliver. It was rolled out
in over 25 countries in localized language editions. Other projects include
building a series of games for the ever popular Big Brother TV franchise
and an employee training game for Legal and General.

vii
About the Technical Reviewer
Massimo Nardone has more than 22 years
of experiences in security, web/mobile
development, and cloud and IT architecture.
His true IT passions are security and Android.
He has programmed and taught how to
program with Android, Perl, PHP, Java, VB,
Python, C/C++ and MySQL for more than 20
years.
He holds a master’s degree in computing
science from the University of Salerno, Italy.
He has worked as a project manager, software engineer, research
engineer, chief security architect, information security manager, PCI/SCADA
auditor and senior lead IT security/cloud/SCADA architect for many years.
His technical skills include security, Android, cloud, Java, MySQL,
Drupal, Cobol, Perl, web and mobile development, MongoDB, D3, Joomla,
Couchbase, C/C++, WebGL, Python, Pro Rails, Django CMS, Jekyll,
Scratch, and more.
He currently works as chief information security office (CISO) for
Cargotec Oyj.
He worked as visiting lecturer and supervisor for exercises at the
Networking Laboratory of the Helsinki University of Technology (Aalto
University). He holds four international patents (PKI, SIP, SAML, and Proxy
areas).
Massimo has reviewed more than 40 IT books for various publishing
companies. He is the coauthor of Pro Android Games (Apress, 2015).

ix
Acknowledgments
To Pops - you were an amazing dad who has left a massive hole in our lives.
To my closest friend, who has been (and continues to be) there for me
at the times when it matters the most: my brother Ibrar. Thank you to my
parents, who gave me the most amazing education and start to life. My one
constant and partner in crime, my wife Sadia. My son, whom I am so proud
of (incidentally, he was my initial editor for the book) and my “janno-jaan”
daughters: Sara, Aisha, and Rushda. I would be in a tremendous amount
of trouble if I did not also acknowledge Bella, our Bengal cat.
I would like to say a heartfelt thank you to my agent, Carole. You agreed
to represent me, despite my thick Scottish accent! Your guidance and
patience at the start will always be remembered and appreciated. Also,
thank you to the awesome and gorgeous team at Apress: Aaron and Jessica.
I had a great time working with you both and you made this “noob” feel
like part of the team.
I want to thank two people who have inspired me to write books. My
Latin teacher Mr. Temperely and my favorite author of all time, David Blixt.
I would also like send my love and appreciation to all my staff, both past
and present: Alasdair, George, Paul (the Great), Les, and Claire. Also, my
thanks to those clients that gave me my initial start despite having little or
no experience.
Finally, I would like to thank the nurses and doctors at Monklands
Haematology department who looked after my wife, Sadia. I will always
remember your commitment, passion, and support that you gave to her.
Thank you for sending her home to us.

xi
Preface
Welcome to the wonderful world of HTML5 game development. Are you
looking for a new challenge or looking to expand your current skill set?
Then get ready to start your journey. This book has been written with a
simple goal in mind: to provide the means for anyone to develop their first
HTML5 game.
This is a great time to break into the most lucrative game development
platform in the world. The global demand for the HTML5 game
development platform has expanded so quickly that it is currently crying
out for seasoned developers from more traditional environments to
cross over. Never before has there been such a widely accepted platform
by literally every manufacturer and operating system. This, in turn,
has convinced marketing departments to move away from traditional
platforms, such as dedicated mobile apps, for the more widely accepted
HTML5 format.
In short, there has never been a better time for a seasoned IT
programmer to cross over and capitalize in this lucrative market with their
much sought-after talents and experience.
I have spent the last five years training developers from a wide range
of programming disciplines to cross-train in HTML5 game development.
Whatever your vocation, whether it be an application databases systems
developer or a professional web developer, with this book you will learn to
evolve your current coding skills to enable you to become eligible for the
biggest gaming platform in the world.
From the first chapter, you immediately see encouraging results as
you power through a challenging and fun project that has been uniquely
designed and developed for this book.

xiii
Preface

Why This Book


This book was written with a simple goal in mind: to help seasoned
programmers from other disciplines to cross over to HTML5 game
development.
No apps need to be purchased. No special hardware or software is
required. As long as you have a simple computer with Internet access, you
can start today.
How quickly you build this game is entirely up to you. For each major
step we come across, you can decide to either study the technical aspects
or skip ahead to the next step. Either way, by the end of this book, you will
have a playable game to show off to friends and family.
This book is perfect for anyone that just wants to roll up their sleeves
and start developing a game for themselves. I believe that by the end of
this book, you will be in a far better position to make a decision on whether
you want to invest your time and money in becoming a qualified games
developer.

What You Will Need


Any computer will do.

• You do not need a super-fast computer

• You do not need an expensive IDE installed

• You do not need the latest graphics card

You can build this game using the computer/laptop that you already
have—as long as it switches on and you can run the already installed
Notepad program (if you are using Windows) or TextEdit (if you are on an
Apple Mac).

xiv
Preface

What about your phone or tablet? Technically, it is possible; however, it


is not ideal because the operating environment is not suited to coding (i.e.,
typing). If you do wish to use these devices, then you may wish to invest in
a Bluetooth keyboard and an external memory card.

How to Use This Book


During this project, I have spent a great deal of my time minimizing the
amount of code that you need to write. However, I had to balance this
with making code that was still readable, which means that in occasional
instances of this book, you will find some lengthy portions of code to write.
I do apologize for this; however, keep in mind that you will be able to reuse
the code in your next project.
The following icons appear in the book.

In this section, you will see the actual code that will need to be written. It is
important to ensure that you copy the code exactly as it is written.
On most occasions, you will only need to write the lines that are
written in bold. Also, the lines of code that existed before but have just
been modified are in red.

xv
Preface

In this section, you will see interesting facts and explanations of the code
that has just been written. If you wish to build on your coding knowledge
as you proceed, then you will find a great source of information here.
However, feel free to ignore this section if you just want to get on with
building your game.

Did something go wrong? Did the code you just wrote not work? Not to
worry. You will find common (and some not so common) mistakes here
with solutions on how to fix them.

xvi
CHAPTER 1

Introduction
“If you have a garden and a library,
you have everything you need.”
Marcus Tullius Cicero
(106 BC – 43 BC)

var replaceWord1 = str.replace("garden", "computer");

var replaceWord2 = str.replace("a library", "time");

I have been developing software since 1996 and I have developed games
for small and large companies for over a decade now. Like any form of
development in the real world, you need to know why you are building
the game before you think of coding strategies and build processes. In the
gaming world, this comes in the form of the game’s story. This includes the
background, reasons to play, and the goals of the game.

Introducing Our Game: Space Zombies


So here is our story, which we will develop into a game.
Hi. My name is Ace Star. The year is 2107. For the last three
months, I have been stationed as a security guard on the only moon
of planet ZC636, which is in the Andromeda Galaxy. In addition to
me and a group of dignitaries from Earth, there is a group of about
500 top scientists stationed here to work on secret experiments.
1
© Zarrar Chishti 2017
Z. Chishti, Cross Over to HTML5 Game Development,
https://doi.org/10.1007/978-1-4842-3291-0_1
Chapter 1 Introduction

I need your help.


Last night, there was an explosion in one of the labs. A gas was released
that turned all the scientists in the lab into zombies.
I have positioned myself outside the only doors of the colony’s main
building. The other survivors are safely inside. I am the last line of defense
before help arrives from Earth.
I discovered that our weapons are useless against the zombies. While
running out of the labs, however, I found a new, experimental weapon.
It seems to do the trick.
I can hear them coming. Are you ready?

Let’s have a look at a few of the graphics that we will use for the
development.

This is the background image for our game.


It will fill the screen by stretching out both
horizontally and vertically.
Our zombies will spawn from where the ground
meets the sky. Once spawned, they will come
toward us, growing bigger.
Say hello to Professor Z, our average zombie. In
terms of speed, he is not very fast and he does
not suddenly sprint to the front. He simply heads
toward you at his own leisurely speed! In terms of
our weapon shots, he will not be too hard or too
easy to “neutralize.” It takes two zaps to get him.
Say ciao to Belladonna, our fastest zombie.
Keep an eye on her because she will appear one
minute and then suddenly sprint to the front.
She will not be too hard to neutralize, however.
One zap will get her.

2
Chapter 1 Introduction

Finally, this is Brad, our heavyweight zombie.


Unfortunately, due to all of those hours lifting
weights, he is slower than the average zombie.
He takes his time to gain speed once he spawns.
He will be harder to neutralize, however. It takes
three zaps to get him.
This is the experimental weapon that our hero
found in one of the labs. When fired, it zaps
out a special liquid, which when successfully
administered, encases the zombie in an air
bubble.
It will need to be reloaded often.
This is our Reload button. From a game-design
point of view, it adds another dimension to the
gameplay.
This is our game’s logo. We will not see it until
the last chapter of the book, when we embed our
game.
This is the box that we will embed into our
game. Initially, you see the game span the
entire screen. Near the end, however, we look at
embedding the code into this box.
This is the background image that we use in the
final chapter. The background is the main image
used when we build a dedicated web page to
embed our game into.

3
Chapter 1 Introduction

The following is a screenshot of the finished game.

Setting up Your Work Environment


This section discusses how to set up your work environment.

Part 1: Setting up Our Folders


You need to create a work folder where all of your work files can be stored.
This makes it easier to distinguish your work files from all the others on
your computer. So first, create a root (or master) folder called My_Work_
Files in the C drive.

4
Chapter 1 Introduction

Once you have your root folder, the next step is to create the subfolders
that you will need for the game. Create four folders inside My_Work_Files.
Name the folders as follows:

• CSS

• Images

• Raw Images

• js

Your folder should look like the following screenshot.

The CSS folder will hold special code files that help structure the design of
the game. All the files in this folder will end in .css.
The js folder will hold all of our JavaScript files, which will form the
engine for our game. They will contain commands and instructions that will
control what happens in our game. All the files in this folder will end in .js.

5
Chapter 1 Introduction

The Images folder, as the name suggests, will contain all the image or
media files that we will need for the game.
The Raw Images folder will not technically be used for raw images. In
our case, we will use this folder as special temporary housing for all of our
media. We will move them into the Images folder when we need them.

Part 2: Setting up Our Files


For the purposes of this book, I will use Notepad (if you are using an Apple
computer, then I would use TextEdit). I find Notepad simpler and easier
to use; however, almost any IDE (Integrated Development Environment)
can be used for this project. So go ahead and use the IDE that you are most
comfortable with.
If you do want to use an IDE, here is a list of a few that are free to use:

• Eclipse. This is an open source editor that is typically


used for C and C++ (as well as other high-level
languages) projects.

• NetBeans. Like Eclipse, this is an open source


editor; however, it comes bundled with a plethora of
development frameworks.

• Aptana. A very popular IDE among web developers, it can


be plugged into Eclipse. Typically used for HTML projects.

• CodeRun. This is a slightly unusual choice in that


it runs on a browser (i.e., it is a web-based IDE).
Personally, I find it excellent for last-minute fixes when
at a remote location.

• Visual Studio Community. This is free for individual


programmers and comes packed with all the amazing
features that you will find in Visual Studio Professional
series.
6
Chapter 1 Introduction

Although using an IDE has its benefits, I think that it is worth keeping
in mind this excellent quote about using IDEs for multiple languages:

“Although many IDEs can handle more than one language, few do it
well. Plus, it’s likely overkill if you are just getting started.”

Now that the folders are set up, let’s create the files that you will use to
develop the game.
First, you need to create a default.html file. If you are using an IDE,
click File ➤ Create New and select HTML. If you are using Notepad, open a
new file and save it as default.html.
Your folder should now look like this:

Now, we need to create files within some of the folders we created.


Double-click the js folder. Repeat the preceding steps (i.e., create a New
File and then Save As). The following are the file names to enter:
• > SZ_main.js
• > SZ_movement.js
• > SZ_setupContent.js
• > SZ_SS.js
• > SZ_touch.js
• > SZ_zombie_movement.js

7
Chapter 1 Introduction

Your js folder should now look like this:

Finally, we need to create a file within the CSS folder. Repeat the steps
from earlier (i.e., create a New File and then Save As). The file name to
enter is

> SZ_master.css.

Your CSS folder should now look like this:

8
Chapter 1 Introduction

We need our files to work across the worldwide network successfully, so we


should try to keep to the standardized naming conventions.
It is best to avoid character spaces in file names. Technically, this is
acceptable in local environments (Apple and Windows OS), however,
character spaces are not recognized by other systems. Ideally, use an
underscore or a hyphen character to separate words within file names.
Do not use any special characters, such as !, ?, %, #, or /. It is best to
limit file names to underscores, numbers, and letters.
For this project, you will notice that I try to consistently start all of my
file names with SZ_. This is because they are the initials for the name of the
game—Space Zombies. It is important to be consistent and descriptive in
naming and organizing files so that it is obvious where to find specific data
and what the files contain.
By naming your files in a meaningful manner, you increase your
chances of finding those files in the future and knowing what information
they contain. When you come to develop new games, you will easily be
able to locate Space Zombie files by searching for all files starting with SZ_.
Finally, it is good practice to keep file names as short as possible. Apart
from adding to the size of the file, it also makes them easier to remember
six months down the line.

9
Chapter 1 Introduction

Hosting and Media Files


As long as the files remain on your hard drive (the files and folders created
earlier), you will be able to test the game comfortably on your computer.
This is certainly okay for budding developers starting out.
Nonetheless, at some point when you have developed several games,
you may wish to showcase them for all to see and play.
To do this, you need to upload your files to a server computer. A server
is essentially a computer that is connected to the Internet.

Part 1: Your Computer vs. Hosting Servers


You need to open an account with a server computer. If you do a Google
search for “server hosting free trial,” you have several options available.
If you are still unsure, please do not hesitate to message me on Twitter
@zarrarchishti.

The following is a short list of available hosting options.

Dedicated Server

This is the most expensive option. Essentially, you own the computer that
is connected to the Internet. This is only an option if you are either a huge
company or a reseller.

10
Chapter 1 Introduction

Shared Server

This is generally the most economical option for hosting. It is very much
for people like you, who are renting a piece of the server. The main
advantage is the ridiculously low cost, of course. However, as your game
development expertise increases, you may find this option to be limiting
and unfit for your specific needs.

Cloud Hosting

Whereas the prior two options rely on one physical computer, cloud
hosting allows an unlimited number of computers to act as one system.

Part 2: Download the Media for Your Project


The media files (image and sound files) used in the project are available
for you to download.
Open your Internet browser and go to the following URL:

http://zarrarchishtiauthor.com/downloads/

Click the Download button. This will initiate a download. The browser
will let you know when it has completed. Navigate to your download folder
and locate the downloaded file.
It should be a file called raw_media_1.rar. Now you need to extract the
files from this zipped file in a new folder called Raw Media. Double-click
this folder and you will see the following four folders:

• > Images

• > JS

• > sounds

• > html_web

11
Chapter 1 Introduction

First, copy all four folders to your Raw Images folder, which is in the
My_Work_Files folder.
At this stage, we are only interested in the files inside the JS folder. As
we progress through the game, we will go back to the other folders and
copy the files as needed. Double-click the JS folder (in the Raw Images
folder). Using the same technique as before to copy files, go ahead and
copy all the files, and then paste them into your own js folder (in the My_
Work_Files folder).
Your js folder (in the My_Work_Files folder) should now look like this:

That’s it for now! We have successfully set up our game development


environment. We are now ready to start coding our game!

12
Chapter 1 Introduction

The files we copied over from the JS folder are special JavaScript programs
that we can use for our game. Imagine a library of code maintained by
companies like Google that contain functions that make our lives easier.
The files—for instance, jQuery—are fast, small, and feature-rich
JavaScript libraries. Together they make things like HTML document
traversal and manipulation, event handling, animation, and AJAX much
simpler with an easy-to-use API that works across a multitude of browsers.
When using a library such as this, we do not need to ever worry about
how they work. All we need to know is what they do so that we can decide
whether we want to use them in our games.
Another advantage of using libraries such as jQuery is that it runs
exactly the same in all major browsers, including Internet Explorer 6! So no
need to worry about cross-browser issues.
Usually, we link to these files directly from the source servers. The
advantage of doing it this way is that we always get the latest copy of the
code when running our game. However, since we want to be able to play
the game offline, let’s choose to download them into our local folders.

13
Chapter 1 Introduction

1) In Windows, did the option to Extract Here


appear? If not, you need to download WinRAR from
the following:

http://www.win-rar.com/download.html

2) Are you using a laptop? To right-click, you need to

first click and then click the mousepad.

3) When downloading the media files, did you receive


a message from your browser warning you that
the download is not commonly used and may be
dangerous? If yes, this is because I chose to WINRAR
rather than to WINZIP the file. The files are not
dangerous. You may click Keep; however, feel free to
run a virus check on the folder before opening.

14
CHAPTER 2

In the Beginning,
There Was HTML
“Nine people can’t make a baby in a month.”
Fred Brooks

HTML is a mark-up language that is used to develop web sites. So why do


we need this for our game? It is best to imagine HTML as the skeleton or
bone structure of our game.
As a side note, once you have completed this chapter, you will have
not only started your journey into game development, but also web
development!

H
 ello World
During my 20 years of programming, I have learned many programming
languages. The first project that I always work on is learning how to output
the words “Hello World.” to the screen. I bet that you follow this tradition
too, so let’s develop a “Hello World” page in HTML.
Open the default.html file in Notepad or TextEdit in the My_Work_Files
folder using the same program or IDE that you used in the “Part 2: Setting up
Our Files” section in Chapter 1.

15
© Zarrar Chishti 2017
Z. Chishti, Cross Over to HTML5 Game Development,
https://doi.org/10.1007/978-1-4842-3291-0_2
Chapter 2 In the Beginning, There Was HTML

When the file opens, it should be completely blank. Type the following
lines:

<html>
<head>
</head>
<body>
  <div id="SZ_maincontent">
   Hello World.
  </div>
</body>
</html>

Navigate to the menu, click File and then click on Save. You can now
close this file. Navigate back to the menu, click File, and then click Exit/
Close.
Are you ready to test your very first program?
Go back to the My_Work_Files folder and double-click the default.
html file. This should open in your default Internet browser; for example,
Microsoft Edge, Google Chrome, or Safari.
The page that opens up on the browser should be a completely blank
page with the words “Hello World.” displayed in the top-left corner.
Excellent. Our program works and we have written our first piece of code!
Obviously, this is nowhere near a game yet. All the same, persevere
with the work between now and that point. Rest assured, by the end of
this book, we will have developed the entire game. It will most certainly be
worth it. And you will be learning a lot of different techniques to get you
started on your journey to developing a suite of games!

16
Another random document with
no related content on Scribd:
to the actual burning of the body, have in the Samoan custom which
we have just named a remarkable coincidence in their favour.
The unburied occasioned great concern. “No Roman,” says Mr.
Turner, “was ever more grieved at the thought of his unburied friend
wandering a hundred years along the banks of the Styx than were
the Samoans, while they thought of the spirit of one who had been
drowned, or of another who had fallen in war, wandering about
neglected and comfortless. They supposed the spirit haunted them
everywhere night and day, and imagined they heard it calling upon
them in a most pitiful tone, and saying, ‘Oh! how cold; oh! how cold.’
Nor were the Samoans, like the ancient Romans, satisfied with a
mere tumulus-inanis (or empty grave), at which to observe the usual
solemnities; they thought it was possible to obtain the soul of the
departed in some tangible transmigrated form. On the beach, near
where a person had been drowned, or on the battle-field, where
another fell, might be seen sitting in silence a group of five or six,
and one a few yards in advance, with a sheet of native cloth spread
out on the ground before him. Addressing some god of the family, he
said, ‘Oh! be kind to us; let us obtain without difficulty the spirit of the
young man.’ The first thing that happened to light upon the sheet
was supposed to be the spirit. If nothing came, it was supposed that
the spirit had some ill-will to the person praying. That person after a
time retired, and another stepped forward, addressed some other
god, and waited the result. By-and-bye something came—
grasshopper, butterfly, ant, or whatever else it might be; it was
carefully wrapped up, taken to the family, the friends assembled, and
the bundle buried with all due ceremony, as if it contained the real
spirit of the departed.”
The burial, like all other customs of the New Zealanders, are very
singular. Very little, however, was known concerning them until a
recent date. At the time Captain Cook visited the country, everything
connected with the disposal of their dead was concealed from him by
the natives.
It is now known, however, that the dead bodies of slaves were
thrown into holes or into the sea, or buried under the poles
supporting houses; but the dead bodies of free persons were ever
held in high respect. It was only, however, at the death of chiefs that
the funeral rites of the people were celebrated. A chief on his death
bed was surrounded by most of his relatives, his last words were
treasured up, and the resignation with which the dying man
submitted to his fate suggested to the mind that he died of his own
will. The moment the vital spark fled, its departure was bewailed with
doleful cries: abundance of water was shed in the form of tears, and
the spectators groaned, sighed, and seemed inconsolable. But all
was hollow, except with the immediate relatives of the deceased,
and a specimen of the talent of the New Zealanders for
dissimulation. Men, women, and children cut themselves with shells,
and slaves were slain to attend on the dead in the next world, and in
revenge for his death. Since the introduction of fire-arms, guns are
fired off at the death of chiefs.
Twenty-four hours after death the body was washed and beaten
with flax-leaves, to drive away evil spirits. Priests then dressed the
corpse. The legs were bent, the body placed in a sitting attitude, the
hair tied in a lump on the crown of the head, and ornamented with
albatross feathers; garlands of flowers were wound round the
temples, tufts of white down from a sea-bird’s breast were stuck in
the ears, the face was smeared with red ochre and oil, and the whole
body, save the head, enveloped in a fine mat. In this condition,
surrounded with his weapons of war, the bones and preserved heads
of his ancestors, the dead chief sat in state; and as the complexion
of the skins of the natives alters little after death, there was a life-like
appearance in the whole scene. Certain birds were sacrificed to the
gods. Tribes from a distance visited the dead. Wisps of the long toitoi
grass placed in the dead warrior’s hands were grasped by friends,
and flattering laments, of which the following is a good specimen,
were sung in his honour:—
“Behold the lightning’s glare:
It seems to cut asunder Tuwhara’s rugged mountains.
From thy hand the weapon dropped,
And thy bright spirit disappeared
Beyond the heights of Rauhawa.
The sun grows dim, and hastes away,
As a woman from the scene of the battle.
The tides of the ocean weep as they ebb and flow,
And the mountains of the south melt away,
For the spirit of the chieftain
Is taking its flight to Kona.
Open ye the gates of the heavens—
Enter the first heaven, then enter the second heaven,
And when thou shalt travel the land of spirits,
And they shall say to thee, ‘What meanest this?’
Say’st thou, the winds of this our world
Have been torn from it in the death of the brave one,
The leader of our battles.
Atutahi and the stars of the morning
Look down from the sky.
The earth reels to and fro,
For the great prop of the tribes lies low,
Ah! my friend, the dews of Kokianga
Will penetrate the body;
The waters of the rivers will ebb out,
And the land be desolate.”

Dead chiefs sat in state until they gave out an ill odour. Then their
bodies were wrapped in mats, put into canoe-shaped boxes along
with their meris, and deposited on stages nine feet high, or
suspended from trees in the neighbourhood of villages, or interred
within the houses where they died. Here, after daylight, for many
weeks the nearest relatives regularly bewailed their death with
mournful cries. Persons tapued from touching the dead were now
made clean. Carved wooden ornaments, or rude human images
twenty or forty feet high, not unlike Hindoo idols, were erected on the
spots where the bodies were deposited. Mourning head dresses
made of dark feathers were worn; some mourners clipped half their
hair short, and people talked of the dead as if they were alive.
The bodies were permitted to remain about half a year on the
stages, or in the earth, after which the bones were scraped clean,
placed in boxes or mats, and secretly deposited by priests in
sepulchres, on hill tops, in forests, or in caves. The meris and
valuable property of chiefs were now received by their heirs. To
witness this ceremony of the removal of bones neighbouring tribes
were invited to feasts, called the hahunga; and for several
successive years afterwards hahungas were given in honour of the
dead, on which occasions skulls and preserved heads of chiefs were
brought from sepulchres, and adorned with mats, flowers, and
feathers. Speeches and laments delivered at hahungas kept chiefs’
memories alive, and stimulated the living to imitate the dead.
In Borneo when a Dayak dies the whole village is tabooed for a
day; and within a few hours of death the body is rolled up in the
sleeping mat of the deceased, and carried by the “Peninu,” or sexton
of the village, to the place of burial or burning. The body is
accompanied for a little distance from the village by the women,
uttering a loud and melancholy lament. In one tribe—the Pemujan—
the women follow the corpse a short way down the path below the
village to the spot where it divides, one branch leading to the burning
ground, the other to the Chinese town of Siniawau. Here they mount
upon a broad stone and weep, and utter doleful cries till the sexton
and his melancholy burden have disappeared from view. Curiously
enough, the top of this stone is hollowed, and the Dayaks declare
that this has been occasioned by the tears of their women, which,
during many ages, have fallen so abundantly and so often as to wear
away the stone by their continual dropping.
In Western Sarawak the custom of burning the dead is universal.
In the district near the Samarahan they are indifferently burnt or
buried, and when the Sadong is reached, the custom of cremation
ceases, the Dayaks of the last river being in the habit of burying their
dead. In the grave a cocoa nut and areca nut are thrown; and a
small basket and one containing the chewing condiments of the
deceased are hung up near the grave, and if he were a noted warrior
a spear is stuck in the ground close by. The above articles of food
are for the sustenance of the soul in his passage to the other world.
The graves are very shallow, and not unfrequently the corpse is
rooted up and devoured by wild pigs. The burning also is not
unfrequently very inefficiently performed. “Portions of bones and
flesh have been brought back by the dogs and pigs of the village to
the space below the very houses of the relatives,” says Mr. St. John.
“In times of epidemic disease, and when the deceased is very poor,
or the relatives do not feel inclined to be at much expense for the
sexton’s services, corpses are not unfrequently thrown into some
solitary piece of jungle not far from the village, and there left. The
Dayaks have very little respect for the bodies of the departed, though
they have an intense fear of their ghosts.
“The office of sexton is hereditary, descending from father to son;
and when the line fails, great indeed is the difficulty of inducing
another family to undertake its unpleasant duties, involving, as it is
supposed, too familiar an association with the dead and with the
other world to be at all beneficial. Though the prospect of fees is
good, and perhaps every family in the village offers six gallons of
unpounded rice to start the sexton in his new and certainly useful
career, it is difficult to find a candidate. The usual burying fee is one
jav, valued at a rupee; though if great care be bestowed on the
interment, a dollar is asked; at other places as much as two dollars is
occasionally demanded.”
On the day of a person’s death a feast is given by the family to
their relations: if the deceased be rich, a pig and a fowl are killed; but
if poor, a fowl is considered sufficient. The apartment and the family
in which the death occurs are tabooed for seven days and nights,
and if the interdict be not rigidly kept, the ghost of the departed will
haunt the place.
Among the Sea Dayaks, as we are likewise informed by Mr. St.
John, human bodies are usually buried, although, should a man
express a wish to share the privilege of the priests, and be, like
them, exposed on a raised platform, his friends are bound to comply
with his request.
Immediately after the breath has left the body, the female relations
commence loud and melancholy laments; they wash the corpse and
dress it in its finest garments, and often, if a man, fully armed, and
bear it forth to the great common hall, where it is surrounded by its
friends to be mourned over. In some villages a hireling leads the
lament, which is continued till the corpse leaves the house. Before
this takes place, however, the body is rolled up in clothes and fine
mats, kept together by pieces of bamboo tied on with rattans, and
taken to the burial-ground. A fowl is then killed as a sacrifice to the
spirit who guards the earth, and they commence digging the grave
from two and a half to four and a half feet deep, according to the
person’s rank: deeper than five feet would be unlawful. Whilst this
operation is going on others fell a large tree, and cutting off about six
feet, split it in two, and hollow out the pieces with an adze. One part
serves as a coffin and the other as the lid; the body is placed within,
and the two are secured together by means of strips of pliable cane
wound round them.
After the coffin is lowered into the grave, many things belonging to
the deceased are cast in, together with rice, tobacco, and betel-nut,
as they believe they may prove useful in the other world.
It was an old custom, but now falling into disuse, to place money,
gold and silver ornaments, clothes, and various china and brass
utensils in the grave; but these treasures were too great temptation
to those Malays who were addicted to gambling, and the rifling of the
place of interment has often given great and deserved offence to the
relations. As it is almost impossible to discover the offenders, it is
now the practice to break in pieces all the utensils placed in the
grave, and to conceal as carefully as possible the valuable
ornaments.
The relatives and bearers of the corpse must return direct to the
house from which they started before they may enter another, as it is
unlawful or unlucky to stop, whatever may be the distance to be
traversed. Sea Dayaks who fall in battle are seldom interred, but a
paling is put round them to keep away the pigs, and they are left
there. Those who commit suicide are buried in different places from
others, as it is supposed that they will not be allowed to mix in the
“Seven-storied Sabayau,” or Paradise, with such of their fellow-
countrymen as come by their death in a natural manner, or through
the influence of the spirits.
Black is the sign of mourning among the Indians of North
America, as among us; but among these savage populations grief is
manifested by other signs than the gloomy colour of the dress. The
Crows cut part of their hair on the death of a relation. The widows of
the Foxes, as a sign of mourning, remain several months without
changing their clothes, or paying any other attention to their dress.
This custom is common to many tribes of the north. Among the
Shahonees and several other of the western population, those who
have lost one of their relatives manifest their grief by inflicting on
themselves mutilations and wounds. The mourning of an Indian for
the loss of a relative continues for at least six months. It generally
consists in neglecting his person, and painting his face black. A
widow will generally mourn the loss of her husband for a year. During
all this time she appears sincerely affected, never speaking to any
one unless she is forced to do so from necessity or propriety. She
always seeks solitude, and desires to remain alone, in order to
abandon herself more freely to her affliction. After her mourning is
over, she resumes her best garments, and paints herself as
coquettishly as possible, in order to find another husband.
The customs observed in the burial of the dead differ in different
tribes. The only observance common to them all is the singular one
of painting the corpses black. The Omahas swathe the bodies with
bandages made of skins, giving them the appearance of Egyptian
mummies. Thus enveloped they are placed in the branches of a tree,
with a wooden vase full of dried meat by their side, and which from
time to time is renewed. The Sioux bury their dead on the summit of
a hill or mountain, and plant on the tomb a cedar tree, which may be
seen from afar. When no natural elevation exists, they construct a
scaffolding two or three yards high.
The Chinooks, says the Abbé Dominech (from whose account of
Indian burial customs this description is chiefly derived), and some
other populations of Columbia and Oregon, have a more poetical
custom. They wrap the bodies of their dead in skins, bind their eyes,
put little shells in their nostrils, and dress them in their most beautiful
clothes; they then place them in a canoe, which is allowed to drift at
the pleasure of the winds and currents, on a lake, a river, or on the
Pacific Ocean.
When there is neither lake nor river nor sea near the village, the
funeral canoe is attached to the branches of the loftiest trees. These
aërial tombs are always so placed that the wild animals cannot reach
them; the favourite spots are solitary and wooded islands. These
sepulchral canoes are often moored in little bays, under shady trees
whose thick foliage overhang them like a protecting dome. There are
islands on the large rivers of Columbia where as many as twenty or
thirty of these canoes are attached to the cedars and birches on the
banks.
Not far from Columbia is a rock which serves as a cemetery for
the people of the neighbourhood. One perceives, on examining this
village of death, that the tribes of fishermen bestow the same
religious care on the dead as do the various tribes of hunters. In one
case, as in the other, the favourite objects he used while alive are
placed by his side in death. In Columbia, the oar and the net lie by
the fisherman in his funereal canoe; in the Great Prairies, the lance,
the bow and arrows, and often the war-horse, are buried in the grave
with the hunter. To the east as to the west of the Rocky Mountains,
the savages venerate, respect, and take care of their friends and
relatives even after death. The lamentations and prayers of the
survivors are heard each day at dawn and dusk wherever there are
tombs.
In New Mexico the whites have singularly modified the customs of
the Indians; what remains of their ancient practices bears the
impress at once of the superstitious character of the natives, and of
the habits of the Spaniards. Thus, the inhabitants of Pueblo de
Laguna, who are half Christians, half followers of Montezuma, wrap
the body of the deceased in his ordinary garments, lay him in a
narrow grave of little depth, and place bread and a vase of water
near him. They then throw huge stones upon him with such violence
as to break his bones, with the notion that any evil spirit remaining in
the carcase may be driven out in the process.
The Sacs and Foxes place their dead, wrapped in blankets or
buffalo skins, in rude coffins made out of old canoes or the bark of
trees, and bury them; if the deceased was a warrior, a post is
erected above his head, painted with red lines, indicating the number
of men, women, and children he has killed during his life, and who
are to be his slaves in the land of shadows.
The Tahkalis burn the bodies of their dead. The medicine-man
who directs the ceremony makes the most extraordinary
gesticulations and contortions, for the purpose, as he pretends, of
receiving into his hands the life of the deceased, which he
communicates to a living person by laying his hands on his head,
and blowing on him; the person thus endowed takes the rank of the
deceased, whose name he adds to that he bore previously. If the
dead man had a wife, she is obliged to lay down on the funeral pyre
while it is set on fire, and to remain there till she is almost suffocated
with smoke and heat. Formerly, when a woman endeavoured to
escape this torture, she was carried to the fire and pushed in, to
scramble out how she might. When the corpse is consumed it is the
duty of the widow to collect the ashes, place them in a basket and
carry them away. At the same time she becomes the servant of her
husband’s family, who employ her in all sorts of domestic drudgery,
and treat her very ill. This servitude continues during two or three
years, at the expiration of which period the relatives of deceased
assemble to celebrate the “feast of deliverance.” At this solemnity a
pole five or six yards in height is fixed in the ground, to sustain the
basket containing the ashes of the deceased, which remain thus
exposed till the pole, destroyed by time and the elements, falls down.
The widow then recovers her liberty, and can marry again.
Mr. Paul Kane, in his “Wanderings of an Artist,” describes much
such a ceremony as observed by him in New Caledonia, which is
east of Vancouver’s Island and north of Columbia. Among the tribe
called “Taw-wa-tius,” and also among other tribes in their
neighbourhood, the custom prevails of burning the bodies, with
circumstances of peculiar barbarity to the widows of the deceased.
The dead body of the husband is laid naked upon a large heap of
resinous wood; his wife is then placed upon the body, and covered
over with a skin; the pile is then lighted, and the poor woman is
compelled to remain until she is nearly suffocated, when she is
allowed to descend as best she can through the flames and smoke.
No sooner, however, does she reach the ground, than she is
expected to prevent the body from becoming distorted by the action
of the fire on the muscles and sinews; and wherever such an event
takes place, she must with her bare hands restore the burning body
to its proper position, her person being the whole time exposed to
the intense heat. Should she fail in the performance of this
indispensable rite, from weakness or the intensity of her pain, she is
held up by some one until the body is consumed. A continual singing
and beating of drums is kept up throughout the ceremony, which
drowns her cries.
Afterwards she must collect the unconsumed pieces of bone and
the ashes, and put them in a bag made for the purpose, and which
she has to carry on her back for three years; remaining for a time a
slave to her husband’s relations, and being neither allowed to wash
nor comb herself for the whole time, so that she soon becomes a
very unpleasant object to behold. At the expiration of three years a
feast is given by her tormentors, who invite all the friends and
relations of her and themselves. At the commencement they deposit
with great ceremony the remains of the burnt dead in a box, which
they affix to the top of a high pole, and dance round it. The widow is
then stripped and smeared from head to foot with fish-oil, over which
one of the bystanders throws a quantity of swans’-down, covering
her entire person. After this she is free to marry again, if she have
the inclination and courage enough to venture on a second risk of
being roasted alive and the subsequent horrors.
It has often happened that a widow, who has married a second
husband in the hope perhaps of not outliving him, commits suicide in
the event of her second husband’s death, rather than undergo a
second ordeal.
A Mandan Chief.
Among the Mandans, another tribe of North American Indians,
burial is unknown. A tract of land is set apart, and is known to all the
tribes as the “village of the dead.” When a Mandan dies he is
wrapped in the hide of a freshly-slaughtered buffalo, which is
secured by thongs of new hide. Other buffalo skins are soaked until
they are soft as cloth, and in these the already thoroughly enveloped
body is swathed till the bulk more resembles a bale of goods packed
for exportation than a human body. Within the bundle are placed the
man’s bow and quiver, shield, knife, pipe and tobacco, flint and steel,
and provisions enough to last him some time “on his long journey.”
Then his relatives bear him on their shoulders, and carry him to the
cemetery, “where,” says Catlin, “are numerous scaffolds, consisting
of four upright poles some six or seven feet in height. On the top of
these are small poles passing around from one corner post to
another; across these are placed a row of willow rods, just strong
enough to support the body.”

Mandan Place of Skulls.


On this scaffold, and with his feet towards the rising sun, the
Mandan is laid, and he is not disturbed till the scaffold poles decay,
and the buffalo coffin, still containing the Mandan’s bones, falls to the
earth. Then the relatives of the deceased, having received notice of
the circumstance, once more assemble at the cemetery and, digging
a hole, bury the bones—all except the skull; for this is reserved a
separate ceremony.
Apart from the willow biers may be seen circles of skulls,
numbering from fifty to a hundred, each about nine inches from its
neighbour, and with the face turned towards the centre. In this
ghastly cordon room is made, and the newly fallen skull added
thereto, and ever after regarded with the rest as an object of
veneration, not only by those who can claim with it family
acquaintance, but by the whole tribe. “Very frequently,” says Catlin,
“the traveller may observe a wife, or maybe a mother, of this sad
remnant of mortality sitting down by the side of the skull of its
departed husband or child, talking to it in the most endearing tones,
and even throwing herself down to embrace it, the while bewailing
with loud and incessant cries; very often too they will cut and hack
themselves with knives as a punishment for any offence they may
have given their relative while alive.”
Among the Ojibbeways, as soon as the man is dead, they array
him in his best clothes, and as soon as possible place him in a coffin.
If this latter article is not available, he is wrapped in the best skins or
blankets the tent furnishes. A hole about three feet deep is dug, and
generally within twelve hours of his decease the man is buried, with
his head towards the west. By the side of his body is placed his
former hunting and war implements, such as his bow and arrow,
tomahawk, gun, pipe and tobacco, knife, pouch, flint and steel,
medicine-bag, kettle, trinkets, and other articles which he carried
with him when going on a long journey. The grave is then covered,
and on the top of it poles or sticks are placed lengthways, to the
height of about two feet, over which birch bark or mats form a
covering to secure the body from the rain. The relations or friends of
the deceased then sit on the ground in a circle round the head of the
grave, when the usual offering to the dead, consisting of meat, soup,
or the fire-waters, is made. This is handed to the people present in
bowls, a certain quantity being kept back for a burnt offering. While
this is preparing at the head of the grave, the old man, or speaker for
the occasion, makes a prayer to the soul of the departed,
enumerating his good qualities, imploring the blessing of the dead
that his spirit may intercede for them, that they may have plenty of
game; he also exhorts his spirit to depart quietly from them. They
believe that the soul partakes of a portion of the feast, and especially
that which is consumed by fire. If the deceased was a husband, it is
often the custom for the widow, after the burial is over, to spring or
leap over the grave, and then run zigzag behind the trees, as if she
were fleeing from some one. This is called running away from the
spirit of her husband, that it may not haunt her. In the evening of the
day on which the burial has taken place, when it begins to grow dark,
the men fire off their guns through the hole left at the top of the
wigwam. As soon as this firing ceases, the old women commence
knocking and making such a rattling at the door as would frighten
away any spirit that would dare to hover near. The next ceremony is
to cut into narrow strips like ribbon, thin birch bark. These they fold
into shapes, and hang round inside the wigwam, so that the least
puff of wind will move them. With such scarecrows as these, what
spirit would venture to disturb their slumbers? Lest this should not
prove effectual, they will also frequently take a deer’s tail, and after
burning or singeing off all the hair, will rub the necks or faces of the
children before they lie down to sleep, thinking that the offensive
smell will be another preventive to the spirit’s entrance. “I well
remember,” says the Rev. Peter Jones, a Christianised Ojibbeway
and missionary, “when I used to be daubed over with this
disagreeable fumigation, and had great faith in it all. Thinking that
the soul lingers about the body a long time before it takes its final
departure, they use these means to hasten it away.
“I was present at the burial of an old pagan chief by the name of
Odahmekoo, of Muncey Town. We had a coffin made for him, which
was presented to his relatives; but before they placed the body in it,
they bored several holes at the head, in order, as they supposed, to
enable the soul to go in and out at pleasure.
“During the winter season, when the ground is frozen as hard as a
rock two or three feet deep, finding it almost impossible to penetrate
through the frost, having no suitable tools, they are obliged to wind
up the corpse in skins and the bark of trees, and then hang it on the
fork of a large tree, high enough to be beyond the reach of wolves,
foxes, and dogs, that would soon devour it. Thus the body hangs till
decomposition takes place, and the bones, falling to the ground, are
afterwards gathered up and buried.
“Immediately after the decease of an Indian all the near relatives
go into mourning, by blackening their faces with charcoal, and
putting on the most ragged and filthy clothing they can find. These
they wear for a year, which is the usual time of mourning for a
husband or wife, father or mother.
“At the expiration of a year the widow or widower is allowed to
marry again. Should this take place before the year expires, it is
considered, not only a want of affection for the memory of the dead,
but a great insult to the relations, who have a claim on the person
during the days of the mourning. The first few days after the death of
the relative are spent in retirement and fasting; during the whole of
their mourning they make an offering of a portion of their daily food
to the dead, and this they do by putting a part of it in the fire, which
burns while they are eating. I have seen my poor countrymen make
an offering of the fire-waters to the departed: they deem this very
acceptable, on account of its igniting the moment it touches the fire.
Occasionally they visit the grave of the dead, and there make a feast
and an offering to the departed spirit: tobacco is never forgotten at
these times. All the friends of the dead will for a long time wear
leather strings tied round their wrists and ankles, for the purpose of
reminding them of their deceased relative.”
It is a custom always observed by widows to tie up a bundle of
clothes in the form of an infant, frequently ornamented with silver
brooches. This she will lie with and carry about for twelve months, as
a memorial of her departed husband. When the days of her
mourning are ended, a feast is prepared by some of her relatives, at
which she appears in her best attire. Having for the first time for a
twelvemonth washed herself all over, she looks once more neat and
clean.
The Shahonees bury their dead with everything belonging to
them. The Comanches generally bury a warrior with his arms and his
favourite horse; formerly his wives also shared the same fate, but
this custom has disappeared. Whilst the Sioux put striking marks on
their tombs that they may be easily distinguished, the Comanches
cover them with grass and plants to keep them concealed. Among
the tribes of the west the warriors are still sometimes buried on
horseback, wrapped in their richest dress, with bow in hand, buckler
on arm, the quiver full of arrows slung behind, the pipe and the
medicine-bag hanging to the belt, and supplied with a provision of
tobacco and dried meat sufficient for the voyage to the enchanted
prairies.
The Assineboins, like several other tribes of the great American
desert, never bury their dead, but suspend them by thongs of leather
between the branches of the great trees, or expose them on
scaffoldings sufficiently high to place the body out of reach of the
voracious wild animals. The feet of the corpse are turned towards
the rising sun; and when the scaffoldings fall through old age, the
bones are collected and burned religiously within a circle formed of
skulls. The sacred deposit is guarded, as among the Mandans, by
medicine-trees or posts, from which amulets or medicine-bags are
suspended.
On the death of a member of their tribe, the Potowatomies, the
Ottawas, and several other people of the north, distribute all the
things which belonged to the deceased to his friends. Some of them
are Catholics, and these fix on the tomb a great pole, at the summit
of which floats a banner ornamented with a black cross. Among
these same tribes, when a married man or woman dies, the survivor
pays the debt of the body by giving money, horses, and other
presents to the relatives of the deceased. The Ottawas sacrifice a
horse on the tomb of the dead; they strangle the animal by means of
a noose, then cut off its tail and suspend it to stakes fixed on the
tomb. The women of the Crows also pay the debt of the dead by
making incisions deep in their own flesh. The Chippewas are in the
habit of lighting large fires on the tombs of members of their family
for several nights after the funeral.
As to the origin of this last-mentioned custom nothing is known;
but there exists among the Chippewas a legend which may be worth
the reader’s perusal as throwing some light on the subject.
“Once upon a time, many years ago, a war raged between the
Chippewas and their enemies, and the lands of the hostile tribes
were red with blood. It was then that a party of the Chippewas met a
band of their foes upon an open plain in the country of the Great
Lakes. Meteewan, the leader of the Chippewas, was a brave; his
martial deeds were the song of every youth who looked to obtain
renown in the warpath; and the young squaws talked of them at the
fires. And never did the chief act with more bravery or prudence than
on this occasion. After he had, by the strength of his arm, turned the
battle against his enemies, and while he was giving the great shout
of victory, an arrow quivered in his breast, and he fell upon the plain.
No Indian warrior killed thus is ever buried. According to old custom,
he was placed in a sitting posture upon the field of battle, his back
supported by a tree, and his face turned towards the path in which
his enemies had fled. His spear and club were placed in his hands,
and his bow and quiver leaned against his shoulder. So they left him.
“He heard them recount their valiant deeds.”
“But was he gone to the land of spirits? Though he could not
move, nor speak, he heard all that had been said by his friends. He
heard them bewail his death and could not comfort them; he heard
them speak of his great deeds; he heard them depict the grief of his
wife when she should be told he was dead. He felt the touch of their
hands, but his limbs were bound in chains of strength, and he could
not burst them. His thoughts flowed as free as the great rivers; but
his limbs were like the fallen branches. His anguish, when he felt
himself thus abandoned, was heavy; but he was compelled to bear
it. His wish to follow his friends who were about to return to their
wigwams so filled his mind, that, after making a violent exertion, he
rose, or seemed to rise, and followed them.
But he was invisible; they neither saw his form nor heard his
voice. Astonishment, disappointment, rage filled him, while he
attempted to make himself heard, seen, or felt, and could not; but
still he followed on their track. “Wherever they went, he went; when
they walked, he walked; when they ran, he ran; when they built their
fires, and sat down, his feet were in the embers; when they slept, he
slept; when they awoke, he awoke. He heard them recount their
valiant deeds, but he was unable to tell them how much his own
exceeded theirs; he heard them paint the joys which awaited their
return to their wigwams, but could not say how much peace and how
much love was in his.
“At length the war-party reached their village, and the women and
children came out to welcome their return. The old warrior whom
weakness had compelled to throw down the bow and the spear, and
the eagle-eyed boy who was fast hastening to take them up, did
each his part in making joy. The wife came forward with embraces,
the timid maiden with love weighing on her eyelids, to meet their
braves. And if an old warrior found not his son, he knew he had
fallen bravely, and grieved not; and if the wife found not her
husband, she wept only a little while: for was he not gone to the
great Hunting Grounds?
“Still no one seemed conscious of the presence of the wounded
chief. He heard many ask for him; he heard them say that he had
fought, conquered, and fallen, pierced through his breast with an
arrow, and that his body had been left among the slain.
“‘It is not true,’ replied the indignant chief with a loud voice. ‘I am
here; I live! I move! See me! touch me! I shall again raise my spear
and bend my bow in the war path; I shall again sound my drum at
the feast.’ But nobody knew of his presence; they mistook the
loudest tones of his voice for the softest whisperings of the winds.
He walked to his own lodge; he saw his wife tearing her hair, and
bewailing him. He endeavoured to undeceive her, but she also was
insensible to his presence or his voice. She sat despairing, with her
head upon her hands. He told her to bind up his wounds, but she
made no reply. He then placed his mouth close to her ear and
shouted, ‘Give me food.’ The wife said, ‘It is a fly buzzing.’ Her
enraged husband struck her upon the forehead. She placed her
hand to her head and said, ‘It is a little arrow of pain.’
“Foiled thus in every attempt to make himself known, the chief
began to think upon what he had heard the priests and wise men
say, that the spirit sometimes left the body, and might wander. He
reflected that possibly his body had remained upon the field of battle,
while his spirit only accompanied his returning companions. He
determined then to return upon their track, though it was four days’
journey. He went. For three days he pursued his way, and saw
nothing; but on the fourth, at evening, as he came to the skirts of the
battle-field, he saw a fire in the path. He walked on one side to avoid
stepping into it, but the fire also went aside, and was still before him.
He went another way, but the fire still burned in his path. ‘Demon!’ he
exclaimed at length, ‘why dost thou keep my feet from the field of
battle, where my body lies? Knowest thou not that I am a spirit also,
and seek again to enter that body? Or dost thou say I shall return
and do it not? Know that I am a chief and a warrior, well tried in
many a hard battle—I will not be turned back.’
“So saying, he made a vigorous effort, and passed through the
flame. In this exertion he awoke from his trance, having lain eight
days on the field. He found himself sitting on the ground, with his
back to a tree, and his bow leaning against his shoulder, the same
as they had been left. Looking up, he beheld a large canieu, a war-
eagle, sitting upon the tree above his head. Then he knew this bird
to be the same he had dreamed of in his youth, and which he had
taken as his guardian spirit, his Manitou. While his body had lain
breathless, this friendly bird had watched it. He got up and stood
upon his feet; but he was weak, and it was a long time before he felt
that his limbs were his. The blood upon his wound had stanched
itself; he bound it up. Possessing, as every Indian does, the
knowledge of medicinal roots, he sought diligently in the woods for

You might also like