|
-
Nov 29th, 2001, 05:25 PM
#1
Thread Starter
Junior Member
help!!!!!!!!!
well i made this little 2 player pong program. but the problem is is that getsasynckeystate stoped working after i added intersectrect. here is my code can someone please tell me whats wrong.
Dim x As Integer
Dim y As Integer
Dim u As Integer
Dim o As Integer
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If GetAsyncKeyState(VK_UP) <> 0 Then
yellowteam.Top = yellowteam.Top - 100
End If
If GetAsyncKeyState(VK_DOWN) <> 0 Then
yellowteam.Top = yellowteam.Top + 100
End If
If GetAsyncKeyState(VK_A) <> 0 Then
redteam.Top = redteam.Top - 100
End If
If GetAsyncKeyState(VK_Z) <> 0 Then
redteam.Top = redteam.Top + 100
End If
End Sub
Public Sub detect()
Dim blueness As RECT
Dim orangeness As RECT
Dim lefty As RECT
Dim righty As RECT
Dim Form As RECT
With lefty
.Top = redteam.Top
.Left = redteam.Left
.Right = redteam.Left + redteam.Width
.Bottom = redteam.Top + redteam.Height
End With
With righty
.Top = yellowteam.Top
.Left = yellowteam.Left
.Right = yellowteam.Left + yellowteam.Width
.Bottom = yellowteam.Top + yellowteam.Height
End With
With blueness
.Top = bball.Top
.Left = bball.Left
.Right = bball.Left + bball.Width
.Bottom = bball.Top + bball.Width
End With
With orangeness
.Top = oball.Top
.Left = oball.Left
.Right = oball.Left + oball.Width
.Bottom = oball.Top + oball.Height
End With
With Form
.Top = form1.Top
.Left = form1.Left
.Right = form1.Left + form1.Width
.Bottom = form1.Top + form1.Height
End With
If IntersectRect(Form, blueness, lefty) Then
x = x * -1
End If
If IntersectRect(Form, blueness, righty) Then
x = x * -1
End If
If IntersectRect(Form, orangeness, lefty) Then
o = o * -1
End If
If IntersectRect(Form, orangeness, righty) Then
o = o * -1
End If
End Sub
Private Sub Form_Load()
x = 50
o = 50
u = 50
y = 50
End Sub
Private Sub Timer1_Timer()
bball.Left = bball.Left + x
bball.Top = bball.Top - y
oball.Top = oball.Top + u
oball.Left = oball.Left - o
detect
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|