This is my happy fun time implementation of the A* algorithm. The trollface uses it to chase the other guy around.
Click the cyan, yellow and magenta buttons and click/drag on the canvas to move the characters or to paint holes in the ground. Then start the scene.
Keep in mind that characters can move diagonally.
ChangeLog:
26-10:\> Set up the canvas, the grid and the interface.
26-10:\> Set up the functionality of customizing the scene before the chase.
27-10:\> Implemented the finite state machine reactions of the target.
28-10:\> Added visuals for character radar, trail and possible steps. Helps a lot with debugging, and it looks neat.
28-10:\> Added options to tweak the Target: patrol, trail, radar range.
These can be changed dynamically during the chase.
29-10:\> Set up some helper functions for A* and some visual assets.
30-10:\> Started working on A*.
1-11:\> Sick :C
2-11:\> Sick :C
3-11:\> Sick :C
3-11:\> Finished A*.
4-11:\> Allowed Target to randomly patrol while Chaser looks for it.
4-11:\> Just discovered that JQuery's .animate works for any variable not just CSS.
Which means: added MOTION TWEENS ALL AROUND! :D
All done.
Note: you'll find more information if you open a
javascript console while running this.