扫雷JS程序Word下载.docx
- 文档编号:8354163
- 上传时间:2023-05-11
- 格式:DOCX
- 页数:12
- 大小:17.40KB
扫雷JS程序Word下载.docx
《扫雷JS程序Word下载.docx》由会员分享,可在线阅读,更多相关《扫雷JS程序Word下载.docx(12页珍藏版)》请在冰点文库上搜索。
clear:
both;
.outGrid{
filter:
alpha(opacity=100);
-moz-opacity:
1;
-khtml-opacity:
opacity:
burlywood;
solidbeige1px;
.disOutGrid{
alpha(opacity=0);
0.0;
.redOutGrid{
guessOutGridfilter:
red;
color:
white;
.guessOutGrid{
/style>
/head>
body>
formaction="
javaScript:
createContent()"
<
divid="
message"
style="
color:
display:
none;
"
booNummustlessthanxyNum*xyNum<
/div>
br/>
xyNum:
inputid="
xyNum"
type="
number"
required="
true"
name="
points"
min="
1"
max="
50"
/>
booNum:
booNum"
2500"
inputtype="
submit"
value="
OK"
1.Inputthewidth<
2.Inputthenumberofray(raynumberislessthanthewidth*width)<
3.Clickok<
Therightmousebutton:
Thefirsttime:
markyourguess<
Thesecondtime:
confirmyourguess<
TheThirdtime:
cancelthetag<
/form>
divstyle="
position:
relative;
margin:
20px20px;
content"
outcontent"
absolute;
top:
0px;
script>
document.oncontextmenu=function(e){
e.preventDefault();
};
varxyNum=document.getElementById('
xyNum'
),
booNum=document.getElementById('
booNum'
message=document.getElementById('
message'
content=document.getElementById('
content'
outcontent=document.getElementById('
outcontent'
commonFunction={
getPromptArray:
function(xyL,BIndex){
varresultArry=[];
//["
x1y1"
"
x2y2"
x3y3"
];
BIndex:
[[0,1],[3,1]]
varresultObj={};
varbx=0,
by=0;
functioncalculateA(item){
bx=item[0];
by=item[1];
if(bx>
0){
resultArry.push('
x'
+(bx-1)+'
y'
+(by));
}
if(bx<
xyL-1){
+(bx+1)+'
if(by>
+(bx)+'
+(by-1));
if(by<
+(by+1));
0&
&
by>
by<
xyL-1&
}
functiongetResultObj(arr){
varobj={};
for(varai=0;
ai<
arr.length;
ai++){
varitem=arr[ai];
if(obj[item]==null)obj[item]=1;
elseobj[item]=obj[item]+1;
returnobj;
for(varbi=0;
bi<
BIndex.length;
bi++){
varBitem=BIndex[bi];
//[0,1]
calculateA(Bitem);
resultObj=getResultObj(resultArry);
returnresultObj;
},
getBIndex:
function(xyn,boo){
varresult=[];
varxy=[];
functioncanAddRes(){
xy=result[result.length-1];
for(varl=0;
l<
result.length-1;
l++){
if(result[l][0]==xy[0]&
result[l][1]==xy[1]){
returnfalse;
}
returntrue;
};
for(vari=0;
i<
boo;
i++){
varx=parseInt(Math.random()*xyn);
vary=parseInt(Math.random()*xyn);
result[i]=[x,y];
if(!
canAddRes()){
i--;
returnresult;
getInnerArea:
function(){
if(xyNum.value*xyNum.value<
booNum.value){
message.style.display='
block'
;
returnfalse;
}else{
while(content.hasChildNodes()){
content.removeChild(content.firstChild);
varoFrag=document.createDocumentFragment();
varBIndex=[];
BIndex=commonFunction.getBIndex(xyNum.value,booNum.value);
for(varxi=0;
xi<
xyNum.value;
xi++){
varoLi=document.createElement("
div"
);
oLi.id='
+xi;
for(varyi=0;
yi<
yi++){
varoDiv=document.createElement("
oDiv.id='
+xi+'
+yi;
oDiv.className='
innerGrid'
oLi.appendChild(oDiv);
if(yi==xyNum.value-1){
varendDiv=document.createElement("
endDiv.className="
clearBoth"
oLi.appendChild(endDiv);
oFrag.appendChild(oLi);
content.appendChild(oFrag);
varpromptObj=commonFunction.getPromptArray(xyNum.value,BIndex);
//{'
x1y1'
:
2}
for(varpIteminpromptObj){
document.getElementById(pItem).textContent=promptObj[pItem];
for(varBi=0;
Bi<
Bi++){
document.getElementById('
+BIndex[Bi][0]+'
+BIndex[Bi][1]).textContent="
b"
returntrue;
getOutArea:
while(outcontent.hasChildNodes()){
outcontent.removeChild(outcontent.firstChild);
oLi.id=xi;
oDiv.id=xi+'
outGrid'
outcontent.appendChild(oFrag);
checkEnd:
if(document.getElementsByClassName('
disOutGrid'
).length<
xyNum.value*xyNum.value-booNum.value){
LClickButton:
function(elem){
varresult=false;
varid=this.id;
varinterX=parseInt(id.split("
y"
)[0]);
varinterY=parseInt(id.split("
)[1]);
vardoc=document.getElementById('
+interX+'
+interY);
if(elem.button==2){
if(this.className=='
){
this.className='
guessOutGrid'
this.textContent='
?
'
result=false;
}elseif(this.className=='
redOutGrid'
7'
}elseif(elem.button==0){
if(this.className=='
){
}elseif(this.className!
='
returnfalse;
}elseif(doc.textContent=='
b'
alert('
youarefail'
while(outcontent.hasChildNodes()){
outcontent.removeChild(outcontent.firstChild);
}elseif(doc.textContent!
result=true;
}else{
commonFunction.removeSplace(this)
if(result&
commonFunction.checkEnd()){
youarewin'
)
removeSplace:
functionremoveS(elem){
if(elem.className=='
varid=elem.id;
if(doc.textContent!
elem.className='
if(doc.textContent!
if(interX>
removeS(document.getElementById((interX-1)+'
+interY));
if(interX<
xyNum.value-1){
removeS(document.getElementById((interX+1)+'
if(interY>
removeS(document.getElementById((interX)+'
+(interY-1)));
if(interY<
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 扫雷 JS 程序
![提示](https://static.bingdoc.com/images/bang_tan.gif)