当前位置: 首页 > 图文教程 > 网络编程 > ASP > ASP作的剪包锤游戏
'*********************************************
' THIS FUNCTION GENERATES A RANDOM NUMBER
'*********************************************
Function computerChooses()
Dim randomNum
Dim choice
randomize
randomNum = int(rnd*15)+1
If randomNum = 1 OR randomNum = 3 OR randomNum = 7 OR randomNum = 8 OR randomNum = 15 OR randomNum = 12 Then
choice = "R"
ElseIf randomNum = 2 OR randomNum = 6 OR randomNum = 11 OR randomNum = 13 Then
choice = "S"
Else
choice = "P"
End If
computerChooses = choice
End Function
'*********************************************
' THIS FUNCTION SIMPLY DETERMINES THE WINNER
' OF THE GAME
'*********************************************
Sub determineWinner(playerChoice, computerChoice)
Const Rock = "R"
Const Scissor = "S"
Const Paper = "P"
Dim tempPlayer, tempComputer
If playerChoice = Rock Then
If computerChoice = Scissor Then
%>
<P><CENTER>
<IMG src="/upload/tech/20091103/20091103093253_5b8add2a5d98b1a652ea7fd72d942dac.gif"><BR>
Your ROCK crushed the computer's SCISSORS!"</CENTER>
<%
End If
ElseIf playerChoice = Scissor Then
If computerChoice = Paper Then
%>
<P><CENTER>
<IMG src="/upload/tech/20091103/20091103093253_6aca97005c68f1206823815f66102863.gif"><BR>
Your SCISSORS cut up the computer's PAPER!</CENTER>
<%
End If
ElseIf playerChoice = Paper Then
If computerChoice = Rock Then
%>
<P><CENTER>
<IMG src="/upload/tech/20091103/20091103093254_ea5d2f1c4608232e07d3aa3d998e5135.gif"><BR>
Your PAPER stumped the computer's ROCK!</CENTER>
<%
End If
ElseIf playerChoice = computerChoice Then
%>
<p><CENTER>
<IMG src="/upload/tech/20091103/20091103093255_cee631121c2ec9232f3a2f028ad5c89b.gif"><BR>
We seem to have a tie!</CENTER>
<%
End If
If computerChoice = Rock Then
If playerChoice = Scissor Then
%>
<P><CENTER>
<IMG src="/upload/tech/20091103/20091103093253_5b8add2a5d98b1a652ea7fd72d942dac.gif"><BR>
The computer's ROCK crushed your SCISSORS!</CENTER>
<%
ElseIf playerChoice = computerChoice Then
%>
<P><CENTER>
<IMG src="/upload/tech/20091103/20091103093255_cee631121c2ec9232f3a2f028ad5c89b.gif"><BR>
We seem to have a tie!</CENTER>
<%
End If
ElseIf computerChoice = Scissor Then
If playerChoice = Paper Then
%>
<P><CENTER>
<IMG src="/upload/tech/20091103/20091103093257_1700002963a49da13542e0726b7bb758.gif"><BR>
The computer's SCISSOR cut up your PAPER!</CENTER>
<%
ElseIf playerChoice = computerChoice Then
%>
<P><CENTER>
<IMG src="/upload/tech/20091103/20091103093255_cee631121c2ec9232f3a2f028ad5c89b.gif"><BR>
We seem to have a tie!</CENTER>
<%
End If
ElseIf computerChoice = Paper Then
If playerChoice = Rock Then
%>
<P><CENTER>
<IMG src="/upload/tech/20091103/20091103093254_ea5d2f1c4608232e07d3aa3d998e5135.gif"><BR>
The computer's PAPER stumped your ROCK!</CENTER>
<%
ElseIf playerChoice = computerChoice Then
%>
<P><CENTER>
<IMG src="/upload/tech/20091103/20091103093255_cee631121c2ec9232f3a2f028ad5c89b.gif"><BR>
We seem to have a tie!</CENTER>
<%
End If
ElseIf computerChoice = playerChoice Then
%>
<P><CENTER>
<IMG src="http://www.ruanchen.com/iles/BeyondPic/chinazcj/2005-11/18/0511182238102970"
评论 (0) All