I ported this little pathfinding/game type demo.
It originally was 100% in dutch, including variables and comments. Its 100% in english now.
It was also not in standard Java.
I have fixed most, but not all the bugs.
There were other misc changes I have made since the original.
Summary:
There are these knights that go out and find the random gold(random each time you load) and return it back to the castle.
There is no real “game” to it right now, its more of a learning/shared code type of thing.
Features, things to look at:
Java2D
Random tile variation(take notice of the grass, the slight variation in color makes it look good)
All graphics are made on the fly in game…no reference “image files”
The encapsulation of how they handle the graphics for different elements.
A different approach to path finding ( not better, but different, then typical types )
-Take note of “why” the knights get jammed about 15% of the time, its quite obvious if you see them get stuck and admire the pathfinding correction.
(They only have the foresight of a couple of tiles and don’t know how well enough how to navigate around things, There needs to be either a “return home and try again” or “randomization” of where to go, given the limitations of the current pathfinding. Ideally youd want a different system all together though
Incorporates multiple useful elements,
–logging feature(disabled by default)(minor logging is enabled)
–swing buttons
–game window
The pathfinding uses a step pathfinding, and I wouldn’t recommend looking too much at it, because its really finicky, and you should be using A* pathfinding anyways. The knights sometimes get stuck, I’ve fixed a lot of their jams, but they still get jammed sometimes, especially if you add more knights.
Pictures:
http://code.newrog.com/sites/default/files/1kc.png
http://code.newrog.com/sites/default/files/2kc.png
Demo:
http://code.newrog.com/sites/default/files/goldHunters.jar
http://code.newrog.com/sites/default/files/goldHunters-small.jar (smaller window)
Source:
http://code.newrog.com/sites/default/files/goldhunters.rar