Godzil 3 éve
szülő
commit
8cb9e7602b
2 módosított fájl, 6 hozzáadás és 6 törlés
  1. 1 1
      source/Game.cpp
  2. 5 5
      source/include/Systems/Collision.h

+ 1 - 1
source/Game.cpp

@@ -271,7 +271,7 @@ void Game::Render()
 
     if (this->isDebug)
     {
-        registry->getSystem<CollisionSystem>().debugRender(this->renderer);
+        registry->getSystem<CollisionSystem>().debugRender(this->renderer, this->camera);
     }
 
     SDL_RenderPresent(this->renderer);

+ 5 - 5
source/include/Systems/Collision.h

@@ -78,7 +78,7 @@ public:
         }
     }
 
-    void debugRender(SDL_Renderer *renderer)
+    void debugRender(SDL_Renderer *renderer, SDL_Rect &camera)
     {
         for(auto entity: this->getSystemEntities())
         {
@@ -86,10 +86,10 @@ public:
             auto transform = entity.getComponent<TransformComponent>();
 
             SDL_Rect rect;
-            rect.x = static_cast<int>(transform.position.x + collider.offset.x);
-            rect.y = static_cast<int>(transform.position.y + collider.offset.y);
-            rect.w = static_cast<int>(collider.width);
-            rect.h = static_cast<int>(collider.height);
+            rect.x = static_cast<int>(transform.position.x + collider.offset.x - camera.x);
+            rect.y = static_cast<int>(transform.position.y + collider.offset.y - camera.y);
+            rect.w = static_cast<int>(collider.width * transform.scale.x);
+            rect.h = static_cast<int>(collider.height * transform.scale.y);
 
             if (collider.isColliding)
             {