* @brief Render a row of tile * @param out Output buffer * @param tilePosition dPiece coordinates * @param targetBufferPosition Buffer coordinates * @param rows Number of rows * @param columns Tile in a row */
| 922 | * @param columns Tile in a row |
| 923 | */ |
| 924 | void DrawTileContent(const Surface &out, Point tilePosition, Point targetBufferPosition, int rows, int columns) |
| 925 | { |
| 926 | // Keep evaluating until MicroTiles can't affect screen |
| 927 | rows += MicroTileLen; |
| 928 | dRendered.reset(); |
| 929 | |
| 930 | for (int i = 0; i < rows; i++) { |
| 931 | for (int j = 0; j < columns; j++) { |
| 932 | if (InDungeonBounds(tilePosition)) { |
| 933 | #ifdef _DEBUG |
| 934 | DebugCoordsMap[tilePosition.x + tilePosition.y * MAXDUNX] = targetBufferPosition; |
| 935 | #endif |
| 936 | if (tilePosition.x + 1 < MAXDUNX && tilePosition.y - 1 >= 0 && targetBufferPosition.x + TILE_WIDTH <= gnScreenWidth) { |
| 937 | // Render objects behind walls first to prevent sprites, that are moving |
| 938 | // between tiles, from poking through the walls as they exceed the tile bounds. |
| 939 | // A proper fix for this would probably be to layout the sceen and render by |
| 940 | // sprite screen position rather than tile position. |
| 941 | if (IsWall(tilePosition) && (IsWall(tilePosition + Displacement { 1, 0 }) || (tilePosition.x > 0 && IsWall(tilePosition + Displacement { -1, 0 })))) { // Part of a wall aligned on the x-axis |
| 942 | if (IsTileNotSolid(tilePosition + Displacement { 1, -1 }) && IsTileNotSolid(tilePosition + Displacement { 0, -1 })) { // Has walkable area behind it |
| 943 | DrawDungeon(out, tilePosition + Direction::East, { targetBufferPosition.x + TILE_WIDTH, targetBufferPosition.y }); |
| 944 | } |
| 945 | } |
| 946 | } |
| 947 | DrawDungeon(out, tilePosition, targetBufferPosition); |
| 948 | } |
| 949 | tilePosition += Direction::East; |
| 950 | targetBufferPosition.x += TILE_WIDTH; |
| 951 | } |
| 952 | // Return to start of row |
| 953 | tilePosition += Displacement(Direction::West) * columns; |
| 954 | targetBufferPosition.x -= columns * TILE_WIDTH; |
| 955 | |
| 956 | // Jump to next row |
| 957 | targetBufferPosition.y += TILE_HEIGHT / 2; |
| 958 | if ((i & 1) != 0) { |
| 959 | tilePosition.x++; |
| 960 | columns--; |
| 961 | targetBufferPosition.x += TILE_WIDTH / 2; |
| 962 | } else { |
| 963 | tilePosition.y++; |
| 964 | columns++; |
| 965 | targetBufferPosition.x -= TILE_WIDTH / 2; |
| 966 | } |
| 967 | } |
| 968 | } |
| 969 | |
| 970 | /** |
| 971 | * @brief Scale up the top left part of the buffer 2x. |
no test coverage detected