Jump to content
  • Advertisement
Sign in to follow this  
The Hanged Man

SDL/pathfinding question

This topic is 2483 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello. I'm mostly a beginner in C++ (and in programming in general) and I've recently started to dabble in SDL. I'm working on a simple turn-based strategy game where you move units around with a mouse. So I've learned how to set tiles with this tutorial: http://lazyfoo.net/S...on29/index.php. Sadly, since I need to move units with only two clicks (one on the unit I want to move and one on his destination's tile), I've got a major problem: pathfinding.

IWDr5.png

From what I understand after reading some articles on the subject, the basic idea is that I want the game to check all the available tiles on the way from A to B, in order to get the shortest path. Can I actually do that at all? I mean, when I choose the unit I want to move, the tile under him won't "know" that it becomes the starting point for the pathfinding process.

I have a feeling that if I had a way to pinpoint a certain class instance (one of the six tiles, like in the screenshot) by only having some of the information about it (like the moving unit's coordinates, which would be the same as the starting point's) it would make this work, but at this point I don't know how to do it. If you guys could help me with this in any way, I would be really grateful. I realize that this may be way over my head at my level, but I still need to solve this problem no matter what.

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!