Is there a tutorial on how to make things move in a program using pathfinding?

  • Thread starter JamesU
  • Start date
  • Tags
    Tutorial
In summary: Here is a complete example:In summary, you need to understand vectors and coordinates of a computer screen in order to move something in a program. You need to understand text based games, 3D APIs, and how to move something in a program.
  • #1
JamesU
Gold Member
815
3
is completely confusing to me. I don't get how to make something move in a program. is there a good tutorial on this?
 
Technology news on Phys.org
  • #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 I am understanding your question.

im sorry if this is horribly patronising...
 
  • #3
well, I'm just trying to get something to move in C++ right now...
 
  • #4
define "something" and define "move"

are you attempting to move a file in the file system to another location from a C++ program?
 
  • #5
in stdio.h the rename() function performs an implicit mv command.

Is this what you want?
 
  • #6
I want it to be soething like a game. I want the object to move whe a certain key is pressed.
 
  • #7
yomamma said:
I want it to be soething like a game. I want the object to move whe a certain key is pressed.

so, you need to understand vectors and the coordinates of a computer screen (the top left of the screen is the origin.)
 
  • #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.
 
  • #9
yomamma said:
I want it to be soething like a game. I want the object to move whe a certain key is pressed.

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
http://www.gamedev.net/reference/list.asp?categoryid=28
or I am sure there are details on this site.
 
Last edited by a moderator:
  • #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 don't 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)..
 
  • #11
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.
 

1. What is pathfinding and why is it important?

Pathfinding is the process of finding the shortest or most efficient route between two points. It is important because it is used in a variety of fields, such as robotics, video games, transportation, and logistics, to plan and optimize routes and save time and resources.

2. What are some common algorithms used in pathfinding?

Some commonly used algorithms in pathfinding include Dijkstra's algorithm, A* algorithm, and breadth-first search. These algorithms use different techniques to find the shortest path between two points, such as exploring all possible paths or using heuristics to estimate the distance between points.

3. How does pathfinding relate to artificial intelligence?

Pathfinding is a crucial component in artificial intelligence because it allows machines to make decisions based on finding the most optimal route. This is useful in autonomous vehicles, game characters, and other AI applications where the ability to navigate efficiently is important.

4. What are some challenges in pathfinding?

One of the main challenges in pathfinding is dealing with complex and constantly changing environments. This requires algorithms to be adaptable and able to handle obstacles, dynamic terrain, and other unexpected conditions. Another challenge is finding a balance between efficiency and accuracy in determining the best path.

5. How can I learn more about pathfinding and its applications?

There are many online tutorials and resources available that provide in-depth information on pathfinding, including various algorithms, techniques, and implementations. You can also explore the code of existing pathfinding libraries or experiment with creating your own pathfinding algorithms to gain a better understanding of how it works.

Similar threads

  • Programming and Computer Science
Replies
5
Views
1K
  • Programming and Computer Science
Replies
2
Views
1K
  • Programming and Computer Science
Replies
9
Views
1K
  • Programming and Computer Science
Replies
1
Views
792
  • Programming and Computer Science
2
Replies
69
Views
4K
  • Sticky
  • Programming and Computer Science
Replies
13
Views
4K
Replies
40
Views
2K
  • Programming and Computer Science
Replies
1
Views
1K
  • Programming and Computer Science
Replies
8
Views
1K
  • Programming and Computer Science
Replies
1
Views
976
Back
Top