Ejemplo n.º 1
0
        public void Render(SpriteBatch spriteBatch, SpriteFont font)
        {
            /*foreach (LineSegment side in sides)
             * {
             *  line.ClearVectors();
             *  line.AddVector(side.Point1);
             *  line.AddVector(side.Point2);
             *  line.Render(spriteBatch);
             * }*/

            line.ClearVectors();

            foreach (Vector2 vert in vertices)
            {
                line.AddVector(vert);
            }

            line.AddVector(vertices[0]);

            line.Render(spriteBatch);

            string  str     = vertices.Count.ToString();
            Vector2 strSize = font.MeasureString(str);

            spriteBatch.DrawString(font, str, new Vector2((int)(CenterPoint.X - strSize.X / 2), (int)(CenterPoint.Y - strSize.Y / 2)), Color.Black);
        }
Ejemplo n.º 2
0
        protected override void Draw(GameTime gameTime)
        {
            frameCounter++;

            GraphicsDevice.Clear(Color.CornflowerBlue);

            spriteBatch.Begin();

            foreach (Ball ball in Ball.Balls)
            {
                spriteBatch.Draw(ballTexture, ball.Rectangle, Color.White * .95f);
            }

            foreach (Polygon polygon in Polygon.Polygons)
            {
                polygon.Render(spriteBatch, font1);
            }

            /*foreach (Ball ball in Ball.Balls)
             * {
             *  line.ClearVectors();
             *  line.AddVector(ball
             * }*/

            foreach (GridNode node in Grid.nodes)
            {
                line.ClearVectors();
                line.AddVector(new Vector2(node.Rectangle.X, node.Rectangle.Y));
                line.AddVector(new Vector2(node.Rectangle.X + node.Rectangle.Width, node.Rectangle.Y));
                line.AddVector(new Vector2(node.Rectangle.X + node.Rectangle.Width, node.Rectangle.Y + node.Rectangle.Height));
                line.AddVector(new Vector2(node.Rectangle.X, node.Rectangle.Y + node.Rectangle.Height));
                line.RenderWithAlpha(spriteBatch, .25f);
            }

            spriteBatch.End();

            base.Draw(gameTime);
        }