Results 1 to 9 of 9

Thread: Following Path

  1. #1

    Thread Starter
    Fanatic Member gwdash's Avatar
    Join Date
    Aug 2000
    Location
    Minnesota
    Posts
    666

    Post

    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]

  2. #2
    Hyperactive Member
    Join Date
    Jun 2000
    Location
    Auckland, NZ
    Posts
    411

    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
    Paul Lewis

  3. #3

    Thread Starter
    Fanatic Member gwdash's Avatar
    Join Date
    Aug 2000
    Location
    Minnesota
    Posts
    666
    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]

  4. #4
    Hyperactive Member
    Join Date
    Jun 2000
    Location
    Auckland, NZ
    Posts
    411

    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?

    Paul Lewis

  5. #5

    Thread Starter
    Fanatic Member gwdash's Avatar
    Join Date
    Aug 2000
    Location
    Minnesota
    Posts
    666
    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]

  6. #6
    Hyperactive Member
    Join Date
    Jun 2000
    Location
    Auckland, NZ
    Posts
    411

    What's your email?

    It's not on your profile and the code is longer than is reasonable to post.

    Regards
    Paul Lewis

  7. #7

    Thread Starter
    Fanatic Member gwdash's Avatar
    Join Date
    Aug 2000
    Location
    Minnesota
    Posts
    666
    GWDASH
    [b]VB6, Perl, ASP, HTML, JavaScript, VBScript, SQL, C, C++, Linux , Java, PHP, MySQL, XML[b]

  8. #8
    Hyperactive Member
    Join Date
    Jun 2000
    Location
    Auckland, NZ
    Posts
    411

    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



    Paul Lewis

  9. #9
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    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
  •  



Click Here to Expand Forum to Full Width