TileMaps and cam debug added
This commit is contained in:
parent
c8aae59f26
commit
2331110c71
Binary file not shown.
@ -90,10 +90,13 @@ public:
|
||||
|
||||
void update() override
|
||||
{
|
||||
if (Game::gsm->currentState == GameStateManager::ST_COREGAME){
|
||||
for (int i=0;i<destRects.size()-1;i++){
|
||||
// SDL_Rect thisRect = destRects[i];
|
||||
destRects[i].x = destRects[i].x - Game::camera.x;
|
||||
destRects[i].y = destRects[i].y - Game::camera.y;
|
||||
if (Game::camera.x >= 352)
|
||||
destRects[i].x = destRects[i].x - Game::camera.x*0.01f;
|
||||
if (Game::camera.y >= 432)
|
||||
destRects[i].y = destRects[i].y - Game::camera.y*0.01f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -51,6 +51,8 @@ auto& puppy(manager.addEntity());
|
||||
// auto& scoreboard(manager.addEntity());
|
||||
auto& uiInfo(manager.addEntity());
|
||||
auto& uiJumpInfo(manager.addEntity());
|
||||
auto& uiCamXInfo(manager.addEntity());
|
||||
auto& uiCamYInfo(manager.addEntity());
|
||||
auto& uiTextInstructions(manager.addEntity());
|
||||
|
||||
auto& gameScene(manager.addEntity());
|
||||
@ -133,26 +135,13 @@ void Game::init(const char *title, int width, int height, bool fullscreen, int g
|
||||
levelMap.y = 0;
|
||||
levelMap.w = map.width*map.tileWidth*gScale;
|
||||
levelMap.h = map.height*map.tileHeight*gScale;
|
||||
// std::cout << "Map Width Tiles: " << map.width << std::endl;
|
||||
//iterate through rows and columns of the map to draw the tiles
|
||||
// // First cycle through rows
|
||||
// for (int r = 0;r<map.height;r++){
|
||||
// // Next cycle through each column or tile in that row:
|
||||
// for (int c = 0;c<map.width;c++){
|
||||
// int tileToDraw = map.layerCollection[0].tiles[r*map.width+c].gid;
|
||||
// std::cout << tileToDraw << ",";
|
||||
// }
|
||||
// std::cout << std::endl;
|
||||
// }
|
||||
// std::cout << map.height;
|
||||
// std::cout << "Map width: " << map.width << " tiles wide by: " << map.height << " tiles high" << std::endl;
|
||||
// for (int t = 0;t<map.width;t++){
|
||||
// std::cout << layer.tiles[t].gid << std::endl;
|
||||
// }
|
||||
// std::cout << "Map Width Tiles: " << map.width << " Map Tile Width: " << map.tileWidth <<std::endl;
|
||||
} else {
|
||||
std::cout << "Encountered error loading map file: " << error << std::endl;
|
||||
}
|
||||
|
||||
// std::cout << "levelMap.w - camera.w: " << levelMap.w-camera.w << std::endl;
|
||||
|
||||
assets->AddTexture("player", "assets/textures/actors/firefighter.png");
|
||||
assets->AddTexture("font", "assets/textures/ui/ui-font-cloud-sans.png");
|
||||
assets->AddTexture("textBox", "assets/textures/ui/ui-element-cloud.png");
|
||||
@ -190,6 +179,14 @@ void Game::init(const char *title, int width, int height, bool fullscreen, int g
|
||||
uiInfo.addComponent<UITextComponent>("font", "Camera CamX: CamY: Jump: P.y : P.dy: YVec: ", 8, 12, 1);
|
||||
uiInfo.addGroup(groupUI_Layer3);
|
||||
|
||||
uiCamXInfo.addComponent<TransformComponent>(camera.w-48,24,40,12,gScale);
|
||||
uiCamXInfo.addComponent<UITextComponent>("font", "nan", 8, 12, 1);
|
||||
uiCamXInfo.addGroup(groupUI_Layer3);
|
||||
|
||||
uiCamYInfo.addComponent<TransformComponent>(camera.w-48,36,40,12,gScale);
|
||||
uiCamYInfo.addComponent<UITextComponent>("font", "nan", 8, 12, 1);
|
||||
uiCamYInfo.addGroup(groupUI_Layer3);
|
||||
|
||||
uiJumpInfo.addComponent<TransformComponent>(camera.w-48,48,40,12,gScale);
|
||||
uiJumpInfo.addComponent<UITextComponent>("font", "false", 8, 12, 1);
|
||||
uiJumpInfo.addGroup(groupUI_Layer3);
|
||||
@ -206,7 +203,7 @@ void Game::init(const char *title, int width, int height, bool fullscreen, int g
|
||||
//ecs implementation
|
||||
|
||||
// player.addComponent<TransformComponent>(860*globalScale,640*globalScale,22,42,globalScale);
|
||||
player.addComponent<TransformComponent>(120*globalScale,120*globalScale,22,42,globalScale);
|
||||
player.addComponent<TransformComponent>(180*globalScale,120*globalScale,22,42,globalScale);
|
||||
player.addComponent<SpriteComponent>("player", SpriteComponent::spriteAnimation, "assets/textures/actors/firefighter.json");
|
||||
|
||||
// player.addComponent<PlayerController>(0.0,0.0,false,false,Vector2D().Zero());
|
||||
@ -313,15 +310,17 @@ void Game::update()
|
||||
|
||||
camera.x = player.getComponent<TransformComponent>().position.x - camera.w/2;
|
||||
camera.y = player.getComponent<TransformComponent>().position.y - camera.h/2;
|
||||
uiCamXInfo.getComponent<UITextComponent>().updateString(std::to_string(camera.x));
|
||||
uiCamYInfo.getComponent<UITextComponent>().updateString(std::to_string(camera.y));
|
||||
|
||||
if(camera.x < 0)
|
||||
camera.x = 0;
|
||||
if (camera.y < 0)
|
||||
camera.y = 0;
|
||||
// if (camera.x > levelMap.w-camera.w)
|
||||
// camera.x = levelMap.w-camera.w;
|
||||
// if (camera.y > levelMap.h-camera.h)
|
||||
// camera.y = levelMap.h-camera.h;
|
||||
if (camera.x > levelMap.w-camera.w)
|
||||
camera.x = levelMap.w-camera.w;
|
||||
if (camera.y > levelMap.h-camera.h)
|
||||
camera.y = levelMap.h-camera.h;
|
||||
if (Game::debugCollisionBoxes)
|
||||
{
|
||||
for (auto& c: colliders)
|
||||
|
Loading…
Reference in New Issue
Block a user