mhwombat / grid

Tools for working with regular grids/graphs/lattices.
Other
106 stars 12 forks source link

Rectangular, wrap-around grids #2

Closed listx closed 11 years ago

listx commented 11 years ago

Currently, only the square tiles support a rectangular grid with the rectSquareGrid function. I think it would be nice to have a similar function for both the tri and hex tiles. The right and left edges would be jagged, but, they could be made so that they wrap around and fit together, e.g. like in the game Civilization III.

mhwombat commented 11 years ago

That's a great idea. I'll try to include that in the next version.

On 2 March 2013 02:38, Linus notifications@github.com wrote:

Currently, only the square tiles support a rectangular grid with the rectSquareGrid function. I think it would be nice to have a similar function for both the tri and hex tiles. The right and left edges would be jagged, but, they could be made so that they wrap around and fit together, e.g. like in the game Civilization III.

— Reply to this email directly or view it on GitHubhttps://github.com/mhwombat/grid/issues/2 .

mhwombat commented 11 years ago

I implemented this in v4.0 but forgot to close the issue.

listx commented 11 years ago

Hmm, it is unclear to me if the functionality is really there. Essentially, what I originally requested was something like a rectHexGrid layout, but where the left edge is connected to the right edge of the grid. Thus, the leftmost tile is actually only 1 tile away from the rightmost tile (that would be the calculation from distance). This could be implemented (somewhat easily? I hope?) for both the rectSquareGrid and rectTriGrid types because they already exist. If it were me, I would prioritize the rectHexGrid one just because I want to play around with it as part of my game project.

The unbounded grids just give infinite grids, if that is what you are thinking about.

listx commented 11 years ago

Hmm, maybe it would be easier to just start out with a cylSquareGrid, which is just like torSquareGrid but is a cylindrical shape, not a torus. (The blue area of the cylinder at http://en.wikipedia.org/wiki/File:Circular_cylinder_rh.svg )

And then you could add cylHexGrid and cylTriGrid...

mhwombat commented 11 years ago

Oh, sorry, I misunderstood. I thought you wanted the grid to wrap around top and bottom as well as on the sides, so I developed torTriGrid. (I've never played Civilisation.) But it won't be difficult for me to do a cylindrical version.

mhwombat commented 11 years ago

Can you take a look at this diagram and verify that this is what you're looking for?

cyltrigrid

listx commented 11 years ago

Yes, your version of cylTriGrid looks great! (By the way, how did you generate the image?)

Here are my interpretations of the other cylindrical grids:

cylHex1 cylHex1 cylHex2 cylHex2 cylSquare1 cylSquare1 cylSquare2 cylSquare2

There are 2 versions for the hex and square grid types because you can arrange them differently and still wrap them around. In case you are curious, cylSquare2 was used in the game Civilization 3, while Civilization 4 used cylSquare1. Civilzation 5 used cylHex2.

mhwombat commented 11 years ago

Added. See yCylTriGrid.