Esempio n. 1
0
        public GridRenderer(Grid <T> _grid, Func <T, Color4> _colorSelector, float _tileWidth, float _tileHeight)
        {
            grid = _grid;

            tileWidth  = _tileWidth;
            tileHeight = _tileHeight;
            var rectanglesVertices = new List <IEnumerable <ColoredVertex> >();

            for (var i = 0; i < _grid.Width; i++)
            {
                for (var j = 0; j < _grid.Height; j++)
                {
                    var rectangle       = new Rectangle(i * tileWidth, j * tileHeight, tileWidth, tileHeight);
                    var vertices        = rectangle.ToVertices();
                    var tile            = _grid.Get(i, j);
                    var color           = _colorSelector(tile);
                    var coloredVertices = vertices.Select(v => new ColoredVertex(new Vector3(v.X, v.Y, 0), color));
                    rectanglesVertices.Add(coloredVertices);
                }
            }

            buffer = new ColoredVertexBuffer(PrimitiveType.Quads);
            buffer.AddVertices(rectanglesVertices.SelectMany(x => x));

            Initialize(buffer);
        }
Esempio n. 2
0
 /// <summary>
 /// Sets this bounding box's position/dimensions to match the given rectangle
 /// </summary>
 /// <param name="_rectangle">rectangle to match</param>
 public void MatchPositionAndDimensions(Rectangle _rectangle)
 {
     X = _rectangle.X;
     Y = _rectangle.Y;
     W = _rectangle.W;
     H = _rectangle.H;
 }
Esempio n. 3
0
            public IEnumerable <(ParticlePrimitive PrimitiveType, IEnumerable <(float X, float Y)> Vertices)> Vertices(Particle _particle)
            {
                var rectangle = new Rectangle(_particle.X - _particle.Size / 2, _particle.Y - _particle.Size / 2, _particle.Size, _particle.Size);

                return(new List <(ParticlePrimitive, IEnumerable <(float X, float Y)>)>()
                {
                    (ParticlePrimitive.Quads, rectangle.ToVertices().Rotated(_particle.Rocket.Angle, _particle.X, _particle.Y))
                    //(ParticlePrimitive.Points, new List<(float X, float Y)> () { (_particle.X, _particle.Y) })
                });
            }
Esempio n. 4
0
 public bool Collides(float _x, float _y, float _w, float _h, float _xoff, float _yoff)
 => Rectangle.Collide(_x, _y, _w, _h, _xoff + X, _yoff + Y, W, H);
Esempio n. 5
0
 //Collide against _r if we were offset by (_xoff, _yoff)
 public bool Collides(Rectangle _r, float _xoff, float _yoff)
 => Collides(_r.X, _r.Y, _r.W, _r.H, _xoff, _yoff);
Esempio n. 6
0
 public bool Collides(float _x, float _y)
 => Rectangle.Collide(_x, _y, X, Y, W, H);
Esempio n. 7
0
 public BoundingBox(Rectangle _rectangle) : this(_rectangle.X, _rectangle.Y, _rectangle.W, _rectangle.H)
 {
 }
Esempio n. 8
0
 public static List <Vector3> PointsFromRectangle(Rectangle _r)
 => PointsFromRectangle(_r.X, _r.Y, _r.W, _r.H);
Esempio n. 9
0
 public static List <Vector3> RectanglePoints(Basics.Rectangle _rectangle)
 => RectanglePoints(_rectangle.X, _rectangle.Y, _rectangle.W, _rectangle.H);
Esempio n. 10
0
 public static ConvexPolygon Rectangle(Basics.Rectangle _rectangle)
 => Rectangle(_rectangle.X, _rectangle.Y, _rectangle.W, _rectangle.H);
Esempio n. 11
0
 public static void Rectangle(Rectangle _r, float _x = 0, float _y = 0, Color4?_color = null, bool _filled = true, float _radians = 0)
 => Rectangle(_x + _r.X, _y + _r.Y, _r.W, _r.H, _color, _filled, _radians);