Re:OpenSC2K – An Open Source Remake of SimCity 2000
by samwestdev on Monday February 05, 2018 @12:12PM
(#16310215)
Thanks! How do you handle different terrain heights?
[ Parent
| on HN ]
Re:OpenSC2K – An Open Source Remake of SimCity 2000
by TapamN on Monday February 05, 2018 @03:12PM
(#16311672)
Terrain height just changes the Y position when where you draw. Draw order is still the same. The formula for tile map space to screen space is:
scrx = mapy16 - mapx16;
scry = mapx8 + mapy8 - GetSurfaceHeight(mapx,mapy)*12;
IIRC, this assumes origin is in top most tile, with increasing Y going down. So each step the terrain increases, you move the tile you draw up 12 pixels higher from the lowest point.