Jump to content
  • Advertisement
  • entries
  • comments
  • views

PFinding Demo

Sign in to follow this  


I got my pathfinding to an actual useable state so I decided I'd post a demo.

Controls first though:

Select unit: left click
Move: left click on an unoccupied tile
Quit: escape/click the x

Clicking on a spot while the entity is moving will cause it get stuck mid move. I actually had one run off screen somehow.
Linky (~770kb)(D3DX9_30.dll required)

Edit: I'd appreciate comments on whether or not it works, runs slow, etc. If it fails to run, It'd make things easier if you also post the contents of the log.html file. Thanks!

Now, it doesn't work perfect. A lot of the time it will search more nodes than it needs too and it won't always choose the best path, but I think I did pretty well for my first time without looking at any articles or code (well, I did a couple months ago.)

Also, I'm going to post my code. BUT, be warned. I did some things that I would never EVER do in an actual project. For example, my Entity class accesses my Map class data directly (which means my Map class data is in public.) There are a couple other things and I'm too lazy to point them all out. Why post it then? So that someone like me can get some use out of it. I would look at this code and throw up, but I'd still be able to get some positive use out of how things are being done, whilst ignoring the bad code. So, any of you beginner C++ programmers, DON'T download this, PLEASE. It'll just confuse you majorly.

PFinding_Src.zip (~20kb)

For those of you that don't love me enough to download it, you can check out the screenshots in my last entry.
Sign in to follow this  


Recommended Comments

Worked and ran nicely!

It does seem to search backwards at first though once you try to move more than 2 tiles away.

Share this comment

Link to comment
Thanks Tallitus! It's nice to know that it works on someone PC other than mine lol.

I seemed to have fix the searching backwards problem with my new algorithm. The problem was that tiles with the flipped values (column 4, row 8 and column 8, row 4) would recieve the same distance value and thus might be searched first.

Share this comment

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • 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!