137 : Keys for level 2 and 3
Balthazar:
We can add a key to level 2
function init_level2() {
...
add_default_platforms(level);
var item_data = [
[250, 360, 18, 20, "key", "key"],
];
add_items(level, item_data);
level.goal = create_goal(500, 360, 2);
...
}
Balthazar:
Rather than add a key to level 3 (which would just allow us to loop back to level 1 in any case), we can add a new item that ends the game when you acquire it.
Balthazar:
Copy the gem.png image into the images/items directory.
Copy the following files into your project:
function init_level3() {
...
add_default_platforms(level);
var item_data = [
[500, 360, 21, 27, "finish", "gem"],
];
add_items(level, item_data);
level.goal = create_goal(500, 360, 0);
_levels.push(level);
}
Balthazar:
Note that you the goal doesn't indicate whether or not it is currently locked. We'll can fix that now.
GOTO 113 if you already have the Platform III - Pattern badge.
GOTO 141