0
\$\begingroup\$

I'm creating a game with levels built from tilemaps in LibGDX. I've created the logic for the game that adds entities based on object layers, however, many levels have different behaviors. Do I need to create a separate class for every single level, or should I build in logic to handle every possible scenario in the class that loads levels?

\$\endgroup\$

1 Answer 1

0
\$\begingroup\$

That depens on what exactly changes. If for example variabels change, such as the acceleration for Gravity, you could run a short piece of code to change this variable. You then store this variable in the class where you start a new level from. This way is pretty fast, so if you can make it that the behavior depends on a variable, you can try this.

If entire formulas change, you can deal with it by making a for loop which chooses the formula based on the level, but then this needs to be run every game loop. A more efficient way would be to use different classes like you said. This does not decrease preformance, but it does increase the size of your game.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .