An implementation of Sokōban in JavaScript, as a jQuery plugin. It parses and runs the de-facto standardized Sokoban puzzle notation, is capable of running multiple games and includes a separate undo buffer for each one. It's about 300 lines of code.
-
Include a reference to the plugin (and jQuery) to the
<head>
section of your document:<script src="jquery.min.js"></script> <script src="jquery.sokoban.js"></script>
-
Add a Sokoban puzzle to your HTML document:
<pre class="sokoban> #### # .# # ### #*@ # # $ # # ### #### </pre>
-
Run the game when the document loads:
<script> jQuery(function($){ $('pre.sokoban').sokoban(); }); </script>
- Consider adding CSS styles to make the levels look nicer (some are included in the project).