Results 1 to 2 of 2

Thread: Equation of a line messup

  1. #1

    Thread Starter
    Hyperactive Member notquitehere188's Avatar
    Join Date
    Dec 2004
    Posts
    403

    Exclamation Equation of a line messup

    I have this code
    it is suppoed to find all the variables for Y = MX + B and use them to find if the aim line goes through the left side of the player but it does not work


    VB Code:
    1. For X = 1 To MaxBullets
    2.     With Bullet(X)
    3.         If .Visible = True Then
    4.             L1 = .Left - .Xinertia
    5.             L2 = .Left
    6.             T1 = (.Top - .Yinertia)
    7.             T2 = .Top
    8.             M = (T2 - T1) / (L2 - L1)
    9.             B = T1 - (M * L1)
    10.         End If
    11.     End With
    12.     For Y = 1 To PlayerCount
    13.         With player(Y)
    14.             'if the line goes over the point then it is true
    15.             'Uses Y = MX + B
    16.             '    Y       MX       +B
    17.             If .Top < (M * .Left) + B Then Cnr(1) = True
    18.             If .Top < (M * (.Left + .Width)) + B Then Cnr(2) = True
    19.             If (.Top + .Height) < (M * .Left) + B Then Cnr(3) = True
    20.             If (.Top + .Height) < (M * (.Left + .Width)) + B Then Cnr(4) = True
    21.         End With
    22.        
    23.         If Cnr(1) = False And Cnr(3) = True Then
    24.             Bullet(X).Visible = False
    25.         End If
    26.     Next Y
    27. Next X

    HELP!!!
    It's not just Good, It's Good enough!



    Spelling Eludes Me

  2. #2
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Re: Equation of a line messup

    Hit detection for polygons.

    http://support.microsoft.com/kb/q121960/
    I don't live here any more.

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