人人做人人澡人人爽欧美,国产主播一区二区,久久久精品五月天,羞羞视频在线观看免费

當(dāng)前位置:蘿卜系統(tǒng)下載站 > 技術(shù)開(kāi)發(fā)教程 > 詳細(xì)頁(yè)面

用ASP完成網(wǎng)上“5子連珠”大賽 (轉(zhuǎn)貼)

用ASP完成網(wǎng)上“5子連珠”大賽 (轉(zhuǎn)貼)

更新時(shí)間:2019-05-04 文章作者:未知 信息來(lái)源:網(wǎng)絡(luò) 閱讀次數(shù):

大家?guī)兔ν晟埔幌拢缓筚N出來(lái),我是改不好了!

用ASP實(shí)現(xiàn)網(wǎng)上“五子連珠”大賽
“五子棋”是大家都非常熟悉的一種益智類(lèi)游戲,相關(guān)的游戲軟件也非常多,在此我向大家隆重推出一款新的純“網(wǎng)絡(luò)版”的五子棋,它利用ASP做為開(kāi)發(fā)環(huán)境,因此在Internet上對(duì)戰(zhàn)的時(shí)候無(wú)需下載客戶(hù)端軟件,只要你有一個(gè)瀏覽器就可以了。你也可以在局域網(wǎng)上進(jìn)行這個(gè)游戲。

對(duì)于ASP,我不想做過(guò)多的說(shuō)明,在以前的文章中,我已經(jīng)說(shuō)過(guò)很多。

游戲的過(guò)程是這樣的,我們首先登錄,然后可以選擇戰(zhàn)場(chǎng),有“金星”、“木星”、“水星”、“火星”、“土星”等五個(gè)戰(zhàn)場(chǎng),如果你自認(rèn)為是一個(gè)高手,可以選擇金星,否則可以依次選擇其它幾個(gè)星球做為戰(zhàn)場(chǎng)。如果這個(gè)星球上沒(méi)有擂主,你就應(yīng)該以擂主的身份進(jìn)入,然后別人就可以和你進(jìn)行對(duì)戰(zhàn)了。當(dāng)然,如果所有的星球上都已經(jīng)開(kāi)始了戰(zhàn)爭(zhēng),那么你就只能等一會(huì)兒了。

如果你是以擂主身份進(jìn)入的,你可以等待別人來(lái)和你對(duì)戰(zhàn),如果你是以攻擂手的身份登錄,你可以很快的和擂主展開(kāi)戰(zhàn)斗。開(kāi)始戰(zhàn)斗后,由擂主執(zhí)黑先行,然后由攻擂手出招,如此這般。當(dāng)最后決出勝負(fù)的時(shí)候,會(huì)有相應(yīng)的提示。

該站點(diǎn)有幾個(gè)主要的文件是:

Index.asp 登錄文件:

Index0.asp中間文件:

Match.asp 比賽文件:

http://cfan.net.cn/info/back0.jpg white0.jpg black0.jpg 中間用到的圖形文件,分別指的棋盤(pán),白子和黑子,如下圖:

在程序的初始化的時(shí)候,將棋盤(pán)上分成若干的表格,將背景圖片放入其中,形成一個(gè)棋盤(pán),然后在放上一個(gè)棋子后,再將圖片換上相應(yīng)的白子或黑子就可以了。

先看看登錄文件:

<%@ Language=VBScript %>

<HTML>

<HEAD>

<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">

<title>星球大戰(zhàn)之“五子連珠”大賽!</title>

</HEAD>

<BODY>

 

<p align=center><font size=6>星球大戰(zhàn)</font></P>

<table border=1 width=80% align=center>

<tr><td>星球</td><td>擂主</td><td>大戰(zhàn)</td><td>攻擂</td></tr>

<tr>

<td>金星</td>

<td>

<%

if application("first1")="" then

%>

<form action=index0.asp?flag=First1 method=post>

<INPUT id=text1 name=txtFirst1 size=10><INPUT id=submit1 name=submit1
type=submit value=進(jìn)入>

</form>

<%

else

response.write application("first1")

end if

%>

</td>

<td>大戰(zhàn)</td>

<td>

<%

if application("second1")="" then

%>

 

<form action=index0.asp?flag=second1 method=post>

<INPUT id=text1 name=txtSecond1 size=10><INPUT id=submit1
name=submit1 type=submit value=進(jìn)入>

</form>

<%

else

response.write application("Second1")

end if

%>

</td>

</tr>

 

<tr>

<td>木星</td>

<td>

<%

if application("first2")="" then

%>

<form action=index0.asp?flag=First2 method=post>

<INPUT id=text1 name=txtFirst2 size=10><INPUT id=submit1 name=submit1
type=submit value=進(jìn)入>

</form>

<%

else

response.write application("first2")

