Exemplo n.º 1
0
        public Vector2f FindOffset()
        {
            LastOffset = ViewOffset;

            Vector2f centre;

            if (CameraSubject != null) {
                centre = CameraSubject.Position;
            } else if (CurrentScreen != null) {
                centre = CurrentScreen.Bounds.Centre.Clone();
            } else {
                centre = Game.ScreenCentre;
            }

            ViewOffset = Game.ScreenSize*0.5f - centre;

            if (CurrentScreen == null) return ViewOffset;

            Bounds = CurrentScreen.Bounds.Clone;
            Bounds.Right -= Game.Width;
            //Bounds.Left += Game.Width/2;
            Bounds.Top -= Game.Height;
            //Bounds.Bottom += Game.Height/2;

            ViewOffset *= -1;
            ViewOffset.Clamp(Bounds);
            ViewOffset *= -1;

            return ViewOffset;
        }