欢迎光临
我们一直在努力

纯VBScript版的Web扫雷程序-ASP教程,脚本编码

建站超值云服务器,限时71元/月

<!doctype html public "-//w3c//dtd html 4.01 transitional//en">

<html>

<head>

<meta http-equiv="content-type" content="text/html; charset=gb2312">

<title>guidy的web扫雷程序 – 纯vbscript版</title>

<style type="text/css">

@charset "gb2312";

body,td {

font: 12 px "宋体", verdana, arial, helvetica, sans-serif;

cursor: default;

}

body{

margin: 0px;

background: buttonface;

}

a:link,a:visited,a:active {

color:#990000;

text-decoration:none;

}

a:hover {

color:#ff8000;

text-decoration:underline;

}

input {

border-top-width: 1 px;

padding-right: 1 px;

padding-left: 1 px;

border-left-width: 1 px;

border-bottom-width: 1 px;

border-right-width: 1 px;

padding-bottom: 1 px;

padding-top: 1 px;

height: 18 px;

border-left-color: #c0c0c0;

border-bottom-color: #c0c0c0;

border-top-color: #c0c0c0;

border-right-color: #c0c0c0;

background-color: #ffffff;

color: #000000;

font: 9pt "宋体", verdana, arial, helvetica, sans-serif;

}

.tdover{

border: 1px outset;

border-left-color: #ffffff;

border-top-color: #ffffff;

border-right-color: #aaaaaa;

border-bottom-color: #aaaaaa;

background-color: #ffccff;

}

.tdout{

border: 1px outset;

border-left-color: #e5e6e7;

border-top-color: #e5e6e7;

border-right-color: #e5e6e7;

border-bottom-color: #e5e6e7;

background-color: #e5e6e7;

}

