private void DrawBorder(SpriteBatch spriteBatch, AsciiFontTexture2D asciiFontTexture2D)
        {
            var topLeft = asciiFontTexture2D.RectangleFromGlyph(218);
            var topRight = asciiFontTexture2D.RectangleFromGlyph(191);
            var bottomLeft = asciiFontTexture2D.RectangleFromGlyph(192);
            var bottomRight = asciiFontTexture2D.RectangleFromGlyph(217);
            var vertical = asciiFontTexture2D.RectangleFromGlyph(196);
            var horizontal = asciiFontTexture2D.RectangleFromGlyph(179);

            spriteBatch.Draw(asciiFontTexture2D.Texture2D, new Rectangle(_rectangle.X * asciiFontTexture2D.GlyphWidth, _rectangle.Y * asciiFontTexture2D.GlyphHeight, asciiFontTexture2D.GlyphWidth, asciiFontTexture2D.GlyphHeight), topLeft, _color);
            spriteBatch.Draw(asciiFontTexture2D.Texture2D, new Rectangle((_rectangle.X + _rectangle.Width - 1) * asciiFontTexture2D.GlyphWidth, _rectangle.Y * asciiFontTexture2D.GlyphHeight, asciiFontTexture2D.GlyphWidth, asciiFontTexture2D.GlyphHeight), topRight, _color);
            spriteBatch.Draw(asciiFontTexture2D.Texture2D, new Rectangle(_rectangle.X * asciiFontTexture2D.GlyphWidth, (_rectangle.Y + _rectangle.Height - 1) * asciiFontTexture2D.GlyphHeight, asciiFontTexture2D.GlyphWidth, asciiFontTexture2D.GlyphHeight), bottomLeft, _color);
            spriteBatch.Draw(asciiFontTexture2D.Texture2D, new Rectangle((_rectangle.X + _rectangle.Width - 1) * asciiFontTexture2D.GlyphWidth, (_rectangle.Y + _rectangle.Height - 1) * asciiFontTexture2D.GlyphHeight, asciiFontTexture2D.GlyphWidth, asciiFontTexture2D.GlyphHeight), bottomRight, _color);

            for (var x = 1; x < _rectangle.Width - 1; x++)
            {
                spriteBatch.Draw(asciiFontTexture2D.Texture2D, new Rectangle((_rectangle.X + x) * asciiFontTexture2D.GlyphWidth, _rectangle.Y * asciiFontTexture2D.GlyphHeight, asciiFontTexture2D.GlyphWidth, asciiFontTexture2D.GlyphHeight), vertical, _color);
                spriteBatch.Draw(asciiFontTexture2D.Texture2D, new Rectangle((_rectangle.X + x) * asciiFontTexture2D.GlyphWidth, (_rectangle.Y + _rectangle.Height - 1) * asciiFontTexture2D.GlyphHeight, asciiFontTexture2D.GlyphWidth, asciiFontTexture2D.GlyphHeight), vertical, _color);
            }
            for (var y = 1; y < _rectangle.Height - 1; y++)
            {
                spriteBatch.Draw(asciiFontTexture2D.Texture2D, new Rectangle(_rectangle.X * asciiFontTexture2D.GlyphWidth, (_rectangle.Y + y) * asciiFontTexture2D.GlyphHeight, asciiFontTexture2D.GlyphWidth, asciiFontTexture2D.GlyphHeight), horizontal, _color);
                spriteBatch.Draw(asciiFontTexture2D.Texture2D, new Rectangle((_rectangle.X + _rectangle.Width - 1) * asciiFontTexture2D.GlyphWidth, (_rectangle.Y + y) * asciiFontTexture2D.GlyphHeight, asciiFontTexture2D.GlyphWidth, asciiFontTexture2D.GlyphHeight), horizontal, _color);
            }
        }
Example #2
0
 public void DrawMap(SpriteBatch spriteBatch, AsciiFontTexture2D asciiFontTexture2D, Map map)
 {
     for (var x = 0; x < _rectangle.Width; x++)
     {
         for (var y = 0; y < _rectangle.Width; y++)
         {
             if ((x >= 0 && x < map.Width) && (y >= 0 && y < map.Width))
             {
                 var tile = map.TileSet.Tiles[map.TileData[x, y]];
                 spriteBatch.Draw(asciiFontTexture2D.Texture2D,
                     new Rectangle((x + _rectangle.X) * asciiFontTexture2D.GlyphWidth, (y + _rectangle.Y) * asciiFontTexture2D.GlyphHeight, asciiFontTexture2D.GlyphWidth, asciiFontTexture2D.GlyphHeight),
                     asciiFontTexture2D.RectangleFromGlyph(tile.Glyph),
                     tile.Color);
             }
         }
     }
 }
Example #3
0
 public void DrawCharacter(SpriteBatch spriteBatch, AsciiFontTexture2D asciiFontTexture2D, Player player)
 {
     spriteBatch.Draw(asciiFontTexture2D.Texture2D, new Rectangle((_rectangle.X + player.X) * asciiFontTexture2D.GlyphWidth, (_rectangle.Y + player.Y) * asciiFontTexture2D.GlyphHeight,
         asciiFontTexture2D.GlyphWidth, asciiFontTexture2D.GlyphHeight), asciiFontTexture2D.RectangleFromGlyph(64), Color.Yellow);
 }