首页 | 代码中心 | 源码下载 | 用户管理 | 用户留言 | 导航 | 繁體
代码秀,专业程序代码提供商(源码下载,编程技术)
扫雷 <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){ for (i=0; i=0) && (x1=0) && (leftValue>=0)) markSquare (bottomValue, leftValue) if ((topValue>=0) && (rightValue>=0)) openSquare(topValue, rightValue) } //-------------------------------------------------------------------------- function showAll() // displays the area like it is represented in the array { var x,y; stopClock(); // init. display for (x=0; x 扫 雷 用时: 剩余雷数: 特别说明:如网页特效代码中有引用图片文件等,请自己下载到本地调试!