Javascript Sokoban game script

I’ve always been addicted to logic games and Sokoban is one of them.

From Wikipedia: Sokoban (warehouse keeper) is a transport puzzle in which the player pushes boxes around a maze, viewed from above, and tries to put them in designated locations. Only one box may be pushed at a time, not two, and boxes cannot be pulled. As the puzzle would be extremely difficult to create physically, it is usually implemented as a video game.

In some cases Javascript is not the ideal language to code puzzle games, because the player can read the code and have a clue about the puzzle. Just imagine a Minesweeper game in Javascript… a brief look at the code and you’ll know where the bombs are.

In Sokoban, reading the code is useless because you don’t play in a static level, but level changes as you move your player pushing blocks.

At this time the script is very essential, and contains just one level, but I am going to push (yes, talking about sokoban, I obviously “push”) the script very far away, including level editors, leagues and even more.

Every single line of the script will be explained, as usual, meanwhile you can watch the code from your browser.

Can you solve the level? Can you tell me where did I rip the main sprite?

Improve the blog rating this post
Tell me what do you think about this post. I'll write better and better entries.
1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 5 out of 5)
Loading ... Loading ...

10 Responses to “Javascript Sokoban game script”

  1. Michael on September 9th, 2007 7:39 am

    Wow, truly amazing! Would be nice for a ‘reload level’ button, since I absolutely suck at it, lol.

    Always interesting how JavaScript can actually make some cool games. The only other cool script I’ve seen really though, is one for a JavaScript-based Battleship, complete with an A.I. that never tries the same spot twice, and can continuously try to attack around a spot if it hits a ship.

    Real cool stuff, keep it up!

  2. galaxy on September 9th, 2007 11:23 am

    hard!! i did it in 35 moves :).

  3. Emanuele Feronato on September 9th, 2007 4:21 pm

    The game can be solved in 33 moves…

  4. galaxy on September 9th, 2007 6:12 pm

    yes i pushed the boxes in the wrong oder.
    i got it now.
    did you make that level? its a nice level anyway.
    what has happen here? why is the main text on the left side now? it makes some pages with AS on them move the boarder to the right.

  5. 0wned on September 10th, 2007 10:37 am

    great game cant wait to see how its done!

  6. Kayn on September 10th, 2007 11:33 am

    It’s Marle, from Chrono Trigger methinks… :)
    Nice puzzle though - you’re right, some puzzles lend themselves well to formats like this. They’re mainly of the type where all the information you need is already viewable on the screen and no amount of source reading can help you.

  7. Monkios on September 10th, 2007 4:30 pm

    I guess a minesweeper would be possible using Javascript without letting the user see the solution in the source.

    It would be an interesting project ..

    Nice sokoban, by the way.

  8. Seth Caldwell on September 11th, 2007 1:58 am

    actually 31 ;)
    these graphics totally remind me of a project I made where I ripped the blocks from the original nes mario for a 2d adventure dos game =D

    And this puzzle game reminds me of solomon’s key.

  9. Thomas on September 20th, 2007 8:03 am

    OK. I give up. Where did you rip the main sprite? Amazing JS, by the way!

  10. A “very old” Flash Sokoban prototype : Emanuele Feronato - italian geek and PROgrammer on November 13th, 2007 5:57 pm

    [...] I plan to work on a Flash version of Sokoban someday, meanwhile you could have a look to my Javascript version. [...]

Leave a Reply