下载 > 资源分类 >  课程资源 >  游戏开发 > 用vb做一个简单的射击游戏

用vb做一个简单的射击游戏

2011-06-11 上传大小:4KB
用vb做一个简单的射击游戏

Option Explicit
Dim RandX As Single
Dim RandY As Single
Dim Score As Single
Dim Thisscore As Single
Dim Average As Single
Dim Shot As Integer
Dim Appear As Boolean
Dim Distance As Singl
e

Private Sub Command1_Click()
Timer1.Enabled = True
Command3.Enabled = True
If Command1.Enabled = True Then
Command3.Caption = "暂停"
End If
Command4.Enabled = True
End Sub

Private Sub Command2_Click()
If Command4.Enabled = True Then
MsgBox "请先结束游戏", 48, "警告"
Else
End
End If
End Sub

Private Sub Command3_Click()
Command1.Enabled = False
Command3.Caption = "继续"
Timer1.Enabled = Not Timer1.Enabled
If Timer1.Enabled = True Then
Command3.Caption = "暂停"
End If

End Sub

Private Sub Command4_Click()
Timer1.Enabled = False
Command3.Enabled = False
Command1.Enabled = True
Picture1.Cls
Label1.Caption = "射击:"
Label2.Caption = "平均得分:"

Label3.Caption = "环数:"

Label4.Caption = "总分:"
Command4.Enabled = False
Command3.Caption = "暂停"
End Sub

Private Sub Form_Load()
Appear = False
Timer1.Enabled = False
Thisscore = 0
Score = 0
Shot = 0


End Sub


Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Beep
Shot = Shot + 1
Picture1.DrawWidth = 4
Picture1.PSet (X, Y), RGB(255, 0, 0)
Distance = Sqr((X - RandX) * (X - RandX) + (Y - RandY) * (Y - RandY))
If Appear And Timer1.Enabled Then
Thisscore = 5 - Int(Distance / 10)
If Thisscore <= 0 Then
Thisscore = 0
End If
Score = Score + Thisscore
Average = Int((Score / Shot) * 100) / 100
Label1.Caption = "射击:" + Str(Shot) + "发"
Label2.Caption = "平均得分:" & Format(Average, "0.00") & "环"

Label3.Caption = "环数:" + Str(Thisscore) + "环"

Label4.Caption = "总分:" + Str(Score) + "环"
End If


End Sub

Private Sub Timer1_Timer()
Dim i As Integer
Appear = Appear Xor True
RandX = 500 * Rnd()
RandY = 370 * Rnd()
If Appear Then
Form1.Picture1.AutoRedraw = True
Picture1.DrawWidth = 1
Picture1.DrawStyle = 0
For i = 10 To 50 Step 10
Picture1.Circle (RandX, RandY), i, RGB(0, 0, 255)
Next i
Picture1.Line (RandX - 60, RandY)-(RandX + 60, RandY)
Picture1.Line (RandX, RandY - 60)-(RandX, RandY + 60)
Else
Picture1.Cls
End If

End Sub
...展开收缩
综合评分:4.2(5位用户评分)
开通VIP C币充值 立即下载

评论共有2条

name
caoyongqing2014-12-02 22:20:40
很有意思,对我帮助很大,我正需要这样的设计。
name
dgideas2012-07-18 19:55:37
不算太好,但是代码量很少,值得研究

评论资源

您不能发表评论,可能是以下原因:

登录后才能评论

待评论资源
 

热门专辑

img
x284785185

关注

等级:2积分 113

课程资源热门标签

VIP会员动态

关闭
img

spring mvc+mybatis+mysql+maven+bootstrap 整合实现增删查改简单实例.zip

资源所需积分/C币 当前拥有积分 当前拥有C币
5 0 0
为了良好体验,不建议使用迅雷下载
确认下载
img

用vb做一个简单的射击游戏

会员到期时间: 剩余下载个数: 剩余C币:593 剩余积分:0
为了良好体验,不建议使用迅雷下载
VIP下载
您今日下载次数已达上限(为了良好下载体验及使用,每位用户24小时之内最多可下载20个资源)

积分不足!

资源所需积分/C币 当前拥有积分
您可以选择
开通VIP
4000万
程序员的必选
600万
绿色安全资源
现在开通
立省522元
或者
购买C币兑换积分 C币抽奖
img

资源所需积分/C币 当前拥有积分 当前拥有C币
5 4 45
(仅够下载10个资源)
为了良好体验,不建议使用迅雷下载
确认下载
img

资源所需积分/C币 当前拥有积分 当前拥有C币
5 0 0
为了良好体验,不建议使用迅雷下载
C币充值 开通VIP
img

资源所需积分/C币 当前拥有积分 当前拥有C币
5 4 45
您的积分不足,将扣除 10 C币
为了良好体验,不建议使用迅雷下载
确认下载
下载

兑换成功

你当前的下载分为234开始下载资源
你还不是VIP会员
开通VIP会员权限,免积分下载
立即开通

你下载资源过于频繁,请输入验证码

您因违反CSDN下载频道规则而被锁定帐户,如有疑问,请联络:webmaster@csdn.net!

举报

若举报审核通过,可奖励20下载分

  • 举报人:
  • 被举报人:
  • 举报的资源分:
  • *类型:
  • *详细原因: