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

Saving/Loading Maps in Weltmeister

Save your map by hitting Save at the top of the editor. You will notice that, by default, Weltmeister wants to put levels in the lib/game/levels/ directory. This is very important, because this is where Impact will automatically look for your game’s levels. Later on, we will be able to simply tell Impact to load your level by name instead of having to pass it the full directory path.

Levels are automatically saved inside the game’s levels directory.

Figure 4-6. Levels are automatically saved inside the game’s levels directory.

Let’s name our level dorm1.js. Note that we have to add the .js file extension to our level. The level file is actually a JSON file. The editor will give you an error if you forget to add the correct extension.

Note

It’s important to note that you will need to have PHP set up in order to save. The editor itself is built with JavaScript, but the save API uses PHP. This should be handled automatically if you’re using the recommended MAMP or XAMP applications discussed in Chapter 1.

You can also easily load any level you have created by selecting Load from the top menu.

It is easy to load any level you have already created.

Figure 4-7. It is easy to load any level you have already created.

You will see a list of all the maps you have created. By default, Weltmeister automatically attempts to load the last level you were working in.

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