打印本文 打印本文 关闭窗口 关闭窗口
扫雷
作者:武汉SEO闵涛  文章来源:敏韬网  点击数618  更新时间:2009/4/23 11:14:34  文章录入:mintao  责任编辑:mintao

说明: 扫雷

效果: 运行后查看!

代码:


<html>
<head>
<title>扫雷</title>
<script language="JavaScript">
<!-- hide code from old browsers
var BOMB = " * ";
var NOBOMB = "";
var MARKED = " X ";
var constModul = 0.0;
var constFactor = 0.0;
var constMove = 0.0;
var pseudoRandomNumber = 0.0;
var constXSize = 5;
var constYSize = 5;
var constBombAmnt = 5;
var squaresCleared = 0;
var firstTime=false;
var topValue=-1;
var rightValue=-1;
var bottomValue=-1;
var leftValue=-1;
var array;
var startTime;
var timerID = null;
var timerRunning = false;
//-------------------------------------------
function stopClock (){
if(timerRunning)
clearTimeout(timerID);
timerRunning = false;
}
//-------------------------------------------
function startClock (){
// Make sure the clock is stopped
stopClock();
startTime = new Date();
showTime();
}
//--------------------------------------------
function diffSeconds (t1, t2){
// returns the difference between t1 (hh:mm:ss)
// and t2 (hh:mm:ss) in seconds!
return (t2.getHours()*3600 + t2.getMinutes()*60 +
t2.getSeconds()) - (t1.getHours()*3600 + t1.getMinutes()*60
+ t1.getSeconds());
}
//---------------------------------------------
function showTime (){
document.info.time.value = diffSeconds(startTime, new Date());
timerID = setTimeout("showTime()",1000);
timerRunning = true;
}

//---------------------------------------------
function initRandom(){
// initialize random number generator
var now = new Date();
var hours = now.getHours();
var minutes = now.getMinutes();
var seconds = now.getSeconds();
constModul = Math.pow(2,48);
constFactor = 513.0
constMove = 29741096258473.0;
pseudoRandomNumber = (hours+minutes*60+seconds*3600);
}
//--------------------------------------------
function random(){
// returns the next pseudo-random number [0,1]
pseudoRandomNumber = (constFactor*pseudoRandomNumber
+constMove)%constModul;
return (pseudoRandomNumber / constModul);
}
//--------------------------------------------
function getArrayAt(x, y, value){
// Access-method of object-type ObjArray
// x,y are zero-based
return this[y*this.xSize+x];
}
//---------------------------------------------
function putArrayAt(x, y, value){
// Access-method of object-type ObjArray
// x,y are zero-based
this[y*this.xSize+x] = value;
}
//----------------------------------------------
function ObjArray(xSize, ySize){



打印本文 打印本文 关闭窗口 关闭窗口