HTML5 swipe controlled Sokoban game made with Phaser featuring unlimited undos – solving and advancing through levels

In this new step of the Sokoban series I am showing you how to check if the player solved a level, and how to advance through levels.

The concept is very simple: a level is solved when there aren’t crates outside target spots, which means when the level array does not have an item with CRATE value in it.

Have a look at the game:

Swipe to move the player, double click/tap to undo last move. If you have a mobile device, you can play the game at this link.

The first level is ridiculously easy to solve, just to show you how to check for a level to be solved and advance through levels.

This is the source code, with new or modified lines highlighted. I did not highlight each level changed to level[this.currentLevel] not to create a visual mess, but you should keep in mind level was transformed from a two-dimensional array into a three-dimensional array.

Next time I will add more levels and a level selection screen, meanwhile download the source code.

  • Vas

    Very good structed code, like

  • What a great learning tool thanks! I see you have removed the arrow key functionality. :( I am trying to add it back for desktop compatibility but having trouble. Do you have any pointers? Thanks!