Exemplo n.º 1
0
        public void DrawRectangles(List <MobaLib.Rectangle> rects, ManualCamera2D cam, Color color)
        {
            int count = rects.Count;

            if (count == 0)
            {
                return;
            }
            be.View = cam.Transformation;
            be.CurrentTechnique.Passes[0].Apply();
            VertexPositionColor[] vertices = new VertexPositionColor[12 * count];
            for (int x = 0; x < count; x++)
            {
                Microsoft.Xna.Framework.Vector3 topLeft  = new Microsoft.Xna.Framework.Vector3(rects[x].Left, rects[x].Top, 0);
                Microsoft.Xna.Framework.Vector3 topRight = new Microsoft.Xna.Framework.Vector3(rects[x].Right, rects[x].Top, 0);
                Microsoft.Xna.Framework.Vector3 botLeft  = new Microsoft.Xna.Framework.Vector3(rects[x].Left, rects[x].Bottom, 0);
                Microsoft.Xna.Framework.Vector3 botRight = new Microsoft.Xna.Framework.Vector3(rects[x].Right, rects[x].Bottom, 0);
                vertices[12 * x]      = new VertexPositionColor(topLeft, color);
                vertices[12 * x + 1]  = new VertexPositionColor(topRight, color);
                vertices[12 * x + 2]  = new VertexPositionColor(topRight, color);
                vertices[12 * x + 3]  = new VertexPositionColor(botRight, color);
                vertices[12 * x + 4]  = new VertexPositionColor(botRight, color);
                vertices[12 * x + 5]  = new VertexPositionColor(botLeft, color);
                vertices[12 * x + 6]  = new VertexPositionColor(botLeft, color);
                vertices[12 * x + 7]  = new VertexPositionColor(topLeft, color);
                vertices[12 * x + 8]  = new VertexPositionColor(botLeft, color);
                vertices[12 * x + 9]  = new VertexPositionColor(topRight, color);
                vertices[12 * x + 10] = new VertexPositionColor(topLeft, color);
                vertices[12 * x + 11] = new VertexPositionColor(botRight, color);
            }
            device.DrawUserPrimitives <VertexPositionColor>(PrimitiveType.LineList, vertices, 0, 6 * count, VertexPositionColor.VertexDeclaration);
        }
Exemplo n.º 2
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);
     cam         = new ManualCamera2D(GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height, GraphicsDevice);
     helper      = new DrawHelper(GraphicsDevice);
     cam.CenterHard(new Vector2(500, 500));
     cam.SetZoom(1);
     StartNewGame();
     // TODO: use this.Content to load your game content here
 }
Exemplo n.º 3
0
 public void DrawLines(Vector2[] positions, ManualCamera2D cam, Color color, int count)
 {
     count = count < positions.Length ? count : positions.Length;
     if (count <= 0)
         return;
     be.View = cam.Transformation;
     be.CurrentTechnique.Passes[0].Apply();
     VertexPositionColor[] vertices = new VertexPositionColor[2 * count];
     for (int x = 0; x < count; x++)
     {
         vertices[2 * x] = new VertexPositionColor(new Microsoft.Xna.Framework.Vector3(positions[x], 0), color);
         vertices[2 * x + 1] = new VertexPositionColor(new Microsoft.Xna.Framework.Vector3(positions[(x + 1) % positions.Length], 0), color);
     }
     device.DrawUserPrimitives<VertexPositionColor>(PrimitiveType.LineList, vertices, 0, count, VertexPositionColor.VertexDeclaration);
 }
Exemplo n.º 4
0
 public void DrawLines(Vector2[] positions, ManualCamera2D cam, Color color, int count)
 {
     count = count < positions.Length ? count : positions.Length;
     if (count <= 0)
     {
         return;
     }
     be.View = cam.Transformation;
     be.CurrentTechnique.Passes[0].Apply();
     VertexPositionColor[] vertices = new VertexPositionColor[2 * count];
     for (int x = 0; x < count; x++)
     {
         vertices[2 * x]     = new VertexPositionColor(new Microsoft.Xna.Framework.Vector3(positions[x], 0), color);
         vertices[2 * x + 1] = new VertexPositionColor(new Microsoft.Xna.Framework.Vector3(positions[(x + 1) % positions.Length], 0), color);
     }
     device.DrawUserPrimitives <VertexPositionColor>(PrimitiveType.LineList, vertices, 0, count, VertexPositionColor.VertexDeclaration);
 }
