[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] Free Graphic Tileset / Automatic Use of "Coast" Tiles
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 +----+---------+---------+---------+---------+
> In the
water-to-sand example, the southmost water tiles would become "water
fading southward to sand," sure, but then the sand tiles just south of
that would become "sand fading northward to water," creating messed-up
tidal pools.
It works if you decide which tile to use based on the four
map cells that it overlaps, taking the half-tile offset into
account. E.g. in the above, the tile whose centre is at
(2.0, 2.0) overlaps sand to the north and water to the
south, so it's a sand-fading-to-water-southward tile,
whereas the one to the north is pure sand, and the one
to the south is pure water.
Another way to think about it is that you're rendering the
map not by drawing a tile for each map cell, but by
drawing a tile for each corner between map cells, with
the tile selected by interpolating between the four map
cells which share that corner.
--
Greg