Cross Over to HTML5 Game Development: Use Your Programming Experience to Create Mobile Games 1st Edition Zarrar Chishti (Auth.) 2024 Scribd Download
Cross Over to HTML5 Game Development: Use Your Programming Experience to Create Mobile Games 1st Edition Zarrar Chishti (Auth.) 2024 Scribd Download
com
https://textbookfull.com/product/cross-over-to-html5-game-
development-use-your-programming-experience-to-create-
mobile-games-1st-edition-zarrar-chishti-auth/
OR CLICK BUTTON
DOWNLOAD NOW
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/
textboxfull.com
https://textbookfull.com/product/create-computer-games-design-and-
build-your-own-game-patrick-mccabe/
textboxfull.com
https://textbookfull.com/product/uncopyable-how-to-create-an-unfair-
advantage-over-your-competition-2nd-edition-steve-miller/
textboxfull.com
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/
textboxfull.com
https://textbookfull.com/product/work-on-your-game-use-the-pro-
athlete-mindset-to-dominate-your-game-in-business-sports-and-life-dre-
baldwin/
textboxfull.com
https://textbookfull.com/product/game-programming-in-c-
creating-3d-games-creating-3d-games-sanjay-madhav/
textboxfull.com
https://textbookfull.com/product/nlp-made-easy-how-to-use-neuro-
linguistic-programming-to-change-your-life-ali-campbell/
textboxfull.com
https://textbookfull.com/product/uncopyable-how-to-create-an-unfair-
advantage-over-your-competition-updated-and-expanded-edition-steve-
miller/
textboxfull.com
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
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
iii
Table of Contents
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
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
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
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)
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.
Let’s have a look at a few of the graphics that we will use for the
development.
2
Chapter 1 Introduction
3
Chapter 1 Introduction
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
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.
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:
7
Chapter 1 Introduction
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.
8
Chapter 1 Introduction
9
Chapter 1 Introduction
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.
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:
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
http://www.win-rar.com/download.html
14
CHAPTER 2
In the Beginning,
There Was HTML
“Nine people can’t make a baby in a month.”
Fred Brooks
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
Exploring the Variety of Random
Documents with Different Content
back
back
back
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
textbookfull.com