Browse Source

Introduce GetScreenPosition

pull/6458/head
obligaron 3 years ago committed by Anders Jenbo
parent
commit
d5642daeb4
  1. 14
      Source/engine/render/scrollrt.cpp
  2. 6
      Source/engine/render/scrollrt.h

14
Source/engine/render/scrollrt.cpp

@ -1510,6 +1510,20 @@ void CalcViewportGeometry()
tileColums = (screenWidth - renderStart.x + TILE_WIDTH - 1) / TILE_WIDTH;
}
Point GetScreenPosition(Point tile)
{
Point firstTile = ViewPosition;
Displacement offset = {};
CalcFirstTilePosition(firstTile, offset);
Displacement delta = firstTile - tile;
Point position {};
position += delta.worldToScreen();
position += offset;
return position;
}
extern SDL_Surface *PalSurface;
void ClearScreenBuffer()

6
Source/engine/render/scrollrt.h

@ -60,6 +60,12 @@ void CalcTileOffset(int *offsetX, int *offsetY);
void TilesInView(int *columns, int *rows);
void CalcViewportGeometry();
/**
* @brief Calculate the screen position of a given tile
* @param tile Position of a dungeon tile
*/
Point GetScreenPosition(Point tile);
/**
* @brief Render the whole screen black
*/

Loading…
Cancel
Save