Review my Code/ProjectDesign

Hey guys, hope everyone’s having a great time developing!

I have been tinkering with MonoGame for a few months now (At most 3 Months) and am working on a JRPG game.

I am currently focusing on the 2DEngine for Sprites, Maps, Menus, Input, Interaction, etc (It’s all still very basic stuff).
While doing that I frequently doubt the design of my classes, the dependencies between them and my project structure in general.

I was wondering if some of the more experienced users could take a look at my project and see if they come across any glaring mistakes or things that could be done better.

Here is a link to the repo: https://github.com/Dante3085/MonoGameJRPG_Ver.2

Thanks in advance
Dante

I’ll just comment on one class: your Camera class.

  • Storing input (KeyboardInput) with your camera is a little sketchy
    • If anything that should be the responsibility of some sort of external CameraController to disambiguate your camera’s duties from control duties
    • It’s really your call though, cameras and control are often tight-knit (unless it’s a shadowmap camera)
  • I get why you’re using a rectangle for bounds, but do be prepared to add a Frustum that’s been computed for orthographic projection in the future
    • I wouldn’t do it now, but I would add a comment noting that if you’ll want to add one before anything that would have you mixing 3d with 2d (ie. ortho 3d models)
  • Your zoom handling is awful, either:
    • Use fixed zoom levels (static readonly float zoomLevels[] = { 0.25f, 0.5f, 0.75f, 1.0f, ... }) and movement speeds
    • Change that if ... else cluster for movement speed to use the closest value from a table (float zoomSpeedTable[,] = new float[,] { { 0.25 /*zoom*/, 11.0f /*speed*/ }, { 0.5f, 20.0f } })
      • What I mean is store a table, and use the speed from whatever zoom-value is closest to the current zoom value (shortest distance / nearest / abs(tableZoomValue - currentZoomValue))
        • For such a one-off like this that you’ll really do only once a frame, just use LINQ - don’t fuss with the garbage
      • That if .. else cluster in Camera::UpdateCamera is really the worst thing in that whole class.