예제 #1
0
 private void scroll()
 {
     if (Map.Width > viewPort.Width || Map.Height > viewPort.Height)
     {
         int x = pc.Position.X - viewPort.Width / 2;
         int y = pc.Position.Y - viewPort.Height / 2;
         if (x < 0)
         {
             x = 0;
         }
         if (y < 0)
         {
             y = 0;
         }
         if (x >= Map.Width - viewPort.Width)
         {
             x = Map.Width - viewPort.Width;
         }
         if (y >= Map.Height - viewPort.Height)
         {
             y = Map.Height - viewPort.Height;
         }
         viewPort.Position.X = x;
         viewPort.Position.Y = y;
         viewPort.PreventGlitches();
     }
     else
     {
         viewPort.Position.X = 0;
         viewPort.Position.Y = 0;
     }
 }