上一篇 | 下一篇

ASP作的剪包锤游戏

发布: 2008-6-27 11:48 | 作者: admin | 来源: | 查看: 0次

<%

'*********************************************

' 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

字号: | 推荐给好友

31/3123>

评分:0

我来说两句