I am working on a 2D game where I need the back-buffer to be larger than the actual displayed screen so that I can draw relatively large maps while using the actual display with a camera to scroll left, right, up, and down.
However, I have found that the PreferredBackBufferWidth & PreferredBackBufferHeight are connected to the actual screen width and height.
I think you might be mistaken either in terminology or conceptually misunderstand something. The back buffer is what is displayed. That’s why MonoGame forces the back buffer and window size to be the same.
Yes, I have been starting to research the RenderTarget component and as a result was beginning to lean in that direction.
However, I am currently using a camera to scroll my map-board tiles. How then would I use the RenderTarget to provide the same capability?
Do I instead use the camera, if that is possible, against the RenderTarget instead? Or do I calculate which set of tiles are to be displayed from the RenderTarget to the BackBuffer?
Once you have drawn the map to the RenderTarget, you don’t need to render the map again unless it changes.
When you are drawing the RenderTarget to the back buffer, offset the position of the RenderTarget by the negative amount you would have moved the camera. For example, if you would have moved the camera +10, -5, offset the position of the RenderTarget by -10, +5. This will move the RenderTarget in the opposite direction with the camera staying still, giving the same effect as if the RenderTarget was stationary and the camera moved.
So the RenderTarget can be used in place of a Texture2D in the SpriteBatch.Draw method since it inherits from the Texture2D class?
Also, if I am implementing left, right, up, down scrolling I would need to extract from the RenderTarget that rectangular selection that is indicative of the tiles in the direction they are being scrolled in the same manner as I am currently using the default Camera. However, you are showing two different draw methods for two different aspects of the RenderTarget.
Are you showing then that if I want the map to begin from the upper-left hand corner of the tile-set in the RenderTarget (which is what I am currently doing) that I would use the first SpriteBatch.Draw method subsequently adding a Vector class to simulate scrolling?
Sorry for the continuous questions but I have been doing a lot of research on my own and the information is quite scant for game development in general unless one is subscribing to a standard game genre, which strategy games do not appear to be well represented as a result…
I have found a book, which has a section on hexagonal tile maps, which I just ordered…
One quick question on the code provided. I have reviewed it and understand everything you provided except for the sizing of the actual displayed BackBuffer to the user.
Where are you setting the actual displayed screen size to 800x480 or are you just using the internal defaults?
If so, I would want to start with a set screen display, then allowing the user to go to full-screen mode…
Ah, yes. That is the default. You can change it by setting the PreferredBackBufferWidth and Height on the GraphicsDeviceManager. If you change this outside of your Game1 constructor you need to call ApplyChanges on the GraphicsDeviceManager for the size change to take effect.