Camera and Tilemaps fixed at 1x res
This commit is contained in:
parent
9f4007bb79
commit
fb20b8d868
Binary file not shown.
@ -34,7 +34,7 @@ public:
|
|||||||
// std::tuple <int,int> oPosition;
|
// std::tuple <int,int> oPosition;
|
||||||
std::vector<std::tuple<int,int>> initialPositions;
|
std::vector<std::tuple<int,int>> initialPositions;
|
||||||
// std::array destRects;
|
// std::array destRects;
|
||||||
int totalTiles;
|
int tileSetTotal;
|
||||||
|
|
||||||
TileMapComponent() = default;
|
TileMapComponent() = default;
|
||||||
|
|
||||||
@ -51,9 +51,9 @@ public:
|
|||||||
setTex(map.tilesetCollection[0].name);
|
setTex(map.tilesetCollection[0].name);
|
||||||
globalScale = gScale;
|
globalScale = gScale;
|
||||||
// =========== Setup Tile Set ===========
|
// =========== Setup Tile Set ===========
|
||||||
totalTiles = map.tilesetCollection[0].colCount*map.tilesetCollection[0].rowCount;
|
tileSetTotal = map.tilesetCollection[0].colCount*map.tilesetCollection[0].rowCount;
|
||||||
// std::cout << "Number of Tiles: " << totalTiles << std::endl;
|
// std::cout << "Number of Tiles: " << tileSetTotal << std::endl;
|
||||||
tileSet.resize(totalTiles);
|
tileSet.resize(tileSetTotal);
|
||||||
|
|
||||||
for (int r=0;r<map.tilesetCollection[0].rowCount;r++){
|
for (int r=0;r<map.tilesetCollection[0].rowCount;r++){
|
||||||
for (int c=0;c<map.tilesetCollection[0].colCount;c++){
|
for (int c=0;c<map.tilesetCollection[0].colCount;c++){
|
||||||
@ -74,11 +74,13 @@ public:
|
|||||||
for (int c = 0;c<map.width;c++){
|
for (int c = 0;c<map.width;c++){
|
||||||
int elem = c+r*map.width;
|
int elem = c+r*map.width;
|
||||||
SDL_Rect thisRect = SDL_Rect();
|
SDL_Rect thisRect = SDL_Rect();
|
||||||
thisRect.x = c*map.tilesetCollection[0].tileWidth*globalScale-offsetX*globalScale;
|
thisRect.x = c*map.tilesetCollection[0].tileWidth*globalScale;
|
||||||
thisRect.y = r*map.tilesetCollection[0].tileWidth*globalScale-offsetY*globalScale;
|
thisRect.y = r*map.tilesetCollection[0].tileWidth*globalScale;
|
||||||
thisRect.w = thisRect.h = map.tileWidth * globalScale;
|
thisRect.w = thisRect.h = map.tileWidth * globalScale;
|
||||||
std::tuple<int,int> ogPos = std::make_tuple(thisRect.x,thisRect.y);
|
std::tuple<int,int> ogPos = std::make_tuple(thisRect.x,thisRect.y);
|
||||||
initialPositions[elem] = ogPos;
|
initialPositions[elem] = ogPos;
|
||||||
|
thisRect.x = thisRect.x-offsetX*globalScale;
|
||||||
|
thisRect.y = thisRect.y-offsetY*globalScale;
|
||||||
destRects[elem] = thisRect;
|
destRects[elem] = thisRect;
|
||||||
// std::cout << "destRects[" << elem << "].x = " << destRects[elem].x << "].y = " << destRects[elem].y << "].w = " << destRects[elem].w << std::endl;
|
// std::cout << "destRects[" << elem << "].x = " << destRects[elem].x << "].y = " << destRects[elem].y << "].w = " << destRects[elem].w << std::endl;
|
||||||
}
|
}
|
||||||
|
@ -341,14 +341,14 @@ void Game::update()
|
|||||||
pVel.x = player.getComponent<TransformComponent>().velocity.x;
|
pVel.x = player.getComponent<TransformComponent>().velocity.x;
|
||||||
pVel.y = player.getComponent<TransformComponent>().velocity.y;
|
pVel.y = player.getComponent<TransformComponent>().velocity.y;
|
||||||
|
|
||||||
// if(camera.x < 0)
|
if(camera.x < 0)
|
||||||
// camera.x = 0;
|
camera.x = 0;
|
||||||
// if (camera.y < 0)
|
if (camera.y < 0)
|
||||||
// camera.y = 0;
|
camera.y = 0;
|
||||||
// if (camera.x > levelMap.w-camera.w*1.5-player.getComponent<TransformComponent>().width)
|
if (camera.x > levelMap.w-camera.w)
|
||||||
// camera.x = levelMap.w-camera.w*1.5-player.getComponent<TransformComponent>().width;
|
camera.x = levelMap.w-camera.w;
|
||||||
// if (camera.y > levelMap.h-camera.h*1.5-player.getComponent<TransformComponent>().height)
|
if (camera.y > levelMap.h-camera.h)
|
||||||
// camera.y = levelMap.h-camera.h*1.5-player.getComponent<TransformComponent>().height;
|
camera.y = levelMap.h-camera.h;
|
||||||
if (Game::debugCollisionBoxes)
|
if (Game::debugCollisionBoxes)
|
||||||
{
|
{
|
||||||
for (auto& c: colliders)
|
for (auto& c: colliders)
|
||||||
|
Loading…
Reference in New Issue
Block a user