• entries
707
1173
• views
436294

# PFinding Demo

115 views

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

Controls first though:
Select unit: left clickMove: left click on an unoccupied tileQuit: 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.

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.

Worked and ran nicely!

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

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.

## Create an account

Register a new account