日期:2009-06-19  浏览次数:21361 次

没有图片,大家自己做吧:-(
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
dir = "";

var mines = [];
var shown = [];
var gridx, gridy, maxmines;
gridx = window.prompt("请输入你想要的行数","8");
gridxverify();
function gridxaccept(){
gridy = window.prompt("请输入你想要的列数","8");
gridyverify();
}
function gridyaccept(){
maxmines = window.prompt("请输入你想要的地雷数目","10");
maxminesverify();
}
function gridxverify(){
if (gridx > 50){
alert("你输入的数字不能超过50.");
gridxreenter();
}
else if (gridx < 8){
alert("你输入的数字不能小于8.");
gridxreenter();
}
else gridxaccept();
}

function gridyverify(){
if (gridy > 50){
alert("That height is too big. Please enter a new height.");
gridyreenter();
}
else if (gridy < 8){
alert("That height is too small. Please enter a new height.");
gridyreenter();
}
else gridyaccept();
}
function maxminesverify(){
if (maxmines > 500){
alert("That number is too big. Please enter a new number of mines.");
maxminesreenter();
}
else if (maxmines < 10){
alert("That number is too small. Please enter a new number of mines.");
maxminesreenter();
}
else accepted();
}
// Functions for reentering key variables, if necessary.
function gridxreenter(){
gridx = window.prompt("Please enter a width.","8");
gridxverify();
}
function gridyreenter(){
gridy = window.prompt("Please enter a height.","8");
gridyverify();
}
function maxminesreenter(){
maxmines = window.prompt("Please enter the number of mines you want.","10");
maxminesverify();
}
function accepted(){
var squaresleft, flagsleft;
var elapsedtime;
var playing;
var placeflag;
var clicked;
}
var gridSq = gridx * 16;
var grid8 = gridSq - 128;
var grid16 = gridx - 8
var grid32 = grid16 * 8
var grid64 = grid16 * 16
var topBarWidth = 8 + grid64;
var menuBarWidth = 86 + grid64;
var wideWidth = gridx * 16;
var highHeight = gridy * 16;
var cplLeft = 6 + grid32;
var cplRight = 4 + grid32;
var totalWidth = gridSq + 32;
var tW6 = totalWidth - 6;
var ww2 = wideWidth + 2;
num=new Array(10);
for (var i=0;i<10;i++) {
num[i]=new Image()
num[i].src=../../i+".gif"
}
function keyDown(e) {
if(document.layers)
placeflag = (e.modifiers & Event.CONTROL_MASK) > 0;
else
placeflag = window.event.ctrlKey;
setStatus();
}
function keyUp(e) {
placeflag = false;
setStatus();
}
function newgame() {
// reset state arrays. mines holds the position of each mine. shown keeps
// track of the image shown at each grid location
var y;
for(y = 0; y < gridy; ++y)
{
mines[y] = [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false];
shown[y] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
}
// Place the mines, making sure positions are unique
var m;
for(m = 0; m < maxmines; ++m) {
var x,y;
do {
x = Math.floor(Math.random() * gridx);
y = Math.floor(Math.random() * gridy);
} while(mines[y][x]);
mines[y][x] = true;
}<