欢迎光临
我们一直在努力

词语搭配游戏的制作(ASP)一

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

说明:

这是个关于词语搭配的游戏,是用asp、vbscript和javascript写的。

在本机win98 oem2、pws、ie5下测试下没发现大问题。

使用方法:

方法一:比方说你的3w服务的目录是c:\inetpub\wwwroot,在下面建一个目录,如wordasb;

将游戏文件(wordasb.asp)拷入目录中;在ie的地址栏中键入http://+你的机器名+/wordasb/wordasb.asp

或http://127.0.0.1/wordasb/wordasb.asp,回车,就可以开始游戏了

方法二:将游戏文件(wordasb.asp)随便拷入一新建的目录。鼠标右键点击该目录,菜单中选“属性”,

点“web sharing”属性页,点选“share this folder”项,点“ok”就可以了。

在ie的地址栏中键入http://+你的机器名+/新建目录的名称/wordasb.asp

或http://127.0.0.1/+新建目录的名称+/wordasb.asp,回车,就可以开始游戏了

注:您的机子os应该是nt或win2000 server或其他os但是装有pws

游戏方法:

单击游戏中的“游戏说明”就知道了;

如果有时页面一片空白,请按f5刷新一遍(这也是目前最大的bug吧),不知为什么

代码如下:

——————————————————————————–

<%@ language = vbscript%>

<%

option explicit

last updated by recon on 03/16/2001

dim m_ipartcnt

dim m_strprompt

dim m_astrsenpart(), m_astrfilename()

dim m_astrwords(), m_aiopstatus()

——————————————

常变量说明

m_ipartcnt :词汇分类的数目。整型

m_strprompt :对文件操作完毕后的提示。字符串型

m_astrsenpart :词汇分类的名称。字符型数组

m_astrfilename :记录各类词汇文件的文件名。字符型数组

m_astrwords :纪录各类词汇。二维字符型数组

m_aiopstatus :纪录对各个文件操作后的状态。整型数组

——————————————

showmethod

m_ipartcnt = 4

m_strprompt = ""

redim m_astrsenpart(m_ipartcnt)

redim m_astrfilename(m_ipartcnt)

redim m_astrwords(m_ipartcnt)

redim m_aiopstatus(m_ipartcnt)

定义各种词汇分类的名称

m_astrsenpart(0) = "主语"

m_astrsenpart(1) = "程度状语"

m_astrsenpart(2) = "地点状语"

m_astrsenpart(3) = "谓语"

定义记载各类词汇文件的名称

m_astrfilename(0) = "who.txt"

m_astrfilename(1) = "how.txt"

m_astrfilename(2) = "where.txt"

m_astrfilename(3) = "what.txt"

if request.servervariables("request_method") = "post" then

如果页面的请求方式是 post

************************

获得客户端的信息

************************

dim m_isenpart

dim m_stropway

dim m_brpteddata

——————————————

常变量说明

m_isenpart :表示词汇分类的数字。整型

词汇的分类来自数组m_astrsenpart

可能的值有:

0:主语

1:程度状语

2:地点状语

3:谓语

m_stropway :文件操作方式。字符串型

可能的值有:

1、save :将某类词汇存入文件

2、saveall :将所有类别的词汇存入文件

3、load :从文件中载入某类词汇

4、loadall :从文件中载入所有类别的词汇

m_brpteddata :表示本次提交的表单数据和上次是否相同。布尔型

可能的值有:

1、false :表单数据不重复

2、true :表单数据重复(即重复提交表单)

——————————————

showform

获得用户请求的操作方式

m_stropway = request.form("txtopway")

show("m_stropway")

获得各个类别的单词

for m_icount = 0 to (m_ipartcnt – 1)

if request.form("txtwords" & m_icount) <> "" then

m_astrwords(m_icount) = split(request.form("txtwords" & m_icount), ",")

end if

response.write ubound(m_astrwords(m_icount)) & "<br>"

next

检测是否重复提交表单

if session("forminf") = request.form then

表单是重复提交

m_brpteddata = true

else

表单是非重复提交

session("forminf") = request.form

m_brpteddata = false

end if

show("m_brpteddata")

************************

