Example #1
0
 private SpriteNode SplitNode(SpriteNode node, int width, int height)
 {
     node.used  = true;
     node.down  = new SpriteNode(node.x, node.y + height, node.w, node.h - height);
     node.right = new SpriteNode(node.x + width, node.y, node.w - width, height);
     return(node);
 }
Example #2
0
 private SpriteNode FindNode(SpriteNode node, int width, int height)
 {
     if (node.used)
     {
         return(FindNode(node.right, width, height) ?? FindNode(node.down, width, height));
     }
     if (width <= node.area.Width && height <= node.area.Height)
     {
         return(node);
     }
     return(null);
 }
Example #3
0
        public SpriteMap(GraphicsDevice graphicsDevice, int mapSize = 1024)
        {
            this.graphicsDevice = graphicsDevice;
            spriteCount         = 0;
            regions             = new Rectangle[256];
            regionIndices       = new Dictionary <string, int>();
            map       = new Texture2D(graphicsDevice, mapSize, mapSize);
            sheetData = new Color[mapSize * mapSize];

            root = new SpriteNode(0, 0, mapSize, mapSize);

            this.mapSize = mapSize;
        }