Wednesday, March 19, 2014

3D, non-cubic map generator

I'm going to split this post up into multiple, because ... yeah.  There you go.

On the medieval combat game I've been posting about (currently aptly named "I Gave Idiots Swords", or IGIS for brevity), map generation has been furiously attacked and eviscerated quite effectively.  I mean, not really, but ...  *sigh*  Observe.




Using some 3D trig and random floats, the map generates a random (between 1 and however many ya might want; for now the threshold is at about 7) number of towers around a central tower, with random distances kept within reasonable ranges and random height displacement, within reasonable ranges.  These are then linked with bridges.  The entire process runs in two scripts, about 20 and 110 lines long, and can be easily adjusted to adapt tower radius, tower height, bridge length, platform offsets, distance between towers, etc.  The bridges, bridge terminals, and towers themselves are all standard meshes-- hence, the use of the second 20-line script, which adjusts bridge length to prevent protrusion through platform bases, etc.  More is to be added, like tunnels, scene props, etc.  Obviously it's not much of a castle, but it's fun, and frankly that's what it needs to be.

Originally the script was recursive, based on an integer property "iteration", and would branch the towers out into a deranged mess.  For now, that feature's been disabled, until I become competent enough to actually do anything about its ensuing chaos.

Pathfinding is in the works, as since the map is random Blender's standard navmesh system is no longer applicable.  This is gonna take a while.  Anyway, the navmesh approach to be attempted (in vain) will probably be THIS:
http://www.policyalmanac.org/games/aStarTutorial.htm
The A* approach!  This shouldn't be too difficult, but knowing Blender's aptitude for making my life miserable, I repeat:  this is gonna take a while.

No comments:

Post a Comment