Thanks Chillcore, I was headed to dev.openttdcoop...
Eddi wrote: ↑27 Sep 2022 19:58
no, those are map coordinates, not screen coordinates.
each tile is divided into 16 steps in X and Y directions, and 8 steps in Z direction (if sloped)
on default zoom, each Z step is 1 pixel up. and each X/Y step is 2 pixels left/right and 1 pixel down.
I'm a bit confused (maybe a vocabulary issue), I'll try to write what's coming to my mind. I was thinking, since it's a 2D game, that there was no polygons, no texture mapping. Simply sprites that we draw at specified coordinates on the buffer, and that the elevation was simply an vertical offset when drawing a sprite supposed to be at a higher level. From what I've seen in the code, each tile of the world stores the height level of its "south" corner (between 1 and MAX_TILE_HEIGHT), so initially I though this height level would simply be the offset to use when drawing.
I took a screenshot and did some pixel counting:
- Sans titre.png (55.94 KiB) Viewed 5552 times
At default zoom:
- the white lines are 16 pixels wide, which make a tile 32 pixels wide, matching TILE_PIXELS.
- The blue and yellow lines are 8 pixels high, making a tile 16 pixels high
So I figure that the ratio used to give perspective is 2 to 1.
- The pink part is 4 pixels high, that's the extra height due to the slope.
This comment :
Code: Select all
///< Height of a height level in world coordinate AND in pixels in #ZOOM_LVL_BASE.
make me think that height in world and pixels is the same at default zoom level, which seems to be the case as the Z offset used to draw fences is tile->z plus the result of GetSlopePixelZInCorner, which returns either 0 or 1 times TILE_HEIGHT.
So, given the ratio perspective of 2 to 1, those 4 pink pixels would match the TILE_HEIGHT.
- there are 8 steps (2 px left and 1 px up ) red steps in a tile side. I'm trying to link this to your explanation about X/Y step, is that it ?
So did I understood correctly your comments if I say that the "physic" engine uses TILE_SIZE to compute positions of moving objects inside a tile. As you mentionned the tile is split in 16 parts, that would make the smallest movement (along the edge of a tile, that's what you call X/Y ?) 2 pixels horizontally (32/16) and 1 pixel vertically ((32/16)/2) ?