Exemplo n.º 5
0
        public void FlushLines(ManualCamera2D cam)
        {
            int count = _lineQueue.Count;

            if (count <= 0)
            {
                return;
            }
            be.View = cam.Transformation;
            be.CurrentTechnique.Passes[0].Apply();
            VertexPositionColor[] vertices = new VertexPositionColor[2 * count];
            for (int x = 0; x < count; x++)
            {
                vertices[2 * x]     = new VertexPositionColor(new Microsoft.Xna.Framework.Vector3(_lineQueue[x].Start, 0), _lineQueue[x].Color);
                vertices[2 * x + 1] = new VertexPositionColor(new Microsoft.Xna.Framework.Vector3(_lineQueue[x].End, 0), _lineQueue[x].Color);
            }
            device.DrawUserPrimitives <VertexPositionColor>(PrimitiveType.LineList, vertices, 0, count, VertexPositionColor.VertexDeclaration);
            _lineQueue.Clear();
        }
Exemplo n.º 6
0
 public void FlushRects(ManualCamera2D cam)
 {
     DrawRectangles(_rectQueue, cam, Color.White);
     _rectQueue.Clear();
 }
Exemplo n.º 7
0
 public void DrawLines(Vector2[] positions, ManualCamera2D cam, Color color)
 {
     DrawLines(positions, cam, color, positions.Length);
 }
Exemplo n.º 8
0
 public void DrawLines(Vector2[] positions, ManualCamera2D cam, Color color)
 {
     DrawLines(positions, cam, color, positions.Length);
 }
Exemplo n.º 9
0
 public void FlushRects(ManualCamera2D cam)
 {
     DrawRectangles(_rectQueue, cam, Color.White);
     _rectQueue.Clear();
 }
Exemplo n.º 10
0
 public void FlushLines(ManualCamera2D cam)
 {
     int count = _lineQueue.Count;
     if (count <= 0)
         return;
     be.View = cam.Transformation;
     be.CurrentTechnique.Passes[0].Apply();
     VertexPositionColor[] vertices = new VertexPositionColor[2 * count];
     for (int x = 0; x < count; x++)
     {
         vertices[2 * x] = new VertexPositionColor(new Microsoft.Xna.Framework.Vector3(_lineQueue[x].Start, 0), _lineQueue[x].Color);
         vertices[2 * x + 1] = new VertexPositionColor(new Microsoft.Xna.Framework.Vector3(_lineQueue[x].End, 0), _lineQueue[x].Color);
     }
     device.DrawUserPrimitives<VertexPositionColor>(PrimitiveType.LineList, vertices, 0, count, VertexPositionColor.VertexDeclaration);
     _lineQueue.Clear();
 }
Exemplo n.º 11
0
 public void DrawRectangles(List<MobaLib.Rectangle> rects, ManualCamera2D cam, Color color)
 {
     int count = rects.Count;
     if (count == 0)
         return;
     be.View = cam.Transformation;
     be.CurrentTechnique.Passes[0].Apply();
     VertexPositionColor[] vertices = new VertexPositionColor[12 * count];
     for (int x = 0; x < count; x++)
     {
         Microsoft.Xna.Framework.Vector3 topLeft = new Microsoft.Xna.Framework.Vector3(rects[x].Left, rects[x].Top, 0);
         Microsoft.Xna.Framework.Vector3 topRight = new Microsoft.Xna.Framework.Vector3(rects[x].Right, rects[x].Top, 0);
         Microsoft.Xna.Framework.Vector3 botLeft = new Microsoft.Xna.Framework.Vector3(rects[x].Left, rects[x].Bottom, 0);
         Microsoft.Xna.Framework.Vector3 botRight = new Microsoft.Xna.Framework.Vector3(rects[x].Right, rects[x].Bottom, 0);
         vertices[12 * x] = new VertexPositionColor(topLeft, color);
         vertices[12 * x + 1] = new VertexPositionColor(topRight, color);
         vertices[12 * x + 2] = new VertexPositionColor(topRight, color);
         vertices[12 * x + 3] = new VertexPositionColor(botRight, color);
         vertices[12 * x + 4] = new VertexPositionColor(botRight, color);
         vertices[12 * x + 5] = new VertexPositionColor(botLeft, color);
         vertices[12 * x + 6] = new VertexPositionColor(botLeft, color);
         vertices[12 * x + 7] = new VertexPositionColor(topLeft, color);
         vertices[12 * x + 8] = new VertexPositionColor(botLeft, color);
         vertices[12 * x + 9] = new VertexPositionColor(topRight, color);
         vertices[12 * x + 10] = new VertexPositionColor(topLeft, color);
         vertices[12 * x + 11] = new VertexPositionColor(botRight, color);
     }
     device.DrawUserPrimitives<VertexPositionColor>(PrimitiveType.LineList, vertices, 0, 6 * count, VertexPositionColor.VertexDeclaration);
 }
Exemplo n.º 12
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);
     cam = new ManualCamera2D(GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height, GraphicsDevice);
     helper = new DrawHelper(GraphicsDevice);
     cam.CenterHard(new Vector2(500, 500));
     cam.SetZoom(1);
     StartNewGame();
     // TODO: use this.Content to load your game content here
 }