How to add more levels to a game in WoofJS

2D Game Design with WoofJS

🕑 This lesson will take about 10 minutes

In this lesson, you will learn how to add a second level to a game in WoofJS, as shown in the example below. An integer variable will be used to track which level the player is currently up to. When the player progresses in the game, the level variable will be increased by 1. Code in the forever loop block checks which level the player is up to and runs the relevant code for that level.

Create a new project at woofjs.com and use the following code to implement this feature. Make sure you pay attention to the comments in the code that explain how it works.