end if

%>

</td>

<td>大戰(zhàn)</td>

<td>

<%

if application("second2")="" then

%>

 

<form action=index0.asp?flag=second2 method=post>

<INPUT id=text1 name=txtSecond2 size=10><INPUT id=submit1
name=submit1 type=submit value=進(jìn)入>

</form>

<%

else

response.write application("Second2")

end if

%>

</td>

</tr>

 

<tr>

<td>金星</td>

<td>

<%

if application("first3")="" then

%>

<form action=index0.asp?flag=First3 method=post>

<INPUT id=text1 name=txtFirst3 size=10><INPUT id=submit1 name=submit1
type=submit value=進(jìn)入>

</form>

<%

else

response.write application("first3")

end if

%>

</td>

<td>大戰(zhàn)</td>

<td>

<%

if application("second3")="" then

%>

 

<form action=index0.asp?flag=second3 method=post>

<INPUT id=text1 name=txtSecond3 size=10><INPUT id=submit1
name=submit1 type=submit value=進(jìn)入>

</form>

<%

else

response.write application("Second3")

end if

%>

</td>

</tr>

 

<tr>

<td>金星</td>

<td>

<%

if application("first4")="" then

%>

<form action=index0.asp?flag=First4 method=post>

<INPUT id=text1 name=txtFirst4 size=10><INPUT id=submit1 name=submit1
type=submit value=進(jìn)入>

</form>

<%

else

response.write application("first4")

end if

%>

</td>

<td>大戰(zhàn)</td>

<td>

<%

if application("second4")="" then

%>

 

<form action=index0.asp?flag=second4 method=post>

<INPUT id=text1 name=txtSecond4 size=10><INPUT id=submit1
name=submit1 type=submit value=進(jìn)入>

</form>

<%

else

response.write application("Second4")

end if

%>

</td>

</tr>

 

<tr>

<td>金星</td>

<td>

<%

if application("first5")="" then

%>

<form action=index0.asp?flag=First5 method=post>

<INPUT id=text1 name=txtFirst5 size=10><INPUT id=submit1 name=submit1
type=submit value=進(jìn)入>

</form>

<%

else

response.write application("first5")

end if

%>

</td>

<td>大戰(zhàn)</td>

<td>

<%

if application("second5")="" then

%>

 

<form action=index0.asp?flag=second5 method=post>

<INPUT id=text1 name=txtSecond5 size=10><INPUT id=submit1
name=submit1 type=submit value=進(jìn)入>

</form>

<%

else

response.write application("Second5")

end if

%>

</td>

</tr>

 



 

 

</BODY>

</HTML>

這個(gè)文件不用做過(guò)多的說(shuō)明,就是一個(gè)大的表格,大家可以從那里進(jìn)入,如果某個(gè)位置已經(jīng)被使用,則它會(huì)變成該大 俠的名字,不允許重復(fù)登錄。在登錄后進(jìn)入
index0.asp,這是一個(gè)中間交換文件,在里面進(jìn)行一些變量的處理及賦值,然后再進(jìn)入match.asp,進(jìn)行正式的比賽。我們來(lái)看一下index0.asp的內(nèi)容:

<%@ Language=VBScript %>

<%

if Request.Form("txt" & request.querystring("flag"))<>"" then

'response.write "in!" & "<Br>"

session("nice")=Request.Form("txt" & request.querystring("flag"))

'response.write session("nice") & "<Br>"

'response.write application(request.querystring("flag"))

if application(request.querystring("flag"))="" then

application(request.querystring("flag"))=session("nice")

session("class")=right(request.querystring("flag"),1)

if left(request.querystring("flag"),1)="f" then

application(session("nice"))=false

elseif left(request.querystring("flag"),1)="s" then

application(session("nice"))=false

application(application("first" & session("class")))=true

end if

Response.Redirect "match.asp"

end if

 

 

end if

 

%>

<HTML>

</HTML>

該程序中,用session(“nice”)來(lái)記錄您登錄的大名,以后的處理中,很多都要用到它,用它來(lái)區(qū)分很多的用戶(hù)。如果您是從擂主的位置進(jìn)入,則您的權(quán)利是
first,否則是second,用session("class")來(lái)記錄位于哪個(gè)戰(zhàn)場(chǎng)場(chǎng),“金”“木”
“水”“火”“土”分別表示為1、2、3、4、5,因?yàn)橛卸鄠(gè)戰(zhàn)場(chǎng)可能同時(shí)開(kāi)戰(zhàn),如果不能正確地區(qū)分開(kāi),則可能導(dǎo)致一片混亂。application(session("nice"))是一個(gè)邏輯型變量,用真假來(lái)表示您是否可以出棋,如果是假,您要等待一個(gè),如果是真,您就可以下棋了。只有一個(gè)戰(zhàn)場(chǎng)上的兩個(gè)人都進(jìn)入了以后,擂主方可以下棋,而且只有當(dāng)擂主出子以后,攻擂手才可以下棋。準(zhǔn)備好以后,下面就進(jìn)入賽場(chǎng),請(qǐng)看文件match.asp

