[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Free Graphic Tileset / Automatic Use of "Coast" Tiles



Greg Ewing wrote:
Kris Schnee wrote:
it strikes me that it would look nice, but shift the apparent terrain half a tile up and left

I think you need to incorporate that half-tile shift into your coordinate system, e.g. your internal map looks like

   0.0       1.0       2.0       3.0       4.0
0.0 +---------+---------+---------+---------+---------+
    |         |         |         |         |         |
    |  sand   |  sand   |  sand   |  water  |  water  |
    |         |         |         |         |         |
1.0 +---------+---------+---------+---------+---------+
    |         |         |         |         |         |
    |  sand   |  sand   |  sand   |  water  |  water  |
    |         |         |         |         |         |
2.0 +---------+---------+---------+---------+---------+
    |         |         |         |         |         |
    | water   |  water  |  water  |  water  |  water  |
    |         |         |         |         |         |
3.0 +---------+---------+---------+---------+---------+
    |         |         |         |         |         |
    | water   |  water  |  water  |  water  |  water  |
    |         |         |         |         |         |
4.0 +---------+---------+---------+---------+---------+


and your displayed tiles are

   0.0  0.5       1.5       2.5       3.5
0.0 +----+---------+---------+---------+---------+
    | s  |    s    |    s    | s    w  |    w    |
0.5 +----+---------+---------+---------+---------+
    |    |         |         |         |         |
    | s  |    s    |    s    | s    w  |    w    |
    |    |         |         |         |         |
1.5 +----+---------+---------+---------+---------+
    | s  |    s    |    s    | s    w  |         |
    |    |         |         |         |    w    |
    | w  |    w    |    w    | w    w  |         |
2.5 +----+---------+---------+---------+---------+
    |    |         |         |         |         |
    | w  |    w    |    w    |    w    |    w    |
    |    |         |         |         |         |
3.5 +----+---------+---------+---------+---------+

Thanks for this!

Rambling ahead. I started on the math for it and got a half-tile shift as planned.

The grid above assumes that (for instance) "sand" occupies the space between (1.0,1.0) and (2.0,2.0). My game's internal map has 1000x1000 data points that I'll presumably be procedurally generating or loading from an image file. What if I assumed that "sand" in slot (1.0,1.0) meant that there was sand at _that exact point_? (Picture it as shifting the words in the first grid above so they're on the intersections.) Then, the math might be a little simpler. Each tile would be drawn with its top-left corner at a whole number, like (1.0,1.0), with the choice of tile determined by what terrain is listed at points (1,1),(2,1),(1,2),(2,2). In this case it'd be ("sand","sand","water","water"), which I'd somehow look up in a big dictionary to get "sand fading south to water."

Looks like the Circle tileset includes only whole-tile, fade-to-north, fade-to-east, and fade-to-northeast corners as standard, with an irregular supply of concave pieces and not every possible combination of terrains. Probably the best way to handle the situation is to load them all in Pygame (which might take up a lot of memory) and fill in the gaps automatically using pygame.transform.

Kris
"Fading south to sea
The island shifts half a pace
Revealing smooth tiles."