Minesweeper is a jQuery plugin that displays a classic Windows minesweeper game on a page
If you just want to play or see the example in action here is a Minesweeper example.
These browsers were tested and passed. So far only browser that is definitly not supported is IE 6 (and I assume any previous versions of IE)
.Include javascript files in your <head>
:
<script type="text/javascript" src='http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js'></script>
<script type="text/javascript" src="http://minesweeper.tomasreichmann.cz/minesweeper-0.9.js"></script>
I recommend calling the plugin from a script inserted right above your </body>
and ensuring it will be executed after DOM is ready like so:
<script type="text/javascript" >//<![CDATA[
$(document).ready(function() {
$("#board").minesweeper(); // this is how the minesweeper plugin is called.
//In this case while no settings are set menu will appear
});
//]]></script>
If you run the plugin without options, it will display menu and try to load last used settings from local storage.
Or you can supply these settings (defaults):
$("#board").minesweeper({
cols: 9, // (integer) Number of columns for playing board.
rows: 9, // (integer) Number of rows for playing board
mines: 10, // (integer) Total number of mines on the field # > 0 && # < cols*rows
difficulty: "beginner" , // (string) A shortcut for cols, rows and mines setting. cols, rows, mines take precedents if also difficulty is set [beginner, advanced, expert, custom]
debug: false // (boolean) with true logs events into firebug console
});
Option { debug: true } will dump a lot of usefull information about whats going on inside the plugin into Firebug console.
$("#standard-beginners-game").minesweeper({ "difficulty":"beginner" }); // standard beginners game with difficulty: beginner option
$("#no-options-game").minesweeper(); // game with no options will display a menu
$("#sample-custom-game").minesweeper({ "cols": 16, "rows": 16, "mines": 48 }); // custom game 16x16 with 48 mines
$("#unusual-game").minesweeper({ "cols": 10, "rows": 1, "mines": 5 }); // unusual game setup
$("#easiest-game").minesweeper({ "cols": 20, "rows": 20, "mines": 399 }); // You will always win this on the first try because a feature prevents you from stepping on a mine on the first cell
Landmine is a one of the most terrible inventions of humankind along with atom bomb, torture and other products of war and violence. Please consider supporting International Campaign to Ban Landmines.
This is my first plugin. I hope you will have a lot of fun with it. Feel free to use it any way you like. It is licenced under GPL
Copyright © 2011 Tomas Reichmann
http://tomasreichmann.cz/
tr@tomasreichmann.cz