当前位置: 首页 > 图文教程 > 网络编程 > ASP > ASP作的剪包锤游戏

ASP
Asp+Sql 对数据库的各种操作
ASP:6行代码实现无组件上传
ASP中几种分页显示的比较
ASP中数据库调用中常见错误的现象和解决
ASP实用技巧:强制刷新和判断文件地址
asp全站防止注入的代码
ASP如何获取客户端真实IP地址
ASP实现可显示和隐藏的树型菜单
如何用ASP获取真实IP地址
ASP与SQL数据库连接代码
拒绝攻击 万能Asp防注入代码
草根站长成长计划:跟我学新云采集入门(2)
ASP技巧:提高使用Request集合的效率
Asp用存储过程实现数据分页
做网页时常用的ASP函数
Asp编码优化技巧八则
ASP中Cache技术的应用
用ASP封IP的方法,防止固定IP垃圾留言
ASP实现一行多列显示方法实例程序
ASP实现动态添加表单内容的实例程序

ASP作的剪包锤游戏


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 26 ::
收藏到网摘: n/a

<%
'*********************************************
' 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="/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"