Ejemplo n.º 1
0
        public static void DrawObject(this Graphics g, IGameObject obj, Bitmap bitmap, Camera camera)
        {
            var location = obj.Body.Position - camera.Body.Position;
            g.DrawImage(bitmap, location.X, location.Y);

            g.DrawAABB(obj, camera);
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
0
        private static void DrawAABB(this Graphics g, IGameObject obj, Camera camera)
        {
            var location = obj.Body.Collider.Position - camera.Body.Position;
            var locationPoint = new Point((int)location.X, (int)location.Y);
            var size = obj.Body.Collider.Size;

            var shape = new Rectangle(locationPoint, new Size((int)size.X, (int)size.Y));
            var pen = new Pen(Color.Green, 2);

            g.DrawRectangle(pen, shape);
        }
Ejemplo n.º 4
0
        public void CreateNewObject()
        {
            EditingObject = new GameObject(0, new Vector2f(), new Vector2f(128, 128), 1, new Vector2f(), false, false);

            var target = EditingObject.Body;
            var offset = new Vector2f((window.ClientSize.Width - 300) / 2, window.ClientSize.Height / 2);
            var cameraPosition = target.Position + target.Collider.Size / 2 - offset;

            var screenSize = new Vector2f(window.ClientSize.Width, window.ClientSize.Height);
            Camera = new Camera(cameraPosition, screenSize);

            TextureName = "";
        }