一主文件
文件名.hta
最好用hta格式,它权限比较高
一图片文件夹用来放拼图图片名:pic
驱动器 F 中的卷是 bak
卷的序列号是 CC6D-A3EE
F:/iis/game/16格拼板游戏/pic 的目录
2010-04-09 10:29 <DIR> .
2010-04-09 10:29 <DIR> ..
2010-04-09 10:29 13 s.bat
2010-04-09 10:29 0 x.txt
2008-11-18 14:10 111,700 奥迪R8图片.jpg
2008-11-18 01:21 89,286 自建方块图片.jpg
2008-11-18 01:15 96,836 默认方块图片.jpg
2008-10-16 11:37 533,603 默认背景图片.jpg
6 个文件 831,438 字节
2 个目录 228,249,600 可用字节
一声效文件夹用来放相应的声音文件:sound
驱动器 F 中的卷是 bak
卷的序列号是 CC6D-A3EE
F:/iis/game/16格拼板游戏/sound 的目录
2010-04-09 10:29 <DIR> .
2010-04-09 10:29 <DIR> ..
2008-04-17 16:51 11,205 change.wav
2008-01-02 19:15 16,418 go.wav
2008-01-02 19:14 17,688 move.wav
2008-01-02 19:14 43,600 moveWrong.wav
2008-01-02 19:15 88,252 random.wav
2010-04-09 10:29 13 s.bat
2008-04-17 16:51 35,320 stop.wav
2008-01-02 19:14 434,788 win.wav
2010-04-09 10:29 0 x.txt
9 个文件 647,284 字节
2 个目录 228,249,600 可用字节
--------------------------------------
<script>
var timer = null, TGH = TGM = TGS = 0;
var tds = 16; //td个数
var tdWH = "150px 150px";//td 高宽
var blankTd = "15";
var errorTd = 0;
var f1 = "规则:把打乱的图片方块重新移动拼接成右边小图中的图片就算成功!/n"
+ "移动:点击空白方格左,右,上,下方块(四角方块不可移动),可以把点中方块移入空格中。/n"
+ "停止计时:停止时间跳动。/n"
+ "打乱排序:随机打乱图片方块/n"
+ "更换图片:更换拼接的方块图片或背景图。点击浏览选择本机硬盘中的图片文件,或是输入图片网址。注意,方块图片不能小于628 × 614。否则图片太小将导致方块空白。/n"
+ "/n/n/n版本:第一版是数字式,此版本属于第二版,支持图片。完成时间:20081018 设计人:qidizi/n"
+ "如发现不足或出错,请来信息。";
function getTds(index)
{
return document.all("td")[index];
}
function sayYehh()
{
record.value += prompt("恭喜你!请英雄留下名字:", "匿名") + " " + TGH + "时" + TGM + "分" + TGS + "秒 内完成!/n";
}
function showState()
{
timeShow.innerText = errorTd + "个错位 耗时" + TGH + "时" + TGM + "分" + TGS + "秒";
}
function startTime()
{
if (timer == null)
{
TGH = TGM = TGS = 0;
timer = setInterval('timeGo();', 1000);
}
}
function stopTime()
{
clearInterval(timer);
timer = null;
playSound("sound/stop.wav");
}
function timeGo()
{
TGS++;
if (TGS == 60)
{
TGS = 0;
TGM++;
if (TGM == 60)
{
TGM = 0;
TGH++;
}
}
showState();
}
function checkClick()
{
var Eobj = event.srcElement;
if ( (Eobj.id=="td") && (Eobj.style.backgroundPosition != tdWH))
{
if (getTds(Eobj.index).canTo.indexOf("." + blankTd + ".") > -1)
{
startTime();
getTds(blankTd).style.backgroundPosition = getTds(Eobj.index).style.backgroundPosition;
blankTd = Eobj.index;
getTds(blankTd).style.backgroundPosition = tdWH;
checkValue();
if (errorTd == 0)
{
stopTime();
playSound("sound/win.wav");
sayYehh();
}else
{
playSound("sound/move.wav");
}
}else
{
playSound("sound/moveWrong.wav");
}
}
}
function randomSort()
{
var randomFrom;
var temp;
for (var forI = 0; forI < tds; forI++)
{
getTds(forI).temp = getTds(forI).style.backgroundPosition;
}
for (forI = 0; forI < 1000; forI++)
{
randomFrom = getTds(blankTd).canTo.split(".");
randomFrom = randomFrom[Math.floor(Math.random()*(randomFrom.length - 2) ) + 1];
temp = getTds(randomFrom).temp;//保存空格要去的单元格
getTds(randomFrom).temp = getTds(blankTd).temp;
getTds(blankTd).temp = temp;
blankTd = randomFrom;
}
for (forI = 0; forI < tds; forI++)
{
getTds(forI).style.backgroundPosition = getTds(forI).temp;
}
stopTime();
TGH = TGM = TGS = 0;
checkValue();
playSound("sound/random.wav");
}
function checkValue()
{
errorTd = 0;
for (var forI = 0; forI < tds; forI++)
{
if (getTds(forI).position != getTds(forI).style.backgroundPosition)
{
errorTd++;
}
}
showState();
}
function playSound(url)
{
mplayer.url = url;
}
function changeImg(how)
{
if (/^ *$/.test(imgPath.value))
{
return alert("选择本机中图片文件或输入图片网址!");
}
playSound("sound/change.wav");
viewImg.how = how;
viewImg.src = imgPath.value;
}
function imgOk()
{
if (viewImg.how == "1")
{
style1.styleSheet.rules[2].style.backgroundImage = 'url(' + viewImg.src + ')';
imgUrl.innerText = viewImg.src;
}else
{
document.body.style.backgroundImage = 'url(' + viewImg.src + ')';
}
}
function imgError()
{
alert("载入图片[" + viewImg.src + "]出错,此问题导致游戏不能玩,请检查图片路径是否正确或者更换图片后再玩。");
}
function saveList()
{
var list = new Array();
for (var forI = 0; forI < tds; forI++)
{
list[forI] = getTds(forI).style.backgroundPosition.toString();
}
var option = document.createElement("OPTION");
lists.options.add(option);
option.innerText = "保存盘局:" + prompt("在下面输入保存盘局名字以供载入辩别用","");
option.value = list.join(",") + "," + blankTd;
alert("保存完成!");
}
function loadList()
{
if (lists.options.length == 0)
{
return alert("未保存过盘局,无盘局可载入!");
}else if ( confirm("你确定要载入新盘局替换掉现在正在玩的盘局?"))
{
var splits = lists.options[lists.selectedIndex].value.split(",");
for (var forI = 0; forI < tds; forI++)
{
getTds(forI).style.backgroundPosition = splits[forI];
}
blankTd = splits[forI];
stopTime();
alert("方块重排完成!");
}
}
</script>
<html>
<head>
<HTA:APPLICATION ID="oHTA"
APPLICATIONNAME="myApp"
CAPTION="yes"
contextmenu="no"
ICON=""
MAXIMIZEBUTTON="yes"
MINIMIZEBUTTON="yes"
SHOWINTASKBAR="yes"
SINGLEINSTANCE="yes"
SCROLL="no"
VERSION="1.0"
WINDOWSTATE="maximize"/>
<title>16格智力拼板游戏</title>
<style id=style1>
body
{
background:url("pic/默认背景图片.jpg") no-repeat fixed;
}
table
{
display:inline;
}
#td
{
width:150px;
height:150px;
color:red;
cursor:hand;
text-align:center;
background-repeat:no-repeat;
background-attachment:scroll;
border-top:2px solid gainsboro;
border-left:2px solid gainsboro;
border-right:2px solid black;
border-bottom:2px solid black;
}
</style>
</head>
<body>
<center>
<table>
<tr><td style="width:620px; background-color:#C0C0C0;text-align:center;">
<table onClick="checkClick();" id=moveTable onselectstart="return false;">
<tr>
<td id=td index="0" temp="" position="0px 0px" canTo=".1.4." style="background-position: 0px 0px;">1</td>
<td id=td index="1" temp="" position="-150px 0px" canTo=".0.2.5." style="background-position: -150px 0px;">2</td>
<td id=td index="2" temp="" position="-300px 0px" canTo=".1.3.6." style="background-position: -300px 0px;">3</td>
<td id=td index="3" temp="" position="-450px 0px" canTo=".2.7." style="background-position: -450px 0px;">4</td>
</tr>
<tr>
<td id=td index="4" temp="" position="0px -150px" canTo=".0.5.8." style="background-position: 0px -150px;">5</td>
<td id=td index="5" temp="" position="-150px -150px" canTo=".1.4.6.9." style="background-position: -150px -150px;">6</td>
<td id=td index="6" temp="" position="-300px -150px" canTo=".2.5.7.10." style="background-position: -300px -150px;">7</td>
<td id=td index="7" temp="" position="-450px -150px" canTo=".3.6.11." style="background-position: -450px -150px;">8</td>
</tr>
<tr>
<td id=td index="8" temp="" position="0px -300px" canTo=".4.9.12." style="background-position: 0px -300px;">9</td>
<td id=td index="9" temp="" position="-150px -300px" canTo=".5.8.10.13." style="background-position: -150px -300px;">10</td>
<td id=td index="10" temp="" position="-300px -300px" canTo=".6.9.11.14." style="background-position: -300px -300px;">11</td>
<td id=td index="11" temp="" position="-450px -300px" canTo=".7.10.15." style="background-position: -450px -300px;">12</td>
</tr>
<tr>
<td id=td index="12" temp="" position="0px -450px" canTo=".8.13." style="background-position: 0px -450px;">13</td>
<td id=td index="13" temp="" position="-150px -450px" canTo=".9.12.14." style="background-position: -150px -450px;">14</td>
<td id=td index="14" temp="" position="-300px -450px" canTo=".10.13.15." style="background-position: -300px -450px;">15</td>
<td id=td index="15" temp="" position="150px 150px" canTo=".11.14." style="background-position: 150px 150px;">16</td>
</tr>
</table>
</td>
<td style="
background-color:#C0C0C0; width:310px;text-align:center;">
--------控制面板--------
<br><br>
<div id=imgUrl style="width:300px; height:50px; overflow:auto;"></div>
<img src="pic/默认方块图片.jpg" οnlοad="imgOk()" οnerrοr="imgError()" id=viewImg how="1"
style="width:200px; height:200px;" title="完整图片">
<br><br><b><span id=timeShow style="color:red; width:300px;"></span></b><br><br>
<input type="button" value="停止计时" onClick="stopTime();" style="width:100px;"><input
type=button value="打乱排序" onClick="randomSort();" style="width:100px;"><input
type=button value="关于程序" onClick="alert(f1);" style="width:100px;">
<br>
<br>
<input type="button" value="保存右边盘局" onClick="saveList()" style="width:145px;" >
<input type="button" value="载入下面盘局" onClick="loadList()" style="width:145px;">
<select id=lists style="width:300px; display:block;">
</select>
<br>
<input type=button value="设下面地址图作方块图" onClick="changeImg(1);" style="width:150px;"><input
type=button value="设下面地址图作背景图" onClick="changeImg(0);" style="width:150px;">
<input type=file id=imgPath title="可以点击选择本机硬盘中的图片,也可以输入http开头的网上图片地址。" style="width:300px;">
<br>
<br>
<textarea id=record style="background-color : transparent; border:1px solid black; font-size:15px; width:300px; height:100px;" CONTENTEDITABLE=false>成绩记录如下:
</textarea>
</td></tr>
</table>
</center>
<OBJECT ID="mplayer"
CLASSID="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" style="width:0px; height:0px; display:none;">
<PARAM name="autoStart" value="true">
<param name="volume" value="100">
</OBJECT>
</body>
</html>