请教三个球在容器内运动的程序?!
我是用三个圆形的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
请高手帮我看下,运行环境: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
...全文
相关推荐
运动的球(JS)
就是一个球在网页上弹来弹去,碰到边缘会反弹
javascript实现10个球随机运动、碰撞实例详解
主要介绍了javascript实现10个球随机运动、碰撞的方法,实例分析了javascript实现小球碰撞的原理与实现技巧,具有一定参考借鉴价值,需要的朋友可以参考下
三个容器的倒水问题(C语言实现)
NULL 博文链接:https://touch-2011.iteye.com/blog/1038893
球球大作战C++源码
欢迎大家下载球球大作战源码,有问题的话可以一起交流,互相学习。
宝可梦推精灵球项目,使用了easyx库和C++容器的知识
使用easyx图形库写的推箱子游戏,宝可梦风格,内容简单易上手,适合学完C++容器后实战!


