Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Tutorial on pathfinding

  1. Oct 10, 2005 #1


    User Avatar
    Gold Member

    is completely confusing to me. I don't get how to make something move in a program. is there a good tutorial on this?
  2. jcsd
  3. Oct 11, 2005 #2
    that questions a bit vague...can you be more specific?

    can you go into more detail about what you're doing (2d/3d? grid/coodrinate based? c/c++/java?)

    obviously pathfinding is about moving something from A to B. if this is a grid based system then its a lot easier, especially in 2d. the only tutorial i could link you to is here, although it covers A* pathfinding and may be a bit excessive for what you want to know, if im understanding your question.

    im sorry if this is horribly patronising...
  4. Oct 11, 2005 #3


    User Avatar
    Gold Member

    well, I'm just trying to get something to move in C++ right now...
  5. Oct 11, 2005 #4
    define "something" and define "move"

    are you attempting to move a file in the file system to another location from a C++ program?
  6. Oct 11, 2005 #5

    jim mcnamara

    User Avatar
    Science Advisor
    Gold Member

    in stdio.h the rename() function performs an implicit mv command.

    Is this what you want?
  7. Oct 13, 2005 #6


    User Avatar
    Gold Member

    I want it to be soething like a game. I want the object to move whe a certain key is pressed.
  8. Oct 13, 2005 #7
    so, you need to understand vectors and the coordinates of a computer screen (the top left of the screen is the origin.)
  9. Oct 13, 2005 #8
    first off are you doing text grid games, 3D APIs like openGL or directx or SDL(which uses either). That probably the first question you shouhld be answering.
  10. Oct 14, 2005 #9
    it seems from your question that your not sure how to do it in maths, so this should be your first port of call. have a look at this link
    or im sure there are details on this site.
  11. Oct 15, 2005 #10
    ah..how to explain this...i wrote out quite a long reply with example code but its quite redundant to do this if i dont understand what you want. ie is this text based? is it from scratch or do you have a library to work from (such as ncurses or one of the lamothe ones)?

    usually you have a grid, and accept user input to move left/right/up/down (im asuming you're working in 2d)..
  12. Dec 3, 2005 #11


    User Avatar
    Gold Member

    To move something you just have to change its position by small amount for a certain amount of times. If you are working with ascii then you can put the cursor in a certain position with the command:
    gotoxy(int x,int y);
    after using this command, whatever you output will by on that (x,y) position of the screen. To make something move just change it's (x,y) values one step at a time.
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?

Similar Discussions: Tutorial on pathfinding
  1. Python Tutorial (Replies: 8)

  2. FORTRAN Tutorial (Replies: 24)

  3. C# Tutorial (Replies: 13)

  4. Programming Tutorials (Replies: 2)