20150520

Hex tiles

I compared regular square grids, hex grids and non-regular graphs, and I decided hex grids would be the best. I mean, it was good enough for other war games, so I kicked my perfectionism in the ass, and HOWAMIGONNAREFERENCETHETILES????

Seriously, how will I assign them coordinates?

Fortunately, I have ran across a very good site about hexagons. It tackles coordinates, rotation, field of view, pathfinding, converting between hex and pixels, etc. - all in hexagonal maps. So I looked and went with the 3-axial system, which seems to be really a 2-axial one with an additional and totally unnecessary third parameter which can be deduced from the other two.

Now, how should I generate the terrain? I figured out that it would be best if I just generated a six-sided map. This is just a placeholder anyway, I don't think it is time yet to work on a fully functional map generator. Also, this 6-sided map is easy to generate: I start from the middle, which will have the 0, 0, 0 coordinate, and then add rings until the requested radius is achieved.

Also, how do tiles look? Well, as good as my Inkscape skills let it so.


(One might wonder how I got these patches of same-type tiles. Easy: every tile, I got a random number, and if it was less then an initially set value, I created the same type tile that was created in the previous step. Not an elegant solution, but good enough for testing.)

Those little circles with the figures in it are also Inkscape "artworks" (really just programmert art, placeholders for some more enjoyable visuals). Also there are like 6 different types of terrain (some of them have identical behaviours, but a "shallow water" is more aesthetically pleasing than some dirt patch in the deep water), and all have three versions of it (except for the mountains, it has only one variation). Before I generate the tiles, I read all tile assets into memory, group them by name, and when I create a tile, I randomly assign a variation of that tile as its sprite.

Units consist of two sprites each: one for the type of unit (it is the black figurine and the black outline), and a team sprite (which is the colored circle).

I also drew a thick white hexagon outline to mark a tile that is selected. There is one for each tile, but only one has it enabled at a time. (At least I'm trying to enforce that through scripts.)

No comments:

Post a Comment