MCPcopy Create free account
hub / github.com/diasurgical/DevilutionX / CalcFirstTilePosition

Function CalcFirstTilePosition

Source/engine/render/scrollrt.cpp:1030–1073  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1028int tileRows;
1029
1030void CalcFirstTilePosition(Point &position, Displacement &offset)
1031{
1032 // Adjust by player offset and tile grid alignment
1033 Player &myPlayer = *MyPlayer;
1034 offset = tileOffset;
1035 if (myPlayer.isWalking())
1036 offset += GetOffsetForWalking(myPlayer.AnimInfo, myPlayer._pdir, true);
1037
1038 position += tileShift;
1039
1040 // Skip rendering parts covered by the panels
1041 if (CanPanelsCoverView() && (IsLeftPanelOpen() || IsRightPanelOpen())) {
1042 int multiplier = (*sgOptions.Graphics.zoom) ? 1 : 2;
1043 position += Displacement(Direction::East) * multiplier;
1044 offset.deltaX += -TILE_WIDTH * multiplier / 2 / 2;
1045
1046 if (IsLeftPanelOpen() && !*sgOptions.Graphics.zoom) {
1047 offset.deltaX += SidePanelSize.width;
1048 // SidePanelSize.width accounted for in Zoom()
1049 }
1050 }
1051
1052 // Draw areas moving in and out of the screen
1053 if (myPlayer.isWalking()) {
1054 switch (myPlayer._pdir) {
1055 case Direction::North:
1056 case Direction::NorthEast:
1057 offset.deltaY -= TILE_HEIGHT;
1058 position += Direction::North;
1059 break;
1060 case Direction::SouthWest:
1061 case Direction::West:
1062 offset.deltaX -= TILE_WIDTH;
1063 position += Direction::West;
1064 break;
1065 case Direction::NorthWest:
1066 offset.deltaX -= TILE_WIDTH / 2;
1067 offset.deltaY -= TILE_HEIGHT / 2;
1068 position += Direction::NorthWest;
1069 default:
1070 break;
1071 }
1072 }
1073}
1074
1075/**
1076 * @brief Configure render and process screen rows

Callers 1

DrawViewFunction · 0.85

Calls 5

GetOffsetForWalkingFunction · 0.85
CanPanelsCoverViewFunction · 0.85
IsLeftPanelOpenFunction · 0.85
IsRightPanelOpenFunction · 0.85
isWalkingMethod · 0.45

Tested by

no test coverage detected