O'Reilly logo

Building HTML5 Games with ImpactJS by Jesse Freeman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Baking Your Game

Baking will combine all your game files into a single file, which helps shorten the download time and compress the game.

You can run the bake script by doing the following:

Mac

Open up a terminal window, navigate to the tools/ directory, and write ./bake.sh.

Windows

For Windows, double-click the bake.bat file in the tools/ directory. You also have to make sure that bake.bat can find php.exe on your system. You can either add the installation path of PHP to your PATH environment variable, or edit bake.bat to point directly to php.exe.

If you get an error message, make sure all the paths are correct. You can open bake.bat or bake.sh with a text editor. The only two lines you should ever need to change are these:

SET GAME=lib/game/main.jsSET OUTPUT_FILE=game.min.js

The GAME variable should point to your game’s main.js file while the OUTPUT_FILE determines where the baked script file will be written.

If the script finishes without errors, you can find game.min.js in your Impact directory. You can now load this one .js file in your .html instead of the two files you had previously. Open up your index.html file and change the following lines:

<script type="text/javascript" src="lib/impact/impact.js"></script>
<script type="text/javascript" src="lib/game/main.js"></script>

to this:

<script type="text/javascript" src="game.min.js"></script>

Once you have correctly baked your game, you are ready to upload the game.min.js source file along with your media directory to your server. You ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required