I am currently about to start work on a libgdx game. All my previous libgdx games were messy and all over the place, and I ended up getting lost in my code. I know HOW to play music, draw to the screen, get input, etc., but not how to put it all together in a neat way.
In my past game I had used oop to make a game where every object was an Entity, and then I made a hierarchy - this is an example:
Entity -> VisibleEntity -> Enemy -> RandomTestEnemy
VisibleEntity contained a position,velocity an image file, as well as a render method.
This is obviously not the right way to do things, or atleast thats what i've been told. I read online that you need to keep classes simple and have a simple purpose. So, I would need to make a class that solely renders things to the screen, or solely handles input, not throw it all into one class. This makes sense, but I don't really follow how to go about doing it.For a simple game like all my previous projects, something like the above worked. However, I want to move on to bigger projects. For this, I need to find a way to put it all together.
With libgdx, I create a class that extends Game, which is one of libgdx's 2d library classes. With it, I can use the setScreen method to set the screen to different screens whenever I want. In the end, I would end up with 6 screens or so, including a settings screen, a level select screen, etc. The problem is what to do with the code in each screen. Do I handle input in each individual screen class? Or does it suffice to make a class called 'inputhandler' or something and then handle all input there? Furthermore, if I make a class called 'RobotEnemy' or something to that nature, do I put a render method in that class, or make an EntityRenderer class and render entities such as RobotEnemy through that way? What do I put in my "Screen" class?
In any case, I am confused. I know that there is no "right" way to do this, but I would like someone to point me in the right direction.
Any thoughts/links to good webistes/books?