Files
LunaLightXMG/UpdateNotes/Camera2D.md
T

1.9 KiB

March 15th, 2025 - JME

Currentlly the camera is static, or non-existtent really.. we need to create a camera class that handles creating and managing a viewport that follows the player wihin the level.

  • If the level is the same size as the viewport then the camera is static.

  • We also want to have a zoom capability that zooms between 320x180 and 480x270. The current view is 320x180.

  • We should be able to use a lot of the code from LunaLightGML however we will need to create the class objects and restructure to work with MonoGame.

March 16th, 2025 - JME

Created intitial Camera2D class. We will need to add in code from GML for the smooth following effect, screen shake, etc. I did add some other stuff that is cool though.

  • Zoom, we can set the camera zoom between 0.1f and 10f. These values may need to be changed after testing.

  • Rotation, I thought this might be fun.. might come in handy for an effect later on. The camera is 2D but rotates on what woudl be the z-axis.

  • We can set the level bounds that the camera exists in when moving from level to level.

March 17th, 2025 - JME

Zoom Weirdness Testing shows some serious pixel distortion when zooming. Rotation is odd.. but could still be cool at somepoint, lets focus on fixing the zoom.

I think the probelm is due to the fixed render target. We are changing the veiwport width and height when zooming but the render target stays the same. We are also zooming at sub-pixel values so it is possible to land on a zoom value of 1.5f for example which isn't pixel perfect and causes distortion.

Solutions:

  • We could abandon zoom in the camera and control zoom by changing the render target values.
  • We should in either case only zoom at integer values to preserve pixel-perfect zoom.

Leaning towards abstracting the render target code to its own class and handling zoom there. Overall I think this will be better as it is what draws to the backbuffer.