diff --git a/sources/Component/Tag/TagComponent.hpp b/sources/Component/Tag/TagComponent.hpp index 9775c06d..d84a9708 100644 --- a/sources/Component/Tag/TagComponent.hpp +++ b/sources/Component/Tag/TagComponent.hpp @@ -54,6 +54,7 @@ namespace BBM constexpr const char Blowable[] = "Blowable"; // interact with visual features like camera constexpr const char Player[] = "Player"; + constexpr const char Background[] = "Background"; constexpr const char Unbreakable[] = "Unbreakable"; constexpr const char Breakable[] = "Breakable"; constexpr const char Hole[] = "Hole"; diff --git a/sources/Map/Map.cpp b/sources/Map/Map.cpp index 305e94dd..cffecfb0 100644 --- a/sources/Map/Map.cpp +++ b/sources/Map/Map.cpp @@ -338,7 +338,7 @@ namespace BBM if (rnd > 0.98) return HOLE; if (rnd > 0.25) - return BREAKABLE; + return NOTHING; return NOTHING; } diff --git a/sources/Models/Vector2.hpp b/sources/Models/Vector2.hpp index b3dacf2b..7b78502d 100644 --- a/sources/Models/Vector2.hpp +++ b/sources/Models/Vector2.hpp @@ -68,6 +68,13 @@ namespace BBM return *this; } + template + Vector2 operator-(const Vector2 &vec) const + { + return Vector2(this->x - vec.x, this->y - vec.y); + } + + template Vector2 &operator*=(T2 d) { diff --git a/sources/Runner/GameScene.cpp b/sources/Runner/GameScene.cpp index 69e954fa..e92c89a1 100644 --- a/sources/Runner/GameScene.cpp +++ b/sources/Runner/GameScene.cpp @@ -46,7 +46,8 @@ namespace BBM .addComponent("", 60, RAY::Vector2(), ORANGE); scene->addEntity("background image") .addComponent(true, "assets/background.png", false) - .addComponent(); + .addComponent() + .addComponent>(); MapGenerator::loadMap(16, 16, MapGenerator::createMap(16, 16, hasHeights), scene); return scene; } diff --git a/sources/System/Renderer/CameraSystem.cpp b/sources/System/Renderer/CameraSystem.cpp index 3c4e538c..58c473ad 100644 --- a/sources/System/Renderer/CameraSystem.cpp +++ b/sources/System/Renderer/CameraSystem.cpp @@ -74,6 +74,12 @@ namespace BBM cam.target += (newCameraPos.abs() - pos.position.abs()) / 10; newCameraPos.y = maxDist; newCameraPos.z -= 1; + Vector3f pos2d(pos.position.abs().x,0, pos.position.abs().z); + Vector3f newPos2d(newCameraPos.abs().x, 0, pos.position.abs().z); + for (auto &[entity, backPos, _] : this->_wal.getScene()->view>()) { + backPos.position -= (newPos2d - pos2d) / 10; + } pos.position += (newCameraPos.abs() - pos.position.abs()) / 10; + } } \ No newline at end of file