コード例 #1
0
ファイル: Maths.cs プロジェクト: lightofanima/Polys
 public static bool isRectVisible(Rect rect, int screenW, int screenH)
 {
     if (rect.right < 0 || rect.top < 0 ||
         rect.x > screenW || rect.y > screenH)
         return false;
     else
         return true;
 }
コード例 #2
0
ファイル: Maths.cs プロジェクト: lightofanima/Polys
        //The position is the bottom left corner.
        public static Matrix4 matrixPixelProjection(Rect spriteRect, int screenWidth, int screenHeight)
        {
            //We want the position to be the bottom left corner, so compensate.
            //Temporary solution.
            //posX -= tileWidth;
            //posY -= tileHeight;

            //Find projection and UV matrices.
            double px = (spriteRect.x + 0.5) / screenWidth * 2.0 - 1.0;
            double py = (screenHeight - spriteRect.y + 0.5 - spriteRect.h) / screenHeight * 2.0 - 1.0;
            double sx = (double)spriteRect.w / screenWidth;
            double sy = (double)spriteRect .h/ screenHeight;

            return new Matrix4(new float[] { (float)sx, 0, 0, 0,
                                                           0, (float)sy, 0, 0,
                                                           0, 0, 0, 0,
                                                           (float)(sx+px), (float)(sy+py), 0, 1});
        }
コード例 #3
0
ファイル: Rect.cs プロジェクト: lightofanima/Polys
 public bool overlaps(Rect r)
 {
     return r.x < (x + w) && (r.x + r.w) >= x &&
         r.y < (y + h) && (r.y + r.h) >= y;
 }