Exemplo n.º 1
0
        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);
            }
        }
Exemplo n.º 2
0
        public void Draw(SpriteBatch spriteBatch, AsciiFontTexture2D asciiFontTexture2D, Console console)
        {
            DrawBorder(spriteBatch, asciiFontTexture2D);

            var displayableMessages = console.Messages.Reverse().Take(_numberOfLines);
            var y = _rectangle.Y + _rectangle.Height - 2;

            foreach (var displayableMessage in displayableMessages)
            {
                asciiFontTexture2D.DrawString(spriteBatch, new Rectangle(_rectangle.X + 1, y, _rectangle.Width - 2, 1), _color, displayableMessage);
                y -= 1;
            }
        }
Exemplo n.º 3
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);
             }
         }
     }
 }
Exemplo n.º 4
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);
 }
Exemplo n.º 5
0
 public void Draw(SpriteBatch spriteBatch, AsciiFontTexture2D asciiFontTexture2D)
 {
     asciiFontTexture2D.DrawString(spriteBatch, _rectangle, Color.Yellow, _statusMessage);
 }
Exemplo n.º 6
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            _spriteBatch = new SpriteBatch(GraphicsDevice);

            _asciiFontTexture2D = new AsciiFontTexture2D(GraphicsDevice, @"Images\Terbert_10x10.png", 10, 10);
        }