Results 1 to 30 of 30

Thread: Calculate Endpoint from X,Y,Dist,Heading [Solved]

Hybrid View

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Apr 2005
    Posts
    19

    Re: Calculate Endpoint from X,Y,Dist,Heading [Solved by Jacob]

    I'd love to learn to use DirectX but I hear it's hell in VB.

    Some of the coding I'm doing now is for an MMO I'm building. The server side is almost complete. I'm currently working on the client side. I think I'm gonna use DarkBasic for the graphic intesive stuff. From what I've read, DarkBasic is super easy to use.

  2. #2

    Thread Starter
    Junior Member
    Join Date
    Apr 2005
    Posts
    19

    Re: Calculate Endpoint from X,Y,Dist,Heading [Solved by Jacob]

    ooops actually there is still an error. Yer off of 90 degrees clockwise. Easy fix.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Apr 2005
    Posts
    19

    Re: Calculate Endpoint from X,Y,Dist,Heading [Solved By Jacob]

    I put in a fix, Angle=Angle-90 that puts it to what looks like the right place however...something strange.

    I set angle at 180. At a distance of 50 the NEW_Y2 should be 230, instead I get 233?? The NEW_X2 should remain the same since we are heading due south but I get 277?

    add this to the bottom and see what I mean.

    MsgBox New_X2 & " " & New_Y2

    It reports back 277 233 for me.

  4. #4
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: Calculate Endpoint from X,Y,Dist,Heading [Problems Still]

    You didn't have to do that with the angle. If you wanted up to be the starting position, then change these two lines:

    VB Code:
    1. X2 = Distance
    2.     Y2 = 0

    to this:

    VB Code:
    1. X2 = 0
    2.     Y2 = -Distance

    And DirectX in VB is easier than you think. It's not hell at all. If you want some killer tutorials on DirectX, then go in here:

    http://externalweb.exhedra.com/Direc...T_DX8Start.asp

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Apr 2005
    Posts
    19

    Re: Calculate Endpoint from X,Y,Dist,Heading [Problems Still]

    Any ideas about why it's reporting back the wrong numbers when I look at the values of NEW_X2 and NEW_Y2?

  6. #6
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: Calculate Endpoint from X,Y,Dist,Heading [Problems Still]

    Yeah, but before I do, I wanna see the new code that you put in your function and I'll find out for ya.

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Apr 2005
    Posts
    19

    Re: Calculate Endpoint from X,Y,Dist,Heading [Problems Still]

    Basically the same with yer one change to orient up.


    VB Code:
    1. Private Sub Form_Activate()
    2.    
    3.     'Set the Window State to Maximize to see the results.
    4.  
    5.     AutoRedraw = True
    6.     ScaleMode = 3
    7.     DrawWidth = 10
    8.  
    9.     Dim X1 As Single, Y1 As Single
    10.     Dim X2 As Single, Y2 As Single
    11.    
    12.     Dim New_X1 As Integer, New_Y1 As Integer
    13.     Dim New_X2 As Integer, New_Y2 As Integer
    14.    
    15.     Dim Center_X As Single, Center_Y As Single
    16.     Dim Distance As Single
    17.     Dim Angle As Single
    18.    
    19.     Distance = 20
    20.    
    21.     Angle = 180
    22.    
    23.    
    24.     Center_X = ScaleWidth / 2
    25.     Center_Y = ScaleHeight / 2
    26.    
    27.     X1 = 20
    28.     Y1 = 20
    29.    
    30.     X2 = 0
    31.     Y2 = -Distance
    32.    
    33.     New_X1 = Center_X + X1
    34.     New_Y1 = Center_Y + Y1
    35.    
    36.     PSet (New_X1, New_Y1)
    37.    
    38.     New_X2 = New_X1 + (X2 * Cos(Angle * PI / 180)) - (Y2 * Sin(Angle * PI / 180))
    39.     New_Y2 = New_Y1 + (X2 * Sin(Angle * PI / 180)) + (Y2 * Cos(Angle * PI / 180))
    40.        
    41.     PSet (New_X2, New_Y2), RGB(0, 250, 255)
    42. Form1.Caption = New_X2 & "  " & New_Y2
    43. End Sub

    If Y= 20 and I'm heading 20 due south at 180 the NEW_Y2 should by 40. Yet look at the form caption, it says 143.

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