-
asp.net教程之ASP做的剪包锤游戏
<%
'*********************************************
' 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
%>
<P><CENTER>
<IMG SRC="images/rock_beats_scissors.gif">
Your ROCK crushed the computer's SCISSORS!"</CENTER>
<%
End If
ElseIf playerChoice = Scissor Then
If computerChoice = Paper Then
%>
<P><CENTER>
<IMG SRC="images/scissors_beats_paper.gif">
Your SCISSORS cut up the computer's PAPER!</CENTER>
<%
End If
ElseIf playerChoice = Paper Then
If computerChoice = Rock Then
%>
<P><CENTER>
<IMG SRC="images/paper_beats_rock.gif">
Your PAPER stumped the computer's ROCK!</CENTER>
<%
End If
ElseIf playerChoice = computerChoice Then
%>
<p><CENTER>
<IMG SRC="images/tie.gif">
We seem to have a tie!</CENTER>
<%
End If
If computerChoice = Rock Then
If playerChoice = Scissor Then
%>
<P><CENTER>
<IMG SRC="images/rock_beats_scissors.gif">
The computer's ROCK crushed your SCISSORS!</CENTER>
<%
ElseIf playerChoice = computerChoice Then
%>
<P><CENTER>
<IMG SRC="images/tie.gif">
We seem to have a tie!</CENTER>
<%
End If
ElseIf computerChoice = Scissor Then
If playerChoice = Paper Then
%>
<P><CENTER>
<IMG SRC="IMAGES/scissors_beats_paper.gif">
The computer's SCISSOR cut up your PAPER!</CENTER>
<%
ElseIf playerChoice = computerChoice Then
%>
<P><CENTER>
<IMG SRC="images/tie.gif">
We seem to have a tie!</CENTER>
<%
End If
ElseIf computerChoice = Paper Then
If playerChoice = Rock Then
%>
<P><CENTER>
<IMG SRC="images/paper_beats_rock.gif">
The computer's PAPER stumped your ROCK!</CENTER>
<%
ElseIf playerChoice = computerChoice Then
%>
<P><CENTER>
<IMG SRC="images/tie.gif">
We seem to have a tie!</CENTER>
<%
End If
ElseIf computerChoice = playerChoice Then
%>
<P><CENTER>
<IMG SRC="images/tie.gif">
We seem to have a tie!</CENTER>
<%
End If
End Sub
'*********************************************
' THIS FUNCTION WILL CAUSE THE GAME TO
' EXECUTE UNLESS A DIFFERENT ACTION WAS CHOSEN
'*********************************************
Sub playGame()
%>
<CENTER><H1>Welcome to the famous game: ROCK, SCISSORS, PAPER!
Good Luck!</H1>
<H3>Please choose your weapon:</H3>
<FORM ACTION="index.asp?action=winner" METHOD="post">
<TABLE>
<TR VALIGN=top>
<TD>ROCK</TD>
<TD><INPUT TYPE="radio" NAME="playerSelect" VALUE="R"></TD>
</TR>
<TR VALIGN=top>
<TD>SCISSOR</TD>
<TD><INPUT TYPE="radio" NAME="playerSelect" VALUE="S"></td>
</TR>
<TR VALIGNn=top>
<TD>PAPER</TD>
<TD><INPUT TYPE="radio" NAME="playerSelect" VALUE="P"></TD>
</TR>
</TABLE>
<INPUT TYPE="submit" VALUE="Play Game">
</CENTER>
<%
End Sub
'********************************************
' THIS FUNCTION WILL BE RUN IF THE GAME IS
' PLAYED
'********************************************
Sub playAgain()
%>
<CENTER>Would you like to play this game again?</CENTER>
<CENTER><A HREF="index.asp">YES
<A HREF="index.asp?action=gameover">NO
</CENTER><%
End Sub
'*********************************************
' THIS FUNCTION WILL BE DISPLAYED WILL THE
' PERSON CHOOSES TO END THE GAME
'*********************************************
Sub endGame()
Response.Buffer = true
Response.Redirect "http://www.getasite.net"
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
'*********************************************
' 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
%>
<P><CENTER>
<IMG SRC="images/rock_beats_scissors.gif">
Your ROCK crushed the computer's SCISSORS!"</CENTER>
<%
End If
ElseIf playerChoice = Scissor Then
If computerChoice = Paper Then
%>
<P><CENTER>
<IMG SRC="images/scissors_beats_paper.gif">
Your SCISSORS cut up the computer's PAPER!</CENTER>
<%
End If
ElseIf playerChoice = Paper Then
If computerChoice = Rock Then
%>
<P><CENTER>
<IMG SRC="images/paper_beats_rock.gif">
Your PAPER stumped the computer's ROCK!</CENTER>
<%
End If
ElseIf playerChoice = computerChoice Then
%>
<p><CENTER>
<IMG SRC="images/tie.gif">
We seem to have a tie!</CENTER>
<%
End If
If computerChoice = Rock Then
If playerChoice = Scissor Then
%>
<P><CENTER>
<IMG SRC="images/rock_beats_scissors.gif">
The computer's ROCK crushed your SCISSORS!</CENTER>
<%
ElseIf playerChoice = computerChoice Then
%>
<P><CENTER>
<IMG SRC="images/tie.gif">
We seem to have a tie!</CENTER>
<%
End If
ElseIf computerChoice = Scissor Then
If playerChoice = Paper Then
%>
<P><CENTER>
<IMG SRC="IMAGES/scissors_beats_paper.gif">
The computer's SCISSOR cut up your PAPER!</CENTER>
<%
ElseIf playerChoice = computerChoice Then
%>
<P><CENTER>
<IMG SRC="images/tie.gif">
We seem to have a tie!</CENTER>
<%
End If
ElseIf computerChoice = Paper Then
If playerChoice = Rock Then
%>
<P><CENTER>
<IMG SRC="images/paper_beats_rock.gif">
The computer's PAPER stumped your ROCK!</CENTER>
<%
ElseIf playerChoice = computerChoice Then
%>
<P><CENTER>
<IMG SRC="images/tie.gif">
We seem to have a tie!</CENTER>
<%
End If
ElseIf computerChoice = playerChoice Then
%>
<P><CENTER>
<IMG SRC="images/tie.gif">
We seem to have a tie!</CENTER>
<%
End If
End Sub
'*********************************************
' THIS FUNCTION WILL CAUSE THE GAME TO
' EXECUTE UNLESS A DIFFERENT ACTION WAS CHOSEN
'*********************************************
Sub playGame()
%>
<CENTER><H1>Welcome to the famous game: ROCK, SCISSORS, PAPER!
Good Luck!</H1>
<H3>Please choose your weapon:</H3>
<FORM ACTION="index.asp?action=winner" METHOD="post">
<TABLE>
<TR VALIGN=top>
<TD>ROCK</TD>
<TD><INPUT TYPE="radio" NAME="playerSelect" VALUE="R"></TD>
</TR>
<TR VALIGN=top>
<TD>SCISSOR</TD>
<TD><INPUT TYPE="radio" NAME="playerSelect" VALUE="S"></td>
</TR>
<TR VALIGNn=top>
<TD>PAPER</TD>
<TD><INPUT TYPE="radio" NAME="playerSelect" VALUE="P"></TD>
</TR>
</TABLE>
<INPUT TYPE="submit" VALUE="Play Game">
</CENTER>
<%
End Sub
'********************************************
' THIS FUNCTION WILL BE RUN IF THE GAME IS
' PLAYED
'********************************************
Sub playAgain()
%>
<CENTER>Would you like to play this game again?</CENTER>
<CENTER><A HREF="index.asp">YES
<A HREF="index.asp?action=gameover">NO
</CENTER><%
End Sub
'*********************************************
' THIS FUNCTION WILL BE DISPLAYED WILL THE
' PERSON CHOOSES TO END THE GAME
'*********************************************
Sub endGame()
Response.Buffer = true
Response.Redirect "http://www.getasite.net"
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
栏目列表
最新更新
nodejs爬虫
Python正则表达式完全指南
爬取豆瓣Top250图书数据
shp 地图文件批量添加字段
爬虫小试牛刀(爬取学校通知公告)
【python基础】函数-初识函数
【python基础】函数-返回值
HTTP请求:requests模块基础使用必知必会
Python初学者友好丨详解参数传递类型
如何有效管理爬虫流量?
SQL SERVER中递归
2个场景实例讲解GaussDB(DWS)基表统计信息估
常用的 SQL Server 关键字及其含义
动手分析SQL Server中的事务中使用的锁
openGauss内核分析:SQL by pass & 经典执行
一招教你如何高效批量导入与更新数据
天天写SQL,这些神奇的特性你知道吗?
openGauss内核分析:执行计划生成
[IM002]Navicat ODBC驱动器管理器 未发现数据
初入Sql Server 之 存储过程的简单使用
这是目前我见过最好的跨域解决方案!
减少回流与重绘
减少回流与重绘
如何使用KrpanoToolJS在浏览器切图
performance.now() 与 Date.now() 对比
一款纯 JS 实现的轻量化图片编辑器
关于开发 VS Code 插件遇到的 workbench.scm.
前端设计模式——观察者模式
前端设计模式——中介者模式
创建型-原型模式