请教三个球在容器内运动的程序?!

liusahara liusahara 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
我是用三个圆形的label分别为label1,label2,label3做球,容器就是form,有一个timer1,还有一个text=“move”的button。球与壁的碰撞没有问题,只是球与球之间的碰撞不知道哪里出问题了。
请高手帮我看下,运行环境:vs2005

Public Class Form1
Declare Function GetActiveWindow Lib "user32" () As Integer
Declare Function SetWindowRgn Lib "user32" (ByVal hWnd As Integer, _
ByVal hRgn As Integer, _
ByVal bRedraw As Boolean) As Integer
Declare Function CreateEllipticRgn Lib "gdi32" (ByVal X1 As Integer, _
ByVal Y1 As Integer, _
ByVal X2 As Integer, _
ByVal Y2 As Integer) As Integer
Declare Function CreateRectRgn Lib "gdi32" (ByVal X1 As Integer, _
ByVal Y1 As Integer, _
ByVal X2 As Integer, _
ByVal Y2 As Integer) As Integer
Declare Function GetWindow Lib "user32" (ByVal hwnd As Integer, ByVal wCmd As Integer) As Integer
Private Const GW_HWNDFIRST = 0
Private Const GW_HWNDNEXT = 2
Private Const GW_CHILD = 5
Private Const PI = 3.14159
Dim dx As Integer, dy As Integer
Dim dx1 As Integer, dy1 As Integer
'Dim ilal As Integer
'Dim idxdy As Integer
'Dim lal(2) As Label
'Dim dx(2) As Long
'Dim dy(2) As Long
Dim point(1) As Point
Dim distance As Integer
Dim dz As Single, dtan As Single, dpz As Single
Dim slal As Single, spint As Single
Dim tlalx As Single, tlaly As Single
Dim tpintx As Single, tpinty As Single
Dim nlalx As Single, nlaly As Single
Dim npintx As Single, npinty As Single
Dim angle2 As Single, angle1 As Single, angle3 As Single
Dim angle2l As Single, angle1l As Single, angle3l As Single

Private Sub Form1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Click
'TextBox1.Text = Me.Bottom & " " & Me.Top & " " & Me.Height
'TextBox2.Text = Me.Left & " " & Me.Right & " " & Me.Width
Dim myhwnd, r1 As Integer, i As Integer
myhwnd = GetActiveWindow()
myhwnd = GetWindow(myhwnd, GW_CHILD)
r1 = CreateEllipticRgn(0, 0, 50, 50)
Call SetWindowRgn(myhwnd, r1, True)
For i = 0 To 1
myhwnd = GetWindow(myhwnd, GW_HWNDNEXT)
r1 = CreateEllipticRgn(0, 0, 50, 50)
Call SetWindowRgn(myhwnd, r1, True)
Next
End Sub

...全文
评论 6
收藏 已收藏
分享
返回顶部
liusahara
VB 16,718 成员 110,520 内容