HTML and CSS Reference
this.y = Game.height - Game.playerOffset - this.h;
The player will now be set up off the bottom of the screen as is appropriate for the device to prevent the
control buttons from obscuring gameplay.
Testing on Mobile
To test this game on an actual mobile device, you need to run the game on a web server, either by setting one up
on your development machine or by deploying the code to a web host. Both of these methods are a bit outside
the scope of this topic.
NOTE You can find lots of hosting companies on the web of varying quality. DreamHost ( ht-
In the long run, you need to test your games without having to deploy them. This enables you to make
changes and quickly test them without any intermediate steps to slow down the process. If you use Windows,
you can most likely install IIS, depending on your version of Windows, but IIS configuration can be involved
and, unless you're comfortable with window configuration tasks, you may want to use one of the following op-
tions. If you use a Mac, you can access Web Sharing from the Sharing section of System Preferences. On Linux
you can install Apache.
If getting a fully configured web server seems daunting, you can check out WAMP at ht-
tp://www.wampserver.com/en/ . WAMP is a project designed to give you a zero-configuration Apache server on
Windows. Web sharing on OS X and native packaging of Apache on Linux is usually a better option for the oth-
er platforms. For simple needs you can also try mongoose at http://code.google.com/p/mongoose/ , a web server
that you execute from the directory you want to serve.
Assuming you are on a network with Wi-Fi, and your development machine and your mobile device are on
the same network, you should now access your development machines from your mobile device when you have
a web server set up and configured and your files are in the proper location. (This depends on the server and
Look up the IP address for your machine on the local network. This is most likely different from the Public
IP address that machines on the web see because most Wi-Fi networks are behind a router. To find your IP ad-
dress on Windows, the easiest way is to bring up the Command Prompt program (usually in Accessories) and
type ipconfig .
You should see a number that looks like xxx.xxx.xxx.xxx (usually something like 192.168.0.50 )
in addition to some other cruft. You may see a couple of other IP addresses that end in 1, such as 192.168.0.1.
This is the gateway address and not the address of your computer.
On a Mac or Linux, bring up Terminal and type ifconfig .
On Linux you may need to type sudo ifconfig . Again you should see a number that looks like an IP
address among a bunch of other lines of information.
Armed with that IP address and the path underneath the document root (the directory where your web server
serves files from) of your game, you should now bring up your game on a mobile device by typing in the IP
address followed by the path. You can also run the version of the game to this point at http://mh5gd.com/ch3/