diff --git a/build/BeagleRescue b/build/BeagleRescue index a4c18b3..ac4bcb7 100755 Binary files a/build/BeagleRescue and b/build/BeagleRescue differ diff --git a/src/ecs/TileMapComponent.h b/src/ecs/TileMapComponent.h index 4db0c25..07e47a8 100644 --- a/src/ecs/TileMapComponent.h +++ b/src/ecs/TileMapComponent.h @@ -90,10 +90,13 @@ public: void update() override { - for (int i=0;icurrentState == GameStateManager::ST_COREGAME){ + for (int i=0;i= 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; + } } } diff --git a/src/game/Game.cpp b/src/game/Game.cpp index 62b9545..f5a5fe3 100644 --- a/src/game/Game.cpp +++ b/src/game/Game.cpp @@ -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;rAddTexture("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("font", "Camera CamX: CamY: Jump: P.y : P.dy: YVec: ", 8, 12, 1); uiInfo.addGroup(groupUI_Layer3); + uiCamXInfo.addComponent(camera.w-48,24,40,12,gScale); + uiCamXInfo.addComponent("font", "nan", 8, 12, 1); + uiCamXInfo.addGroup(groupUI_Layer3); + + uiCamYInfo.addComponent(camera.w-48,36,40,12,gScale); + uiCamYInfo.addComponent("font", "nan", 8, 12, 1); + uiCamYInfo.addGroup(groupUI_Layer3); + uiJumpInfo.addComponent(camera.w-48,48,40,12,gScale); uiJumpInfo.addComponent("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(860*globalScale,640*globalScale,22,42,globalScale); - player.addComponent(120*globalScale,120*globalScale,22,42,globalScale); + player.addComponent(180*globalScale,120*globalScale,22,42,globalScale); player.addComponent("player", SpriteComponent::spriteAnimation, "assets/textures/actors/firefighter.json"); // player.addComponent(0.0,0.0,false,false,Vector2D().Zero()); @@ -313,15 +310,17 @@ void Game::update() camera.x = player.getComponent().position.x - camera.w/2; camera.y = player.getComponent().position.y - camera.h/2; + uiCamXInfo.getComponent().updateString(std::to_string(camera.x)); + uiCamYInfo.getComponent().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)