This is a small game template including a basic render loop where you can move the player around.
There are a few ways to get this template:
If you use Git:
git clone https://github.com/mozilla/mortar-game-stub.git
Or download the latest version in this ZIP file.
Start a local server to simulate accessing the hosted app from the browser, and trying the Install button flow.
python -m SimpleHTTPServer 8000
your.computer.ip:8000 (for example,
192.168.0.25) using Firefox (Desktop or Mobile), or the Browser app in a Firefox OS simulator (or device).
You'll need to use the IP address when using a physical device. Change the port accordingly, if you're running a webserver in this port already.
The game logic is defined in
js/app.js. This is where we define the player entity, and set up the render loop, and the input and install handlers. In the interest of keeping things tidy and easy to follow, we have extracted the code for
install onto two files (
js/install.js) that we then reference in
index.html, right before
If you're interested in reading more about how game loops work, you are strongly advised to read Anatomy of a video game, an article describing all these topics.