PC6下载站

分类分类

ASP作的剪包锤游戏

关注+2004-10-07作者:蓝点




<%
'*********************************************
' THIS IS A SIMPLE GAME OF ROCK SCISSORS PAPER
' FEEL FREE TO DO WHATEVER YOU LIKE WITH THIS
' SCRIPT! -IAN S. CARROLL
'*********************************************


'*********************************************
' 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
%>




Your ROCK crushed the computer's SCISSORS!"


<%
End If

ElseIf playerChoice = Scissor Then

If computerChoice = Paper Then
%>




Your SCISSORS cut up the computer's PAPER!


<%
End If

ElseIf playerChoice = Paper Then

If computerChoice = Rock Then
%>




Your PAPER stumped the computer's ROCK!


<%
End If

ElseIf playerChoice = computerChoice Then
%>




We seem to have a tie!


<%
End If


If computerChoice = Rock Then

If playerChoice = Scissor Then
%>




The computer's ROCK crushed your SCISSORS!


<%
ElseIf playerChoice = computerChoice Then
%>




We seem to have a tie!


<%
End If

ElseIf computerChoice = Scissor Then

If playerChoice = Paper Then
%>




The computer's SCISSOR cut up your PAPER!


<%
ElseIf playerChoice = computerChoice Then
%>




We seem to have a tie!


<%
End If

ElseIf computerChoice = Paper Then

If playerChoice = Rock Then
%>


The computer's PAPER stumped your ROCK!


<%

ElseIf playerChoice = computerChoice Then
%>



We seem to have a tie!


<%
End If
ElseIf computerChoice = playerChoice Then
%>



We seem to have a tie!


<%
End If


End Sub


'*********************************************
' THIS FUNCTION WILL CAUSE THE GAME TO
' EXECUTE UNLESS A DIFFERENT ACTION WAS CHOSEN
'*********************************************
Sub playGame()
%>

Welcome to the famous game: ROCK, SCISSORS, PAPER!

Good Luck!




Please choose your weapon:

















ROCK

SCISSOR

PAPER




<%
End Sub


'********************************************
' THIS FUNCTION WILL BE RUN IF THE GAME IS
' PLAYED
'********************************************
Sub playAgain()
%>

Would you like to play this game again?



YES
NO


<%
End Sub


'*********************************************
' THIS FUNCTION WILL BE DISPLAYED WILL THE
' PERSON CHOOSES TO END THE GAME
'*********************************************
Sub endGame()
Response.Buffer = true

Response.Redirect "http://www.luckybbs.com"


End Sub


'*********************************************
' THE BASIC RUN-TIME SCRIPT
'*********************************************
Dim player, computer
Dim gameAction
gameAction = Request.QueryString("action")

Select Case gameAction
Case "winner"
player = Request.Form("playerSelect")
computer = computerChooses

determineWinner player, computer
Response.Write "

"
playAgain

Case "again"
playAgain

Case "gameover"
endGame

Case Else
playGame

End Select
%>

展开全部

相关文章

更多+相同厂商

热门推荐

  • 最新排行
  • 最热排行
  • 评分最高
排行榜

    点击查看更多

      点击查看更多

        点击查看更多

        说两句网友评论

          我要评论...
          取消