Beispiel #1
0
        private static void DrawCell(this Graphics g, CollisionCell cell, Vector2f indexes, Camera camera)
        {
            var location      = indexes * CollisionCell.Size - camera.Body.Position;
            var locationPoint = new Point((int)location.X, (int)location.Y);
            var shape         = new Rectangle(locationPoint, new Size(CollisionCell.Size, CollisionCell.Size));

            var pen = new Pen(cell.ObjectsInside.Count > 0 ? Color.DarkRed : Color.DarkCyan);

            pen.Width = 1.5f;

            g.DrawRectangle(pen, shape);
        }
Beispiel #2
0
        private void DrawCollisionCell(RenderTarget target, CollisionCell cell, int x, int y, Vector2f offset)
        {
            Transform transf = Transform.Identity;

            transf.Translate(new Vector2f(x * CollisionCell.Size, y * CollisionCell.Size) - offset);
            var shape = new RectangleShape(new Vector2f(CollisionCell.Size - 3, CollisionCell.Size - 3));

            shape.FillColor        = Color.Transparent;
            shape.OutlineColor     = cell.ObjectsInside.Count > 0 ? Color.Red : Color.Green;
            shape.OutlineThickness = 1.5f;

            target.Draw(shape, new RenderStates(transf));
        }
        public PhysicalProcessor(Scene scene, Vector2f gravity, uint iterationsCount, PhysicsMode mode)
        {
            IterCount        = iterationsCount;
            StaticResistance = 0.3;
            var sceneSize = scene.Size;

            Gravity   = gravity;
            this.mode = mode;
            master    = scene;

            var colonsCount = (int)(sceneSize.X / CollisionCell.Size) + 1;
            var rowsCount   = (int)(sceneSize.Y / CollisionCell.Size) + 1;

            cellMap = new CollisionCell[colonsCount, rowsCount];

            for (var x = 0; x < cellMap.GetLength(0); x++)
            {
                for (var y = 0; y < cellMap.GetLength(1); y++)
                {
                    cellMap[x, y] = new CollisionCell();
                }
            }
        }