Exemple #1
0
        public void Initialize(Rectangle screen, BoundingBox world)
        {
            this.Screen = screen;

            this.Level = 1;

            // Add a margin so there's some space around the border
            float worldMargin = (world.Width < world.Height) ? world.Height * 0.05f : world.Width * 0.05f;

            // Get the initial viewport (complete mesh centered on the screen)
            float screenRatio = screen.Width / (float)screen.Height;
            float worldRatio = world.Width / world.Height;

            float scale = (world.Width + worldMargin) / screen.Width;

            if (screenRatio > worldRatio)
            {
                scale = (world.Height + worldMargin) / screen.Height;
            }

            float centerX = world.Left + world.Width / 2;
            float centerY = world.Bottom + world.Height / 2;

            // TODO: Add initial margin
            this.Viewport = new RectangleF(centerX - screen.Width * scale / 2,
                centerY - screen.Height * scale / 2,
                screen.Width * scale,
                screen.Height * scale);

            this.ClipMargin = this.Viewport.Width * 0.05f;

            this.World = this.Viewport;
        }
Exemple #2
0
 public void Update(BoundingBox world)
 {
     if (this.Screen != null)
     {
         Initialize(this.Screen, world);
     }
 }