<html>

<head>

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

<meta name="GENERATOR" content="Microsoft FrontPage 4.0">

<meta name="ProgId" content="FrontPage.Editor.Document">

<META http-equiv=refresh content=3>

<title>連珠大賽...</title>

</head>

<%

Response.Write "擂主:" & application("first" & session("class"))
& "攻擂:" & application("second" & session
("class"))

if Request.QueryString("pos")<>"" then

application("pos" & session("class") & Request.QueryString("pos"))
=true

end if

%>

<body>

<%

'Response.Write application("aaa")

if application("first" & session("class"))=session("nice") then

color="black"

if Request.QueryString("pos")<>"" then

if session("last")="" then session("last")="abc"

if session("last")<> Request.QueryString("pos") then

application(application("first" & session("class")))=false

if application("second" & session("class"))<>"" then application
(application("second" & session("class")))=true

session("last")=Request.QueryString("pos")

END IF

end if

else

if application("second" & session("class"))=session("nice") then

color="white"

if Request.QueryString("pos")<>"" then

'if session("last")="" then session("last")="abc"

if session("last")<> Request.QueryString("pos") then

application(application("first" & session("class")))=true

application(application("second" & session("class")))=false

session("last")=Request.QueryString("pos")

END IF

end if

else

if application("second" & session("class"))="" then

application("second" & session("class"))=session("nice")

color="white"

if Request.QueryString("pos")<>"" then

if session("last")="" then session("last")="abc"

if session("last")<> Request.QueryString("pos") then

application(application("first" & session("class")))=true

application(application("second" & session("class")))=false

session("last")=Request.QueryString("pos")

END IF

end if

else

color=""

end if

end if

end if

Response.Write "<table width=400 height=400 border=0 cellspacing=0
cellpadding=0>"

for i=1 to 16

Response.Write "<tr>"

for j=1 to 16

if application("pos" & session("class") & cstr(i) & "_" & cstr(j))=""
then

application("color" & session("class") & "_" & Request.QueryString
("pos"))=color

Response.Write "<td width=25 height=25>"

'response.write application(application("first" & session("class")))

if application(session("nice"))=true then

response.write "<a href=match.asp?pos=" & cstr(i) & "_" & cstr(j)
& "><img border=0 src=http://cfan.net.cn/info/back0.jpg width=25 height=25></a>"

else

response.write "<img border=0 src=http://cfan.net.cn/info/back0.jpg width=25 height=25>"

end if

response.write "</td>"

else

Response.Write "<td width=25 height=25><img border=0 src=" &
application("color" & session("class") & "_" & cstr(i) & "_" & cstr
(j)) & "0.jpg width=25 height=25></td>" & chr(13)

end if

next

Response.Write "</tr>"

next

Response.Write ""

'判斷輸贏

if application("first" & session("class"))=session("nice") then

m="black"

h="white"

else

h="black"

m="white"

end if

'橫向判斷"-"

for i=1 to 15

win=false

loss=false

five_me=0

five_he=0

for j=1 to 15

if application("color" & session("class") & "_" & cstr(i) & "_" & cstr
(j))=m then

five_me=five_me+1

five_he=0

elseif application("color" & session("class") & "_" & cstr(i) & "_" &
cstr(j))=h then

five_me=0

five_he=five_he+1

else

five_me=0

five_he=0

end if

if five_me=5 then

win=true

loss=false

exit for

elseif five_he=5 then

win=false

loss=true

exit for

end if

next

if win or loss then exit for

next

if win then

response.write "你贏了!"

application(application("first" & session("class")))=false

application(application("second" & session("class")))=false

end if

if loss then

response.write "對(duì)不起,你輸了!"

application(application("first" & session("class")))=false

application(application("second" & session("class")))=false

end if

 

'列向判斷"|"

for j=1 to 15

win=false

loss=false

five_me=0

five_he=0

for i=1 to 15

if application("color" & session("class") & "_" & cstr(i) & "_" & cstr
(j))=m then

five_me=five_me+1

five_he=0

elseif application("color" & session("class") & "_" & cstr(i) & "_" &
cstr(j))=h then

five_me=0

five_he=five_he+1

else

five_me=0

five_he=0

end if

if five_me=5 then

win=true

loss=false

exit for

elseif five_he=5 then

win=false

loss=true

exit for

end if

next

if win or loss then exit for

next

if win then

response.write "你贏了!"

application(application("first" & session("class")))=false

application(application("second" & session("class")))=false

end if

if loss then

response.write "對(duì)不起,你輸了!"

