Results 1 to 2 of 2

Thread: help!!!!!!!!!

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Sep 2001
    Posts
    22

    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

  2. #2
    Addicted Member Osiris's Avatar
    Join Date
    Oct 2000
    Location
    Dimension Hole
    Posts
    142
    if it dont work why dont you try using a different way of moving
    yellowteam & redteam up or down
    try this:

    Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    If Keycode = 38 Then ''KEY UP
    yellowteam.Top = yellowteam.Top - 100
    End If
    If Keycode = 40 Then ''KEY DOWN
    yellowteam.Top = yellowteam.Top + 100
    End If
    If Keycode = 65 Then ''KEY A
    redteam.Top = redteam.Top - 100
    End If
    If Keycode = 90 Then ''KEY Z
    redteam.Top = redteam.Top + 100
    End If
    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
  •  



Click Here to Expand Forum to Full Width