Workshop › Sokoban › Step 12 of 29
Two more levels
What we are doing
Because a level is only text, adding one is just writing it. We add a small room with two boxes and a harder level
with seven.
```js
[
'######',
'# #',
'# $ #',
'# .. #',
'# @ #',
'######',
],
[
' #####',
'### #',
'#.@$ #',
'### $.#',
'#.##$ #',
'# # . ##',
'#$ *$.#',
'# . #',
'########',
],
```
What it means
- Each level is one more item of
LEVELS, separated by commas.
- A space is floor. Rows can have different lengths;
cols takes the longest.
* in the third level is a box already on a goal.
Your turn
Inside LEVELS, under the first level's ],, write the two new levels. Press Run.
Skills: Arrays and objects
← The player One step →
All steps
- A level written as text
- The canvas and the pen
- The warehouse floor
- A function that draws
- A name for every tile
- Read the walls
- Draw the walls
- Center the level
- The goals
- The boxes
- The player
- Two more levels
- One step
- Walk with the arrows
- Boxes are in the way
- Push a box
- A box on a goal turns green
- Solved!
- On to the next level
- Which level?
- A line at the bottom
- Count the moves
- A photo of the game
- A photo before every move
- Undo
- Restart
- A record for every level
- Show the record
- Build it yourself: count the pushes