Graphics Adventure type movement

BlitzMax Forums/BlitzMax Programming/Graphics Adventure type movement

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

No actual code here, but just some ramblings: one thing to consider as well, is how to handle movement to a location that is NOT walkable.

A number of years ago I wrote some code for a point-and-click style adventure movement, and this is how I approached it:

- Create a low-resolution array as an overlay for the screen -- e.g. for a 640x480 screen, I had a 160x120 array, with each slot representing a 4x4 pixel chunk.
- I filled the array with either true or false for each 4x4 block, indicating whether or not the portion was awalkable. (Through a very basic editor where I could 'paint' the walking map on top of the actual background picture, and interprete the results to populate the array)
- Then use one of the A* pathfinding tools to actually plot the path.

- Determine if there is a path from A to B.
- If Yes: Start your walking routines, and traverse the path
- If No: envision a straight line from point A to point B. In ~32 pixel increments or so, traverse that line backwards from point B towards point A and try to find a path. Sooner or later you'll find a spot that's still reachable. At that point you can use use that as your destination: You can walk from point A to this spot, and stop there.
- Optionally, make a comment about how the spot you're trying to get to is out of reach.

As far as the overlay array, it's a bit of a trade-off: The larger the array is, the more precise your morements can be -- but the smaller it is, the less time is needed to calculate a walkable path. Try to find some middle ground there.

Certain evens (e.g. raising or lowering a drawbridge) would affect a portion of the map and by performing the action you can flip that portion of the walking array from true to false or vice-versa.
One advantage of a system like this v.s. using absolute waypoints is that you can walk 'anywhere' on the map.

And if you already have an array representing the entire screen, you can also use it to store other info, like adding a dimension to represent a scaling factor -- in certain screens representing large landscapes you may want to draw your character much smaller in the background than when he's right in the foreground.

You can also use a dimension to define 'trigger' spots, e.g. walking on a certain location may cause something else to happen.