I have this pathfinder and I got it to work using c++... now i am trying to convert it to OpenGL and it is not working.
I wrote code to use a mouse to plot the start and destination points. but it won't work properly.
I have attatched the file to this thread.
Could someone help me?

Thanks,
Brian

Recommended Answers

All 2 Replies

I managed to get your code to compile and run, but I had to kill it after clicking twice. After looking at your code I noticed that you were trying to draw in the glut mouse function, that's a bad idea. There is a reason why you have a draw function, and there is a reason why you have a mouse function, don't mix the two up. Also, it seems to be getting caught in this infinite loop for me:

while(!yet){
                       xs=x;     // x start = x
                       ys=y;     // y start = y

                       set8(xs,ys,xd,yd);
                       //paintgh();

                      }//while

What? I'm sorry, but you really need to clean up the code and give some informative comments as to what you're doing in each function if you want anyone to understand this and to help you.

-Fredric

Well .... here I go.. this will be hard to describe so bare with me...

variables:
xs is x start position
ys is y start position
xd is x destination position
yd is y destination position
yet is a flag to stop the while loop
struct s is the node structure

functions:
- set8 function takes the xs,ys,xd,yd it find the g distance (distance from node to start position) and h distance (manhattan distance).
- md function finds the manhattan distance
- set_back function finds the last visited node
- paintgh function should print the start position, destination position and the line that connects to every visited node. // I need help on this one.

Number meanings:
-2: represents the destination node
-1: represents the start node
0: represents a null node
1: represents a node // no need to worry about output for this one
2: represents the path node
3: represents the barrier node


What I want to do is:
-Click once to create start node.
-Click a second time to create the destination node.
-After all of this, the set8 function should work and help find the path from the start node to the desitination node.
-The paintgh function should then step in and paint the graphics from the start node to the destination node.

I have made the code so that anyone can add a barrier. The code should find its way arround the barrier. Its really cool when I ran it with out Opengl.

If there are any more question please email me at brian63304@hotmail.com.

Thank you
Brian

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.