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?
12 Responses to “Javascript Sokoban game script”
Leave a Reply
Trackbacks
-
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. [...]
-
Trying to solve a Sokoban level with brute force : Emanuele Feronato on
January 22nd, 2009 12:02 am
[...] If you want to see another Sokoban script (this time to play the game), read Javascript Sokoban game script. [...]
-
GameJS and gameQuery: two javascript libraries for game developers : Emanuele Feronato on
March 5th, 2009 12:00 am
[...] Flash action games, I am sure you can code some decent puzzle games. Some months ago I made a Sokoban prototype using Javascript and the game worked pretty well, being Javascript [...]
- Citrus Engine released for free for learning
- My epic fail with ClickBank
- Get up to $100,000 for your next Flash game with Mochi GAME Developer Fund
- Create a dynamic content animated footer ad for your site in just 9 jQuery lines – 17 lines version
- Sell sitelocked version of your Flash games and even .fla sources to Free Online Games
- Protect your work from ActionScript code theft with SWF Protector
- Create a dynamic content animated footer ad for your site in just 9 jQuery lines
- Understanding Box2D’s one-way platforms, aka CLOUDS
- Triqui MochiAds Arcade plugin for WordPress upgraded to 1.2
- Box2D Flash game creation tutorial – part 2
- Create a Lightbox effect only with CSS - no javascript needed
- Flash game creation tutorial - part 1
- Create a Flash Racing Game Tutorial
- Flash game creation tutorial - part 2
- Make a Flash game like Flash Element Tower Defense - Part 2
- Flash game creation tutorial - part 3
- Make a Flash game like Flash Element Tower Defense - Part 1
- Create a flash draw game like Line Rider or others - part 1
- Triqui MochiAds Arcade plugin for WordPress official page
- Create a flash artillery game - step 1
- Flash game creation tutorial – part 5.2 (4.88/5)
- Create a flash artillery game – step 1 (4.79/5)
- Create a Flash Racing Game Tutorial (4.76/5)
- Create a survival horror game in Flash tutorial – part 1 (4.74/5)
- Create a flash artillery game – step 2 (4.74/5)
- Creation of a Flash arcade site using WordPress – step 2 (4.73/5)
- Flash game creation tutorial – part 1 (4.71/5)
- Flash game creation tutorial – part 2 (4.71/5)
- Create a flash draw game like Line Rider or others – part 1 (4.69/5)
- Creation of a platform game with Flash – step 2 (4.68/5)


(12 votes, average: 3.42 out of 5)



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!
hard!! i did it in 35 moves :).
The game can be solved in 33 moves…
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.
great game cant wait to see how its done!
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.
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.
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.
OK. I give up. Where did you rip the main sprite? Amazing JS, by the way!