.tm0{background-color: buttonface;color: #2e8b57; font-weight:bold;}

.tm1{background-color: buttonface;color: #0000ff; font-weight:bold;}

.tm2{background-color: buttonface;color: #2e8b57; font-weight:bold;}

.tm3{background-color: buttonface;color: #ff0000; font-weight:bold;}

.tm4{background-color: buttonface;color: #ff00ff; font-weight:bold;}

.tm5{background-color: buttonface;color: #00ffff; font-weight:bold;}

.tm6{background-color: buttonface;color: #ff00ff; font-weight:bold;}

.tm7{background-color: buttonface;color: #ffff00; font-weight:bold;}

.tm8{background-color: buttonface;color: #000000; font-weight:bold;}

</style>

</head>

<body onselectstart="event.returnvalue=false;">

<table align="center"><tr><td>

<fieldset style="background-color:bottonface;"><legend>扫雷控制面板</legend><table border="0" align="center" cellpadding="0" cellspacing="1">

<tr>

<td>宽度:</td>

<td><input name="tmx" type="text" id="tmx" size="4" maxlength="4" style="ime-mode: disabled;"></td>

<td><input name="s1" type="button" id="s1" onclick="creattable(tmx.value,tmy.value);laymine(mnum.value);" value=" 开 始 "></td>

</tr>

<tr>

<td>高度:</td>

<td><input name="tmy" type="text" id="tmy" size="4" maxlength="4" style="ime-mode: disabled;"></td>

<td rowspan="2" align="center" valign="middle" id="bnnum" style="font-weight:800; color:#ff0000; font-size:36px;" title="当前标记个数,为负表明超过雷数!">&nbsp;</td>

</tr>

<tr>

<td>雷数:</td>

<td><input name="mnum" type="text" id="mnum" size="4" maxlength="4" style="ime-mode: disabled;"></td>

</tr>

</table>

</fieldset></td></tr>

</table>

<hr size="1">

<table border="3" align="center" cellpadding="1" cellspacing="1" bordercolor="threedshadow">

<tr>

<td><div align="center" id="mineview"><div align="left"><br>

<ul>

<li><strong><font color="#ff0000">请设定后点击『开始』按钮,即可进入游戏!</font></strong></li>

<li>“扫雷”游戏的目标是尽快找到雷区中的所有地雷,而不许踩到地雷。如果挖开的是地雷,您将输掉游戏。</li>

<li>通过单击即可挖开方块。如果挖开的是地雷,则您输掉游戏。</li>

<li>如果方块上出现数字,则表示在其周围的八个方块中共有多少颗地雷。</li>

<li>要标记您认为可能有地雷的方块,请右键单击它。 </li>

<li>要标记您认为不确定的方块,请右键单击它两次。 </li>

</ul>

</div></div></td>

</tr>

</table>

<hr size="1">

<script language="vbscript">

rem =========================================================

rem 文件:webmine.asp

rem 功能:guidy的web扫雷程序 – 纯vbscript版

rem 版本:ver1.0.0

rem 全称:guidy的web扫雷程序 ver1.0.0

rem 时间:2004-10-15

rem 作者:guidy

rem 版权:ixuer studio

rem =========================================================

rem copyright (c) 2004-2006 114xp.cn all rights reserved.

rem 官方网站:http://www.114xp.cn

rem 技术论坛:http://bbs.114xp.cn

rem 电子信箱:guidy@qq.com , guidy@psysch.com

rem =========================================================

option explicit

public i,o

public x,y,z

public minearr,laystr,laytmpstr

public ri,rn,rm

public winmsg,losemsg,bnedmsg

function creattable(tx,ty)

//初始化雷区并将雷区标识符保存在数组中

dim tmpstr,tmpstr1

winmsg = "恭喜!你赢了!!!"

losemsg = "踩到地雷了,哈哈!去死吧!~~"

//因为编程上的不足,只有在长宽相等的时候才能正确游戏

//希望有高手帮助我更正这个问题

if tx <> ty and tx > ty then

ty = tx

else

tx = ty

end if

//如果雷区参数过小就强制使用默认值

if tx = "" or isnull(tx) then tx = 9 : tmx.value = 9

if ty = "" or isnull(ty) then ty = 9 : tmy.value = 9

//如果雷区参数过大就强制使用默认值

if tx >= 24 then tx = 24 : tmx.value = 24

if ty >= 24 then ty = 24 : tmy.value = 24

//创建雷区表格

tmpstr = "<table border=""0"" align=""center"" cellpadding=""0"" cellspacing=""0"" bordercolor=""threeddarkshadow"" bgcolor=""#990000"">"

for x = 1 to ty

tmpstr = tmpstr & " <tr>"

for y = 1 to tx

tmpstr = tmpstr & " <td onclick=""showtmn(this.id);"" oncontextmenu=""putbn(this.id);event.returnvalue=false;"" align=""center"" class=""tdout"" width=""24"" height=""24"" id=""t_" & x &"_"& y &""" minenum=""0"" mbn="""" disable=""false"">&nbsp;</td>"

tmpstr1 = tmpstr1 & " t_" & x &"_"& y

next

tmpstr = tmpstr & " </tr>"

next

tmpstr = tmpstr & "</table>"

//显示表格

mineview.innerhtml = tmpstr

//整理雷区标识符字符串便于转换

tmpstr1 = trim(tmpstr1)

//将雷区标识符字符串转换撑数组

minearr = split(tmpstr1)

//将雷区总数

rn = ubound(minearr) + 1

end function

function laymine(mnumber)

//放雷

dim ii

dim lx,ly

//如果检测到雷区未初始化,则强制执行初始化

if isarray(minearr) = false then call creattable(100,100)

//获取雷区参数

x = int(tmx.value)

y = int(tmy.value)

if mnumber = "" or mnumber <= "0" then mnumber = 10 : mnum.value = mnumber

//获取雷数

z = mnum.value

//如果雷数超过了雷区总数则强制设置

if int(mnumber) >= int(x * y) then

mnumber = int(x * y) – 50

mnum.value = mnumber

z = mnum.value

end if

rm = z

//初始化雷标识字符串

laystr = ""

for ii = 1 to mnumber

//初始化随机数种子

randomize timer()

//建立随机数

lx = int(rnd * x) + 1

ly = int(rnd * y) + 1

//对随机数整形

if lx <= 1 then lx = 1

if ly <= 1 then ly = 1

if lx >= x then lx = x

if ly >= y then ly = y

//利用随机数组合雷标识

laytmpstr = "t_"

laytmpstr = laytmpstr & ly

laytmpstr = laytmpstr &"_"& lx

//检测雷标识字符串,如果存在则跳过,不存才就放雷

if instr(laystr,laytmpstr) then

ii = ii – 1

else

execute(laytmpstr & ".minenum = ""地雷""")

//放雷后重新组合雷标识字符串

laystr = laystr &" "& laytmpstr

end if

next

//对雷标识字符串整形

laystr = trim(laystr)

//将雷标识字符串转换成数组

laystr = split(laystr)

//获取雷总数

ri = ubound(laystr) + 1

call laymnum()

end function

function laymnum()

//在所有方格中标识其周围的雷数

dim li,lmn

for li = 0 to ubound(minearr)

lmn = eval(minearr(li) & ".minenum")

call chkminenum(minearr(li),lmn,0)

next

end function

function chkminenum(tid,tmn,tp)

//计算雷区数字,在方格中显示其周围的雷数

dim tdid,tmp,tmp1

dim n

dim sx,sy,ox,oy,mx,my

x = tmx.value

y = tmy.value

n = 0

//将雷区标识转换成数组便于操作

tdid = split(tid,"_")

//对雷标识符进行整形 初始化中央坐标

ox = tdid(1)

oy = tdid(2)

//对雷标识符进行整形 初始化横坐标 幅度 1

sx = ox – 1

mx = ox + 1

if int(sx) <= 1 then sx = 1

if int(mx) >= int(x) then mx = x

//对雷标识符进行整形 初始化纵坐标 幅度 1

sy = oy – 1

my = oy + 1

if int(sy) <= 1 then sy = 1

if int(my) >= int(y) then my = y

if tmn = "地雷" then

//如果时雷标识就应该跳过

//execute(tid & ".innerhtml = """ & tmn & """")

else

//循环计算周围雷总数

for i = sx to mx step 1

tmp1 = tdid(0)

tmp1 = tmp1 & "_" & i

for o = sy to my step 1

tmp = tmp1 & "_" & o

if eval(tmp & ".minenum = ""地雷""") then

n = n + 1

elseif tmn = 0 and tp = 1 then

//如果雷数为0则自动循环检测其周围其他雷区,直到完毕

call showtmn(tmp)

end if

next

next

//显示周围雷数

execute(tid & ".minenum = " & n)

//execute(tid & ".innerhtml = " & n)

end if

end function

function showtmn(tid)

//在选中的格子中显示其周围的雷数

dim ttn

ttn = cstr(eval(tid & ".minenum"))

//如果所点击的不是雷标识格子,则将没有禁用的标识为禁用

//禁用的则自动跳过执行,以减少系统执行负担

if eval(tid & ".minenum <> ""地雷""") then

if eval(tid & ".disable = ""true""") then

exit function

else

execute(tid & ".innerhtml = """ & ttn & """")

execute(tid & ".disable = ""true""")

end if

if eval(tid & ".minenum = ""标记""") then

execute(tid & ".disable = ""false""")

end if

else

if eval(tid & ".disable = ""true""") then

exit function

end if

end if

//按照雷数的不同显示不同的样式,以便区分

select case ttn

case "0"

//如果检测到周围雷数为0,则自动循环检测其周围的格子

execute(tid & ".minenum = """"")

execute(tid & ".classname = ""tm0""")

execute(tid & ".innerhtml = ""&nbsp;""")

call chkminenum(tid,ttn,1)

rn = rn – 1

case "1" execute(tid & ".classname = ""tm1""") : rn = rn – 1

case "2" execute(tid & ".classname = ""tm2""") : rn = rn – 1

case "3" execute(tid & ".classname = ""tm3""") : rn = rn – 1

case "4" execute(tid & ".classname = ""tm4""") : rn = rn – 1

case "5" execute(tid & ".classname = ""tm5""") : rn = rn – 1

case "6" execute(tid & ".classname = ""tm6""") : rn = rn – 1

case "7" execute(tid & ".classname = ""tm7""") : rn = rn – 1

case "8" execute(tid & ".classname = ""tm8""") : rn = rn – 1

case "地雷"

winmsg = losemsg

call showallob()

exit function

case "标记"

execute(tid & ".innerhtml = ""&nbsp;""")

winmsg = losemsg

call showallob()

exit function

end select

if z = "" & rn & "" then

call showallob()

alert(winmsg)

end if

end function

function putbn(tid)

//用右键做自助标记

//如果是已经禁用的,则自动跳过

if eval(tid & ".disable = ""true""") then

if eval(tid & ".minenum <> ""地雷""") or eval(tid & ".minenum <> ""标记""") then

exit function

end if

end if

execute(tid & ".classname = ""tdover""")

execute("mnum.style.color = ""#00ff00""")

//标记类型

if eval(tid & ".mbn = """"") then

//标记为有雷

execute(tid & ".mbn = ""!""")

execute(tid & ".innerhtml = """ & eval(tid & ".mbn") & """")

rm = rm – 1

elseif eval(tid & ".mbn = ""!""") then

//标记为未知

execute(tid & ".mbn = ""?""")

execute(tid & ".innerhtml = """ & eval(tid & ".mbn") & """")

rm = rm + 1

execute("bnnum.innerhtml = """ & mnum.value + 1 & """")

elseif eval(tid & ".mbn = ""?""") then

//标记为一般状态

execute(tid & ".mbn = """"")

execute(tid & ".innerhtml = ""&nbsp;""")

execute(tid & ".classname = ""tdout""")

end if

execute("bnnum.innerhtml = """ & rm & """")

//如果所标记的是雷标识,则计数

if eval(tid & ".minenum = ""地雷""") then

ri = ri – 1

execute(tid & ".minenum = ""标记""")

//下面2行代码可以用来作弊

//execute(tid & ".innerhtml = " & z – ri)

end if

end function

function showallob()

//将所有障碍物反白

dim oi

for oi = 0 to ubound(minearr)

if eval(minearr(oi) & ".minenum = ""地雷""") or eval(minearr(oi) & ".minenum = ""标记""") then

execute(minearr(oi) & ".style.color = ""#ff0000""")

execute(minearr(oi) & ".bgcolor = ""#ff0000""")

execute(minearr(oi) & ".disable = ""true""")

execute(minearr(oi) & ".innerhtml = ""地雷""")

else

call showtmn(minearr(oi))

end if

next

end function

</script>

<table border="1" align="center" cellpadding="2" cellspacing="1" class="tdout">

<tr>

<td colspan="3" align="center"><a href="http://www.114xp.cn/" target="_blank">爱雪儿工作室</a> 2004年10月15日晚<br>

<table width="99%" style="height:1px; " border="0" cellpadding="0" cellspacing="0" bordercolor="#999999" bgcolor="#999999">

<tr><td></td></tr></table>

ixuer studio webmine v1.0.0<br>

<a href="http://www.psysch.com/!guidy/" target="_blank">发现问题请通知作者修正,谢谢!</a></td>

</tr>

</table>

</body>

</html>

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 纯VBScript版的Web扫雷程序-ASP教程,脚本编码
分享到: 更多 (0)

相关推荐

  • 暂无文章