Modding Help Finding Stardew Valley Screen Center

Discussion in 'Mods' started by Alphablackwolf, Oct 26, 2016.

Tags:
  1. Alphablackwolf

    Alphablackwolf Void-Bound Voyager

    So I've been using the Game1.graphics.GraphicsDevice.Viewport width and height to determine the screen center. However, this has been unreliable at zoom levels, as it does not reflect the true screen center.

    Does anyone know how I might get the actual screen center? Is there some other variable to access? Or do I need to multiply by some pixelZoom factor?
     
    • Entoarox

      Entoarox Oxygen Tank

      You need to use the `options.zoomLevel` property in stardew itself to scale the pixel size.
       
      • Alphablackwolf

        Alphablackwolf Void-Bound Voyager

        Yes, but how does one apply that to the viewport to get the screen width/height?
         
        • Alphablackwolf

          Alphablackwolf Void-Bound Voyager

          Nevermind, found it.

          For anyone else who needs it:

          var viewport = Game1.graphics.GraphicsDevice.Viewport;
          var screenXCenter = (int)(viewport.Width * (1.0 / Game1.options.zoomLevel)) / 2;
          var screenYCenter = (int)(viewport.Height * (1.0 / Game1.options.zoomLevel)) / 2;
           

          Share This Page