Example #1
0
 public static bool DrawTexture(TContext tr, TexCod texture)
 {
     tr.Texture = texture;
     ComputeTileRange(tr);
     // calculate tile statrting address
     tr.TileAdrs.X = texture.LLx / tr.TileWidth;
     tr.TileAdrs.Y = texture.LLy / tr.TileHeight;
     if (TileDraw(tr))
     {
         return((bool)true);
     }
     return(false);
 }
Example #2
0
        public static TileCod CalOverlap(TileCod tile, TexCod texture)
        {
            TileCod Overlap = new TileCod();

            if (texture.LLx <= tile.X && tile.X <= texture.TRx && texture.LLy <= tile.Y && tile.Y <= texture.TRy) //in X and Y
            {
                Overlap = tile;
                return(Overlap);
            }
            else if (texture.LLx <= tile.X && tile.X <= texture.TRx) // only X
            {
                Overlap.X = tile.X;

                if (tile.Y <= texture.LLy)
                {
                    Overlap.Y = texture.LLy;
                }
                else if (tile.Y >= texture.TRy)
                {
                    Overlap.Y = texture.TRy;
                }
                return(Overlap);
            }
            else if (texture.LLy <= tile.Y && tile.Y <= texture.TRy)// only in Y
            {
                if (tile.X <= texture.LLx)
                {
                    Overlap.X = texture.LLx;
                }
                else if (tile.X >= texture.TRx)
                {
                    Overlap.X = texture.TRx;
                }
                Overlap.Y = tile.Y;
                return(Overlap);
            }
            else
            {
                if (tile.X <= texture.LLx && tile.Y <= texture.LLy)
                {
                    Overlap.X = texture.LLx; Overlap.Y = texture.LLy;
                }                                                                                                         // nor
                else if (tile.X >= texture.TRx && tile.Y >= texture.TRy)
                {
                    Overlap.X = texture.TRx; Overlap.Y = texture.TRy;
                }
                return(Overlap);
            }
        }