|
-
Apr 23rd, 2005, 05:33 PM
#1
Thread Starter
Junior Member
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.
-
Apr 23rd, 2005, 06:13 PM
#2
Thread Starter
Junior Member
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.
-
Apr 23rd, 2005, 06:38 PM
#3
Thread Starter
Junior Member
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.
-
Apr 23rd, 2005, 06:55 PM
#4
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:
to this:
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
-
Apr 23rd, 2005, 07:14 PM
#5
Thread Starter
Junior Member
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?
-
Apr 23rd, 2005, 07:16 PM
#6
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.
-
Apr 23rd, 2005, 07:20 PM
#7
Thread Starter
Junior Member
Re: Calculate Endpoint from X,Y,Dist,Heading [Problems Still]
Basically the same with yer one change to orient up.
VB Code:
Private Sub Form_Activate()
'Set the Window State to Maximize to see the results.
AutoRedraw = True
ScaleMode = 3
DrawWidth = 10
Dim X1 As Single, Y1 As Single
Dim X2 As Single, Y2 As Single
Dim New_X1 As Integer, New_Y1 As Integer
Dim New_X2 As Integer, New_Y2 As Integer
Dim Center_X As Single, Center_Y As Single
Dim Distance As Single
Dim Angle As Single
Distance = 20
Angle = 180
Center_X = ScaleWidth / 2
Center_Y = ScaleHeight / 2
X1 = 20
Y1 = 20
X2 = 0
Y2 = -Distance
New_X1 = Center_X + X1
New_Y1 = Center_Y + Y1
PSet (New_X1, New_Y1)
New_X2 = New_X1 + (X2 * Cos(Angle * PI / 180)) - (Y2 * Sin(Angle * PI / 180))
New_Y2 = New_Y1 + (X2 * Sin(Angle * PI / 180)) + (Y2 * Cos(Angle * PI / 180))
PSet (New_X2, New_Y2), RGB(0, 250, 255)
Form1.Caption = New_X2 & " " & New_Y2
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|