application(application("first" & session("class")))=false

application(application("second" & session("class")))=false

end if

 

'斜向判斷"/"

for i=1 to 11

win=false

loss=false

five_me=0

five_he=0

for j=i+4 to 1 step -1

if application("color" & session("class") & "_" & cstr(j) & "_" & cstr
(i+5-j))=m then

five_me=five_me+1

five_he=0

elseif application("color" & session("class") & "_" & cstr(j) & "_" &
cstr(i+5-j))=h then

five_me=0

five_he=five_he+1

else

five_me=0

five_he=0

end if

if five_me=5 then

win=true

loss=false

exit for

elseif five_he=5 then

win=false

loss=true

exit for

end if

next

if win or loss then exit for

next

if win then

response.write "你贏了!"

application(application("first" & session("class")))=false

application(application("second" & session("class")))=false

end if

if loss then

response.write "對(duì)不起,你輸了!"

application(application("first" & session("class")))=false

application(application("second" & session("class")))=false

end if

 

'斜向判斷"\"

for i=1 to 11

win=false

loss=false

five_me=0

five_he=0

for j=12-i to 15

if application("color" & session("class") & "_" & cstr(13-i-j) & "_"
& cstr(j))=m then

five_me=five_me+1

five_he=0

elseif application("color" & session("class") & "_" & cstr(13-i-j)
& "_" & cstr(j))=h then

five_me=0

five_he=five_he+1

else

five_me=0

five_he=0

end if

if five_me=5 then

win=true

loss=false

exit for

elseif five_he=5 then

win=false

loss=true

exit for

end if

next

if win or loss then exit for

next

if win then

response.write "你贏了!"

application(application("first" & session("class")))=false

application(application("second" & session("class")))=false

end if

if loss then

response.write "對(duì)不起,你輸了!"

application(application("first" & session("class")))=false

application(application("second" & session("class")))=false

end if

%>

</body>

</html>

如果某點(diǎn)沒(méi)有棋子,則加上一個(gè)超連接,根據(jù)擂主與攻擂手的區(qū)別放上一個(gè)不同顏色的棋子。最后的一段是用來(lái)判斷輸與贏,分為橫,列和兩個(gè)斜線方向。具體內(nèi)容看一下就可以明白。

最后要說(shuō)的一點(diǎn)就是global.asa ,這是站點(diǎn)上的一個(gè)核心文件,為了在退出棋局后,將位置留給別人,需要在sesison_onend中加入代碼進(jìn)行處理,如下:

<script language=vbscript runat = server>

sub application_onstart

session.timeout=1

end sub

sub session_onstart

if application("num")="" then

application("num")=0

end if

application("num")=application("num")+1

end sub

</script>

 

<script language=vbscript runat = server>

sub session_onend

if application("num")="" then

application("num")=0

end if

application("num")=application("num")-1

 

if application("first1")=session("nice") then

application("first1")=""

elseif application("second1")=session("nice") then

application("second1")=""

 

elseif application("first2")=session("nice") then

application("first2")=""

elseif application("second2")=session("nice") then

application("second2")=""

 

elseif application("first3")=session("nice") then

application("first3")=""

elseif application("second3")=session("nice") then

application("second3")=""

 

elseif application("first4")=session("nice") then
application("first4")=""
elseif application("second4")=session("nice") then
application("second4")=""
 

elseif application("first5")=session("nice") then

application("first5")=""

elseif application("second5")=session("nice") then

application("second5")=""

end if

for i=1 to 15

for j=1 to 15

application("color" & session("class") & "_" & cstr(i) & "_" & cstr
(J))=""

application("pos" & session("class") & cstr(i) & "_" & cstr(j))=""

next

next

application(session("nice"))=""

end sub

</script>

以上就是幾個(gè)主要的文件,大家可以一試。什么,想做圍棋?把棋盤(pán)改一下就可以了。

祝大家成功!

溫馨提示:喜歡本站的話(huà),請(qǐng)收藏一下本站!

本類(lèi)教程下載

系統(tǒng)下載排行

網(wǎng)站地圖xml | 網(wǎng)站地圖html
主站蜘蛛池模板: 南宫市| 曲阳县| 株洲县| 兴业县| 滁州市| 寿宁县| 宁明县| 理塘县| 邵阳县| 易门县| 滨州市| 准格尔旗| 三明市| 巩义市| 叙永县| 江油市| 土默特右旗| 绵竹市| 贵德县| 泌阳县| 屏东市| 大安市| 清苑县| 高安市| 边坝县| 灌云县| 周口市| 华容县| 嘉鱼县| 剑河县| 崇文区| 通榆县| 鱼台县| 南岸区| 九龙坡区| 福州市| 定州市| 弥勒县| 辰溪县| 苏尼特左旗| 娄烦县|