|
-
Sep 14th, 2000, 05:01 PM
#1
Thread Starter
Fanatic Member
Does any one have an algorithim to make a sprite follow a path (a network) by knowing the nodes.
i.e. if i give the coords (140,60), etc. can the algorithim, make a sprite follow the path between the points. Also, how do i rotate a sprite in DirectDraw(Is BltFx the only way, and can it rotate at angles, or just flip)
GWDASH
[b]VB6, Perl, ASP, HTML, JavaScript, VBScript, SQL, C, C++, Linux , Java, PHP, MySQL, XML[b]
-
Sep 14th, 2000, 05:07 PM
#2
Hyperactive Member
Vector arithmetic
I'm no graphics expert nor a games programmer however it occurs to me that you need to use simple trig or vector arithmetic to do this.
Other considerations are whether the sprite must always face a certain direction or if it's "node" is always facing the direction of travel.
If the latter, then you need to do a little more than follow the path because at each change in gradient you need to adjust the sprite direction. If all the paths are straight lines then this is easily done at each vertex.
If nobody gives you exactly what you need, I can help with the vector or trig side of things as Mathematics is a hobby 
Cheers
Paul Lewis
-
Sep 14th, 2000, 05:08 PM
#3
Thread Starter
Fanatic Member
it's the later, the sprite needs to rotate at each vertex.
GWDASH
[b]VB6, Perl, ASP, HTML, JavaScript, VBScript, SQL, C, C++, Linux , Java, PHP, MySQL, XML[b]
-
Sep 14th, 2000, 07:48 PM
#4
Hyperactive Member
Well, no other replies
How about if I write some simple code that will allow the traversal of a path made up of arbitary points returning at each vertex the new angle of rotation required and the distance to the new target?
I will make a gui that allows you to click a few points to generate your path, then press a button to "watch" as the path is traversed. All it will be missing is the sprites that you will add in.
Sound ok to you?
-
Sep 14th, 2000, 09:18 PM
#5
Thread Starter
Fanatic Member
go for it. Thats exactly what i want!!!
GWDASH
[b]VB6, Perl, ASP, HTML, JavaScript, VBScript, SQL, C, C++, Linux , Java, PHP, MySQL, XML[b]
-
Sep 14th, 2000, 10:07 PM
#6
Hyperactive Member
What's your email?
It's not on your profile and the code is longer than is reasonable to post.
Regards
-
Sep 14th, 2000, 10:08 PM
#7
Thread Starter
Fanatic Member
GWDASH
[b]VB6, Perl, ASP, HTML, JavaScript, VBScript, SQL, C, C++, Linux , Java, PHP, MySQL, XML[b]
-
Sep 14th, 2000, 10:18 PM
#8
Hyperactive Member
What I have to send to you
It's actually a modified version of a project I did for another topic on this forum.
I actually posted the previous version to someone else on here just earlier today. This version does the following:
Allows you to plot a series of points for a path to traverse (the code closes the path to make a polygon as that is what it was originally designed to do.
Allows you to generate a pseudo-random polygon of n sides.
Allows you to Save / Load the series of points in your path to disk.
Allows you to click on the picturebox and start the traversal of the path. As the path is traversed if in the default "debug mode" an info box appears giving details of distance and angle (in degrees) to reach the next point.
Once the path has been traversed, the program will indicate if the point you specified is either inside the shape, outside the shape or on the edge of the shape.
When the settings are set to enable crosshair, enable on move, disable all debug info, the program will indicate whether the mouse is inside, outside or on the edge in real time.
The project isn't pretty as far as naming conventions etc go, but it should be relatively bug free.
I thing the maths in the pclPolygon and pclPoint classes will be what you are most interested in.
Good luck. When you let me know your email address I will zip it up and send it to you.
Regards
-
Sep 15th, 2000, 07:06 AM
#9
transcendental analytic
For your other problem with DirectDraw, i think you can flip with blt (i'm not sure but if it works with paintpicture then why not with blt? I don't have vb on this comp so i can't test but you could try) What you do is giving the rect.top value a larger value than rect.bottom, so you invert the positions, and to mirror you invert the left and right values. Good luck!
I'm sure there is a way to rotate too but i think it's slow, i'll check it out when i have time.
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
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
|