Browse Source

Fehler beim 2D zeichnen behoben

kolja 5 years ago
parent
commit
f7c2b2d3a9
3 changed files with 12 additions and 12 deletions
  1. 8 8
      Kamera2D.cpp
  2. 3 3
      Welt2D.cpp
  3. 1 1
      Welt2D.h

+ 8 - 8
Kamera2D.cpp

@@ -30,13 +30,13 @@ void Kamera2D::lookAtWorldPos( int x, int y )
     if( welt && welt->getWorldInfo().hasSize && welt->getWorldInfo().circular )
     {
         if( wPos.x < 0 )
-            wPos.x += welt->getWorldInfo().size.x;
+            wPos.x += (float)welt->getWorldInfo().size.x;
         if( wPos.y < 0 )
-            wPos.y += welt->getWorldInfo().size.y;
+            wPos.y += (float)welt->getWorldInfo().size.y;
         if( wPos.x > welt->getWorldInfo().size.x )
-            wPos.x -= welt->getWorldInfo().size.x;
+            wPos.x -= (float)welt->getWorldInfo().size.x;
         if( wPos.y > welt->getWorldInfo().size.y )
-            wPos.y -= welt->getWorldInfo().size.y;
+            wPos.y -= (float)welt->getWorldInfo().size.y;
     }
 }
 
@@ -46,13 +46,13 @@ void Kamera2D::lookAtWorldPos( Vertex pos )
     if( welt && welt->getWorldInfo().hasSize && welt->getWorldInfo().circular )
     {
         if( wPos.x < 0 )
-            wPos.x += welt->getWorldInfo().size.x;
+            wPos.x += (float)welt->getWorldInfo().size.x;
         if( wPos.y < 0 )
-            wPos.y += welt->getWorldInfo().size.y;
+            wPos.y += (float)welt->getWorldInfo().size.y;
         if( wPos.x > welt->getWorldInfo().size.x )
-            wPos.x -= welt->getWorldInfo().size.x;
+            wPos.x -= (float)welt->getWorldInfo().size.x;
         if( wPos.y > welt->getWorldInfo().size.y )
-            wPos.y -= welt->getWorldInfo().size.y;
+            wPos.y -= (float)welt->getWorldInfo().size.y;
     }
 }
 

+ 3 - 3
Welt2D.cpp

@@ -276,12 +276,12 @@ void Welt2D::addObject( Object2D *obj )
     objects->add( obj );
 }
 
-void Welt2D::removeObject( Object2D *obj )
+void Welt2D::removeObject( Object2D *zObj )
 {
     int anz = objects->getEintragAnzahl();
     for( int i = 0; i < anz; i++ )
     {
-        if( objects->z( i ) == obj )
+        if( objects->z( i ) == zObj )
         {
             objects->remove( i );
             i--;
@@ -370,7 +370,7 @@ void Welt2D::render( Mat3< float > &kamMat, Punkt size, Bild &zRObj, int xOffset
     for( auto obj = objects->getIterator(); obj; obj++ )
     {
         Rect2< float > bnd = obj->getBoundingBox();
-        Vertex topRight = Vertex( bnd.topLeft.y, bnd.bottomRight.x );
+        Vertex topRight = Vertex( bnd.bottomRight.x, bnd.topLeft.y );
         Vertex bottomLeft = Vertex( bnd.topLeft.x, bnd.bottomRight.y );
         Mat3< float > km = kamMat * Mat3<float>::translation( Vertex( (float)xOffset, (float)yOffset ) );
         bnd.bottomRight = km * bnd.bottomRight;

+ 1 - 1
Welt2D.h

@@ -151,7 +151,7 @@ namespace Framework
         __declspec( dllexport ) void setSize( bool hasSize );
         __declspec( dllexport ) void setCircular( bool circular );
         __declspec( dllexport ) void addObject( Object2D *obj );
-        __declspec( dllexport ) void removeObject( Object2D *obj );
+        __declspec( dllexport ) void removeObject( Object2D *zObj );
         __declspec( dllexport ) void removeAll();
         __declspec( dllexport ) void explosion( Vertex worldPos, float intensity, float maxRad );
         __declspec( dllexport ) void impuls( Vertex worldPos, Vertex worldDir );