コード例 #1
0
ファイル: PlayFieldView.cs プロジェクト: glocklueng/agg-sharp
 public void SetRendererPreDraw(ImageBuffer background, RendererBase rendererToDrawWith, Player playerToCenterOn)
 {
     rendererToDrawWith.PushTransform();
     Vector2D windowCenter = new Vector2D(screenWindow.Left + (screenWindow.Right - screenWindow.Left) / 2, screenWindow.Bottom + (screenWindow.Top - screenWindow.Bottom) / 2);
     Vector2D playerPos = playerToCenterOn.Position;
     Vector2D playfieldOffset = windowCenter - playerPos;
     if (playfieldOffset.x > screenWindow.Left)
     {
         playfieldOffset.x = screenWindow.Left;
     }
     if (playfieldOffset.x < -background.Width() + screenWindow.Right)
     {
         playfieldOffset.x = -background.Width() + screenWindow.Right;
     }
     if (playfieldOffset.y > screenWindow.Bottom)
     {
         playfieldOffset.y = screenWindow.Bottom;
     }
     if (playfieldOffset.y < -background.Height() + screenWindow.Top)
     {
         playfieldOffset.y = -background.Height() + screenWindow.Top;
     }
     Affine translation = Affine.NewTranslation(playfieldOffset);
     rendererToDrawWith.SetTransform(rendererToDrawWith.GetTransform() * translation);
     rendererToDrawWith.SetClippingRect(screenWindow);
 }
コード例 #2
0
            public void SetRendererPreDraw(ImageBuffer background, RendererBase rendererToDrawWith, Player playerToCenterOn)
            {
                rendererToDrawWith.PushTransform();
                Vector2D windowCenter    = new Vector2D(screenWindow.Left + (screenWindow.Right - screenWindow.Left) / 2, screenWindow.Bottom + (screenWindow.Top - screenWindow.Bottom) / 2);
                Vector2D playerPos       = playerToCenterOn.Position;
                Vector2D playfieldOffset = windowCenter - playerPos;

                if (playfieldOffset.x > screenWindow.Left)
                {
                    playfieldOffset.x = screenWindow.Left;
                }
                if (playfieldOffset.x < -background.Width() + screenWindow.Right)
                {
                    playfieldOffset.x = -background.Width() + screenWindow.Right;
                }
                if (playfieldOffset.y > screenWindow.Bottom)
                {
                    playfieldOffset.y = screenWindow.Bottom;
                }
                if (playfieldOffset.y < -background.Height() + screenWindow.Top)
                {
                    playfieldOffset.y = -background.Height() + screenWindow.Top;
                }
                Affine translation = Affine.NewTranslation(playfieldOffset);

                rendererToDrawWith.SetTransform(rendererToDrawWith.GetTransform() * translation);
                rendererToDrawWith.SetClippingRect(screenWindow);
            }