Browse Source

Fehler in Kamera behoben

kolja 5 years ago
parent
commit
27d90bedc6
1 changed files with 22 additions and 0 deletions
  1. 22 0
      Kamera2D.cpp

+ 22 - 0
Kamera2D.cpp

@@ -27,11 +27,33 @@ void Kamera2D::lookAtWorldPos( int x, int y )
 {
     wPos.x = (float)x;
     wPos.y = (float)y;
+    if( welt && welt->getWorldInfo().hasSize && welt->getWorldInfo().circular )
+    {
+        if( wPos.x < 0 )
+            wPos.x += welt->getWorldInfo().size.x;
+        if( wPos.y < 0 )
+            wPos.y += welt->getWorldInfo().size.y;
+        if( wPos.x > welt->getWorldInfo().size.x )
+            wPos.x -= welt->getWorldInfo().size.x;
+        if( wPos.y > welt->getWorldInfo().size.y )
+            wPos.y -= welt->getWorldInfo().size.y;
+    }
 }
 
 void Kamera2D::lookAtWorldPos( Vertex pos )
 {
     wPos = pos;
+    if( welt && welt->getWorldInfo().hasSize && welt->getWorldInfo().circular )
+    {
+        if( wPos.x < 0 )
+            wPos.x += welt->getWorldInfo().size.x;
+        if( wPos.y < 0 )
+            wPos.y += welt->getWorldInfo().size.y;
+        if( wPos.x > welt->getWorldInfo().size.x )
+            wPos.x -= welt->getWorldInfo().size.x;
+        if( wPos.y > welt->getWorldInfo().size.y )
+            wPos.y -= welt->getWorldInfo().size.y;
+    }
 }
 
 void Kamera2D::lookAtWorldArea( int width, int height )