对单词文件进行操作

************************

if m_brpteddata = false then

dim m_icount, m_ierrcnt

dim m_strfilepath

——————————————

常变量说明

m_icount :计数器。整型

m_ierrcnt :发生操作失败的次数。整型

m_strfilepath :记录各类词汇文件的路径。字符串型

——————————————

获得放置词汇文件的路径

m_strfilepath = request.servervariables("path_translated")

m_strfilepath = left(m_strfilepath, instrrev(m_strfilepath, "\"))

m_strfilepath = m_strfilepath & "words\"

show("m_strfilepath")

开始操作文件

response.write "begin to operate word files<br>"

select case m_stropway

case "save"

保存单词到文件中

m_isenpart = cint(request.form("txtsenpart"))

m_aiopstatus(m_isenpart) = savefile(m_isenpart)

根据操作状态,得到提示信息

select case m_aiopstatus(m_isenpart)

case 0

m_strprompt = "[" & m_astrsenpart(m_isenpart) & "]部分单词已成功地被保存到文件中"

case 1

m_strprompt = "[" & m_astrsenpart(m_isenpart) & "]部分文件保存失败"

end select

case "saveall"

保存所有类别的单词到文件中

m_ierrcnt = 0

for m_icount = 0 to (m_ipartcnt – 1)

m_aiopstatus(m_icount) = savefile(m_icount)

if m_aiopstatus(m_icount) = 1 then

m_ierrcnt = m_ierrcnt + 1

end if

next

根据操作状态,得到提示信息

select case m_ierrcnt

case 0

m_strprompt = "所有类别的单词都已成功地被保存到文件中"

case m_ipartcnt

m_strprompt = "所有类别的单词文件都保存失败"

case else

m_strprompt = "其中,"

for m_icount = 0 to (m_ipartcnt – 1)

if m_aiopstatus(m_icount) = 1 then

m_strprompt = m_strprompt & "[" & m_astrsenpart(m_icount) & "]、"

end if

next

m_strprompt = left(m_strprompt, len(m_strprompt) – 1)

m_strprompt = m_strprompt & "部分文件保存失败"

end select

case "load"

从文件中载入单词

m_isenpart = cint(request.form("txtsenpart"))

m_aiopstatus(m_isenpart) = loadfile(m_isenpart)

根据操作状态,得到提示信息

select case m_aiopstatus(m_isenpart)

case 0

m_strprompt = "[" & m_astrsenpart(m_isenpart) & "]部分单词已成功地被载入"

case 1

m_strprompt = "[" & m_astrsenpart(m_isenpart) & "]部分文件不存在,载入失败"

end select

case "loadall"

从各个文件中载入单词

m_ierrcnt = 0

for m_icount = 0 to (m_ipartcnt – 1)

m_aiopstatus(m_icount) = loadfile(m_icount)

if m_aiopstatus(m_icount) = 1 then

m_ierrcnt = m_ierrcnt + 1

end if

next

根据操作状态,得到提示信息

select case m_ierrcnt

case 0

m_strprompt = "所有类别的单词都已成功地被载入"

case m_ipartcnt

m_strprompt = "所有类别的单词文件都不存在,载入完全失败"

case else

m_strprompt = "其中,"

for m_icount = 0 to (m_ipartcnt – 1)

if m_aiopstatus(m_icount) = 1 then

m_strprompt = m_strprompt & "[" & m_astrsenpart(m_icount) & "]、"

end if

next

m_strprompt = left(m_strprompt, len(m_strprompt) – 1)

m_strprompt = m_strprompt & "部分文件不存在,载入部分失败"

end select

end select

end if

end if

response.write "end to operate word files<br>"

response.write "begin to write client page<br>"

%>

<html>

<head>

<title> 词语搭配游戏 </title>

<meta name="generator" content="editplus">

<meta name="author" content="">

<meta name="keywords" content="">

<meta name="description" content="">

<!–风格表–>

<style>

<!–

/*英文字体1*/

.fonteng1

{

font-family: times new roman;

font-style: ;

}

/*英文字体2*/

.fonteng2

{

font-family: times new roman;

font-style: italic;

}

/*强调字体*/

.fontemp

{

color: red;

}

/*链接*/

.link

{

font-family: times new roman;

font-style: italic;

text-decoration: none;

}

/*被显示的单词列表*/

.listshown

{

position: absolute;

width: 140px;

height: 200px;

display: inline;

border: lightcoral 1px solid;

background-color: gainsboro;

}

/*被隐藏的单词列表*/

.listhidden

{

position: absolute;

width: 140px;

height: 200px;

display: none;

border: lightcoral 1px solid;

background-color: gainsboro;

}

/*被固定的单词列表*/

.listfixed

{

position: absolute;

width: 140px;

height: 200px;

display: inline;

border: red 1px solid;

background-color: gainsboro;

}

/*被显示的帮助列表*/

.helpshown

{

position: absolute;

width: ;

height: ;

display: block;

border: lightcoral 1px solid;

background-color: gainsboro;

}

/*被隐藏的帮助列表*/

.helphidden

{

position: absolute;

width: ;

height: ;

display: none;

border: lightcoral 1px solid;

background-color: gainsboro;

}

/*被固定的帮助列表*/

.helpfixed

{

position: absolute;

width: ;

height: ;

display: block;

border: red 1px solid;

background-color: gainsboro;

}

/*被强调显示的标签*/

.lblmover

{

text-decoration: none;

color: lightcoral;

background-color: ;

}

/*正常显示的标签*/

.lblmout

{

text-decoration: none;

color: ;

background-color: ;

}

/*被点击过的标签*/

.lblclicked

{

text-decoration: underline;

color: red;

background-color: ;

}

/*高亮显示的按钮*/

.btnlighted

{

width: 105px;

color: blue;

background-color: ;

}

/*正常显示的按钮*/

.btndelighted

{

width: 105px;

color: ;

background-color: ;

}

/*高亮显示的单词列表项*/

.optlighted

{

text-decoration: underline;

color: blue;

background-color: ;

cursor: hand;

}

/*正常显示的单词列表项*/

.optdelighted

{

text-decoration: none;

color: ;

background-color: ;

cursor: ;

}

–>

</style>

<!–客户端脚本–>

<script language="javascript">

<!–

//客户端公用及测试函数

//************************

//函数名 :ltrim

//功能 :去掉字串左边的空格

//输入 :1、strtemp :要规整的字串。字符串型

//输出 :规整后的字串。字符串型

//************************

function ltrim(strtemp)

{

var icount, ilength;

//——————————————

//常变量说明

//icount :计数器。整型

//ilength :字串的长度。整型

//——————————————

ilength = strtemp.length;

for (icount = 0; icount < ilength; icount ++)

if (strtemp.charat(icount) != " ")

return strtemp.substring(icount, ilength);

return "";

}

//************************

//函数名 :rtrim

//功能 :去掉字串右边的空格

//输入 :1、strtemp :要规整的字串。字符串型

//输出 :规整后的字串。字符串型

//************************

function rtrim(strtemp)

{

var icount, ilength;

//——————————————

//常变量说明

//icount :计数器。整型

//ilength :字串的长度。整型

//——————————————

ilength = strtemp.length;

for(icount = ilength – 1; icount >= 0; icount –)

if (strtemp.charat(icount) != " ")

return strtemp.substring(0, icount + 1);

return "";

}

//************************

//函数名 :trim

//功能 :去掉字串两边的空格

//输入 :1、strtemp :要规整的字串。字符串型

//输出 :规整后的字串。字符串型

//************************

function trim(strtemp)

{

return rtrim(ltrim(strtemp));

}

//将2位数字转换成2位数字字串

//************************

//函数名 :get2bnumstr

//功能 :转换2位的数字成2位的数字字串

//输入 :1、inumber :要转换的数字。整型

//输出 :转换后得到的数字字串。整型

//************************

function get2bnumstr(inumber)

{

var str2bnum;

//——————————————

//常变量说明

//str2bnum :数字字串。字符串型

//——————————————

if (parseint(inumber) < 10)

str2bnum = "0" + inumber;

else

str2bnum = "" + inumber;

return str2bnum;

}

//************************

//函数名 :assignfunc

//功能 :指定元素的事件处理函数

//输入 :1、ele :要指定事件处理函数的元素。对象型

// 2、func :事件处理函数。函数型

// 3、event :事件类型。字符串型

//输出 :无

//************************

function assignfunc(ele, func, event)

{

var icount, ielecount;

var strevent;

//——————————————

//常变量说明

//icount :计数器。整型

//ielecount :同名元素集合中元素的个数。整型

//strevent :事件类型。字符串型

//——————————————

if (event == null)

strevent = "onclick";

else

strevent = event;

ielecount = ele.length;

if (ielecount == undefined)

eval("ele." + strevent + " = " + func);

else

for (icount = 0; icount < ielecount; icount ++)

eval("ele[icount]." + strevent + " = " + func);

}

//************************

//函数名 :geteleindex

//功能 :得到发生事件的元素在同名集合中的索引

//输入 :1、elesrc :发生事件的元素。对象型

//输出 :发生事件的元素在同名集合中的索引

//************************

function geteleindex(elesrc)

{

var colsrc;

var icount, ielecount;

//——————————————

//常变量说明

//colsrc :同名元素集合。对象型数组

//icount :计数器。整型

//ielecount :同名元素集合中元素的个数。整型

//——————————————

colsrc = eval(elesrc.id);

ielecount = colsrc.length;

for (icount = 0; icount < ielecount; icount ++)

{

if (colsrc[icount] == elesrc)

return icount;

}

return -1;

}

//显示常变量的值(调试用)

//!准备删去

function show(strdef1, strdef2, strdef3, strdef4)

{

var icount, idefcnt;

var strshow, strtemp;

idefcnt = 4;

strshow = "[常变量值]";

for (icount = 1; icount <= idefcnt; icount ++)

{

strtemp = eval("strdef" + icount);

if (strtemp != undefined && strtemp != null)

strshow += "\n" + strtemp + ": " + eval(strtemp);

}

alert(strshow);

}

//************************

//函数名 :showarray

//功能 :显示一维数组的元素(调试用)

//输入 :1、array :要显示的一维数组。数组

//输出 :无

//************************

function showarray(array)

{

var icount, ielecount;

var strshow;

//——————————————

//常变量说明

//icount :计数器。整型

//ielecount :数组元素的个数。整型

//strshow :数组元素值构成的字串。字符串型

//——————————————

ielecount = array.length;

strshow = "array length: " + ielecount;

strshow += "\n———————————\n";

for (icount = 0; icount < ielecount; icount ++)

{

if (typeof(array[icount]) == "object")

strshow += array[icount].id + " ";

else

strshow += array[icount] + " ";

}

alert(strshow);

}

//************************

//函数名 :show2darray

//功能 :显示二维数组的元素(调试用)

//输入 :1、array :要显示的二维数组。数组

//输出 :无

//************************

function show2darray(array)

{

var ix, iy, ilen1, ilen2;

var strshow;

//——————————————

//常变量说明

//ix :计数器。整型

//iy :计数器。整型

//ilen1 :数组一维的数目。整型

//ilen2 :数组二维的数目。整型

//strshow :数组元素值构成的字串。字符串型

//——————————————

ilen1 = array.length;

strshow = "array 1d length: " + ilen1;

strshow += "\n———————————";

for (ix = 0; ix < ilen1; ix ++)

{

strshow += "\n";

ilen2 = array[ix].length;

for (iy = 0; iy < ilen2; iy ++)

strshow += array[ix][iy] + " ";

}

alert(strshow);

}

//–>

</script>

<script language="javascript">

<!–

//——————–函数列表————————–

//window_onload

//

//getword

//reset

//save

//load

//

//showlist

//hidelist

//fixlist

//valuelist

//

//showhelp

//hidehelp

//fixhelp

//

//resetall

//saveall

//loadall

//assemble

//

//lightbtn

//delightbtn

//lightopt

//delightopt

//

//makeopt

//removeopt

//———————————————————–

var m_ipartcnt;

var m_astrsenpart, m_astrwords;

var m_strprompt;

var m_ilistfixed, m_ihelpfixed;

//——————————————

//常变量说明

//m_ipartcnt :词汇分类的数目。整型

//m_astrsenpart :词汇分类的名称。字符型数组

//m_astrwords :纪录各类词汇。二维字符型数组

//m_strprompt :文件操作完毕后的提示信息。字符串型

//m_ilistfixed :代表被固定单词列表的数字。整型

// -1表示没有单词列表被固定

//m_ihelpfixed :表示帮助列表固定状态的数字。整型

// -1表示帮助列表没有被固定

//——————————————

window.onload = window_onload;

//———————————————————–

//初始化页面

function window_onload()

{

var icount, ielecnt;

var colbutton;

var strhelp;

//——————————————

//常变量说明

//icount :计数器。整型

//ielecnt :集合中元素的个数。整型

//colbutton :button元素的集合。对象型数组

//strhelp :帮助文件内容。字符串型

//——————————————

m_ipartcnt = <%= m_ipartcnt%>;

m_strprompt = "<%= m_strprompt%>";

m_ilistfixed = -1;

m_ihelpfixed = -1;

m_astrsenpart = new array();

m_astrwords = new array();

//alert("m_ipartcnt: " + m_ipartcnt + "\nm_strprompt: " + m_strprompt);

//得到词汇分类的名称和已载入的各类词汇

<%for m_icount = 0 to (m_ipartcnt – 1)%>

//得到已载入的各类词汇

<%if isempty(m_astrwords(m_icount)) = true then%>

m_astrwords[<%= m_icount%>] = new array();

<%else%>

m_astrwords[<%= m_icount%>] = "<%= join(m_astrwords(m_icount), ",")%>".split(",");

<%end if%>

//得到词汇分类的名称

m_astrsenpart[<%= m_icount%>] = "<%= m_astrsenpart(m_icount)%>";

<%next%>

//show2darray(m_astrwords);

//showarray(m_astrsenpart);

//将已载入的各类词汇写入到页面中

for (icount = 0; icount < m_ipartcnt; icount ++)

valuelist(m_astrwords[icount], icount);

//载入帮助文件

//strhelp = tblhelp.outerhtml;

//strhelp = divhelp1.innerhtml;

//tblhelp.outerhtml = "";

//divhelp.innerhtml = strhelp;

//tblhelp.style.display = "";

//divhelp.style.display = "none";

//divhelp.style.left = divhelp1.style.left;

//alert("left: "+divhelp.style.left + "\nleft: " + divhelp1.style.left);

//alert("pixelleft: "+divhelp.style.pixelleft + "\npixelleft: " + divhelp1.style.pixelleft);

//alert("posleft: "+divhelp.style.posleft + "\nposleft: " + divhelp1.style.posleft);

//alert("offsetleft : "+divhelp.offsetleft + "\noffsetleft : " + divhelp1.offsetleft );

//alert("clientleft : "+divhelp.clientleft + "\nclientleft : " + divhelp1.clientleft );

//指定页面元素的事件处理函数

assignfunc(txtword, getword, "onkeypress");

assignfunc(btngetword, getword);

assignfunc(btnreset, reset);

assignfunc(btnsave, save);

assignfunc(btnload, load);

assignfunc(lblwordlist, showlist, "onmouseover");

assignfunc(lblwordlist, hidelist, "onmouseout");

assignfunc(lblwordlist, fixlist);

assignfunc(lblhelp, showhelp, "onmouseover");

assignfunc(lblhelp, hidehelp, "onmouseout");

assignfunc(lblhelp, fixhelp);

assignfunc(btnresetall, resetall);

assignfunc(btnsaveall, saveall);

assignfunc(btnloadall, loadall);

assignfunc(btnasb, assemble);

colbutton = document.all.tags("button");

ielecnt = colbutton.length;

//showarray(colbutton);

//alert("ielecnt: " + ielecnt);

for (icount = 0; icount < ielecnt; icount ++)

{

assignfunc(colbutton[icount], lightbtn, "onmouseover");

assignfunc(colbutton[icount], delightbtn, "onmouseout");

}

//设置页面初始状态

if (m_strprompt != "")

alert(m_strprompt);

txtword[0].focus();

}

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 词语搭配游戏的制作(ASP)一
分享到: 更多 (0)