最新帖子 精华区 社区服务 会员列表 统计排行
主题 : [问题]VB关于 鼠标事件 的游戏
dianyancao 离线
级别: 新手
显示用户信息 
0  发表于: 2009-08-01 11:15

[问题]VB关于 鼠标事件 的游戏

附件: 窗体 与 工程.rar 充值交易币(1交易币=1¥) (18 K) 下载次数:9 VB或ASP(不含ASP.NET)设计包调试联系QQ:772789394 介绍朋友购买可获优惠
购买流程:注册论坛账号------->在线充值购买论坛交易币------->下载毕业设计将直接扣除交易币
'问题1:工程运行时,使飞机坠毁,Plane.Picture调用的图标要在 工程"飞行.exe"  之外获得...怎么样才能在程序内部调用 图标"飞机残骸.jpg"?
问题2:为什么 子例程Sub sclcrs() 画的坐标轴 在运行工程"飞行.exe" 时怎么不会显示?


'Form源码:
Const ukcx As Single = 1050, ukcy As Single = 1100
Const uscx As Single = 3700, uscy As Single = 1650
Const landr = 275
Dim uktous As Boolean
Dim donf As Single
Private Sub Form_Load()
  donf = Sqr((ukcx - uscx) ^ 2 + (ukcy - uscy) ^ 2)
  sclcrs
  init
End Sub
Private Sub sclcrs()
  Dim I As Integer
  For I = 1 To 2
  Load Shape1(I)
  Shape1(I).Visible = True
  Shape1(I).Shape = vbShapeCircle
  Shape1(I).Width = landr * 2
  Shape1(I).Height = landr * 2
  Shape1(I).ZOrder
  Next I
  Shape1(1).Left = ukcx - landr
  Shape1(1).Top = ukcy - landr
  Shape1(2).Left = uscx - landr
  Shape1(2).Top = uscy - landr
  For I = 1 To 4
  Load Line1(I)
  Line1(I).Visible = True
  Line1(I).ZOrder
  Next I
  Line1(1).X1 = ukcx - landr
  Line1(1).X2 = ukcx + landr
  Line1(1).Y2 = ukcy
  Line1(1).Y2 = ukcy
  Line1(2).X1 = ukcx
  Line1(2).X2 = ukcx
  Line1(2).Y2 = ukcy - landr
  Line1(2).Y2 = ukcy + landr
  Line1(3).X1 = uscx - landr
  Line1(3).X2 = uscx + landr
  Line1(3).Y2 = uscy
  Line1(3).Y2 = uscy
  Line1(4).X1 = uscx
  Line1(4).X2 = uscx
  Line1(4).Y2 = uscy - landr
  Line1(4).Y2 = uscy + landr
End Sub
Private Sub init()
  Warn.Enabled = False
  Plane.Left = ukcx - Plane.Width / 2
  Plane.Top = uscy - Plane.Height / 2
  Plane.Enabled = True
  uktous = True
  Call info("准备从英国飞往美国")
End Sub
Private Sub info(ByVal msg As String)
  Pane1.ForeColor = &H0&
  Pane1 = msg
End Sub
Private Sub plane_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
If uktous Then
Call info("飞往美国")
Else
Call info("飞往英国")
End If
Warn.Enabled = False
End Sub
Private Sub plane_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
Dim d As Single
If Button = 1 Then
   x = x + Plane.Left
   y = y + Plane.Top
   Plane.Move x - Plane.Width \ 2, y - Plane.Height \ 2
   If uktous Then
   d = Sqr((x - uscx) ^ 2 + (y - uscy) ^ 2)
   Call info("距美国" & Format(d / donf * 2000, "####.00") & "公里")
   Else
   d = Sqr((x - ukcx) ^ 2 + (y - ukcy) ^ 2)
   Call info("距英国" & Format(d / donf * 2000, "####.00") & "公里")
   End If
   If x < 0 Or x > Form1.ScaleWidth Or y < 0 Or y > Form1.ScaleHeight Then
   Call warninfo("警报!飞机消失")
   End If
  End If
End Sub
Private Sub warninfo(ByVal msg As String)
  Pane1.ForeColor = &HFF&
  Pane1 = msg
End Sub
Private Sub plane_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
Dim d1 As Single
Dim d2 As Single
x = Plane.Left + x
y = Plane.Top + y
d1 = Sqr((x - uscx) ^ 2 + (y - uscy) ^ 2)
d2 = Sqr((x - ukcx) ^ 2 + (y - ukcy) ^ 2)
  If d1 < landr And uktous Then
  Call info("成功飞抵美国")
  uktous = False
  ElseIf d2 < landr And uktous Then
  Call warninfo("迫降返回英国")
  ElseIf d1 < landr And Not uktous Then
  Call warninfo("迫降返回美国")
  ElseIf d2 < landr And Not uktous Then
  Call info("成功飞抵英国")
  uktous = True
  Else
  Call warninfo("警报!飞机无法降落,将在三秒内坠毁")
  Warn.Enabled = True
  End If
End Sub

Private Sub Warn_Timer()
Call warninfo("空难!飞机坠毁")
Pane1.Picture = LoadPicture("D:\飞机残骸.jpg")
Plane.Enabled = False
Warn.Enabled = False
End Sub

Private Sub form_dblclick()
init
End Sub

附件: 窗体 与 工程.rar 充值交易币(1交易币=1¥) (18 K) 下载次数:9 VB或者ASP设计可以联系管理QQ:772789394 包调试
快速回复 顶端
内容
HTML 代码不可用
使用签名
Wind Code自动转换

验证问题:本站域名是什么?答案:cccbbs.net  正确答案:cccbbs.net
按"Ctrl+Enter"直接提交