diff --git a/assets/backgrounds/gameWall.png b/assets/backgrounds/gameWall.png new file mode 100644 index 00000000..1a373f54 Binary files /dev/null and b/assets/backgrounds/gameWall.png differ diff --git a/lib/Ray/sources/Drawables/3D/Plane.cpp b/lib/Ray/sources/Drawables/3D/Plane.cpp index 13cc09bc..aaf01bfa 100644 --- a/lib/Ray/sources/Drawables/3D/Plane.cpp +++ b/lib/Ray/sources/Drawables/3D/Plane.cpp @@ -11,7 +11,8 @@ namespace RAY::Drawables::Drawables3D { Plane::Plane(const Vector3 &position, const Vector2 &dimensions, const Color &color) : - ADrawable3D(position, color), _dimensions(dimensions) + ADrawable3D(position, color), + _dimensions(dimensions) { } 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/Models/Vector2.hpp b/sources/Models/Vector2.hpp index 0f27fe3a..cbb51f78 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 2327cc36..0446d082 100644 --- a/sources/Runner/GameScene.cpp +++ b/sources/Runner/GameScene.cpp @@ -17,10 +17,8 @@ #include "Component/Tag/TagComponent.hpp" #include "Component/Renderer/Drawable3DComponent.hpp" #include "Component/Shaders/Items/AlphaCtxShaderComponent.hpp" -#include "Component/Renderer/Drawable2DComponent.hpp" #include #include "Component/Shaders/ShaderComponent.hpp" -#include "Drawables/Texture.hpp" #include "Component/Gravity/GravityComponent.hpp" #include "Component/BumperTimer/BumperTimerComponent.hpp" #include "Component/Timer/TimerComponent.hpp" @@ -40,8 +38,11 @@ namespace BBM .addComponent(8, 0, -5) .addComponent(Vector3f(8, 0, 8)); scene->addEntity("background image") - .addComponent(true, "assets/backgrounds/game.png", false) - .addComponent(); + .addComponent("assets/map/breakable_wall.obj", true, std::make_pair(MAP_DIFFUSE, "assets/backgrounds/game.png"), Vector3f(50, 1, 50)) + .addComponent(5, -2, 0); + scene->addEntity("background image") + .addComponent("assets/map/breakable_wall.obj", true, std::make_pair(MAP_DIFFUSE, "assets/backgrounds/gameWall.png"), Vector3f(50, 1, 50), -90, Vector3f(), Vector3f(1, 0, 0)) + .addComponent(5, 14, 22); MapGenerator::loadMap(16, 16, MapGenerator::createMap(16, 16, hasHeights), scene); return scene; } @@ -69,7 +70,7 @@ namespace BBM .addComponent(BBM::Vector3f{0.25, 0, 0.25}, BBM::Vector3f{.75, 2, .75}) .addComponent() .addComponent() - .addComponent("assets/shaders/alpha.fs", "", [](WAL::Entity &myEntity, WAL::Wal &wal, std::chrono::nanoseconds dtime) { + .addComponent("assets/shaders/alpha.fs", "", [](WAL::Entity &myEntity, WAL::Wal &, std::chrono::nanoseconds dtime) { auto &ctx = myEntity.getComponent(); ctx.clock += dtime; @@ -119,7 +120,7 @@ namespace BBM if (entity.hasComponent()) return; entity.getComponent().disabled = true; - entity.addComponent(1s, [](WAL::Entity &ent, WAL::Wal &wal) { + entity.addComponent(1s, [](WAL::Entity &ent, WAL::Wal &) { ent.scheduleDeletion(); }); }); diff --git a/sources/Runner/Runner.cpp b/sources/Runner/Runner.cpp index 235d53d3..19019a33 100644 --- a/sources/Runner/Runner.cpp +++ b/sources/Runner/Runner.cpp @@ -3,7 +3,6 @@ // #include -#include #include "System/Movable/MovableSystem.hpp" #include "System/Renderer/RenderSystem.hpp" #include @@ -12,15 +11,9 @@ #include "System/Controllable/ControllableSystem.hpp" #include "System/Gamepad/GamepadSystem.hpp" #include -#include "Component/Button/ButtonComponent.hpp" -#include #include #include #include -#include -#include "Component/Renderer/CameraComponent.hpp" -#include "Component/Renderer/Drawable3DComponent.hpp" -#include "Component/Renderer/Drawable2DComponent.hpp" #include "Runner.hpp" #include "Models/GameState.hpp" #include @@ -37,7 +30,6 @@ #include "System/Shaders/ShaderDrawable2DSystem.hpp" #include "System/Shaders/ShaderModelSystem.hpp" #include "System/Animation/AnimationsSystem.hpp" -#include "Map/Map.hpp" #include "System/IAControllable/IAControllableSystem.hpp" #include "System/MenuControllable/MenuControllableSystem.hpp" #include @@ -50,7 +42,6 @@ #include "System/Lobby/LobbySystem.hpp" #include "System/Score/ScoreSystem.hpp" #include "System/EndCondition/EndConditionSystem.hpp" -#include "Component/Lobby/LobbyComponent.hpp" #include "System/Bonus/BonusUISystem.hpp" namespace BBM diff --git a/sources/System/Renderer/CameraSystem.cpp b/sources/System/Renderer/CameraSystem.cpp index f6f2ec22..c8a73015 100644 --- a/sources/System/Renderer/CameraSystem.cpp +++ b/sources/System/Renderer/CameraSystem.cpp @@ -80,11 +80,18 @@ namespace BBM maxDist += (lowerXDist + lowerZDist) / 2; if (maxDist < 14) maxDist = 14; - if (maxDist > 25) - maxDist = 25; - cam.target += (newCameraPos.abs() - pos.position.abs()) / 10; + if (maxDist > 23) + maxDist = 23; + Vector3f pos2d(pos.position.abs().x,0, pos.position.abs().z); + Vector3f newPos2d(newCameraPos.abs().x, 0, pos.position.abs().z); + for (auto &[other, backPos, _] : this->_wal.getScene()->view>()) { + backPos.position = cam.target; + } + newCameraPos.y = 0; + cam.target += (newCameraPos.abs() - cam.target.abs()) / 10; newCameraPos.y = maxDist; - newCameraPos.z -= 1; + newCameraPos.z -= newCameraPos.z > 1 ? 1 : 0; pos.position += (newCameraPos.abs() - pos.position.abs()) / 10; + } } \ No newline at end of file