How to store levels in an Android game?

This is not so much a technical issue as a style issue. I am doing a generalization of peg solitaire for Android, and there will be different levels that you can play. Each of them will have different starting configurations for the board, different sets of moves that you can do, etc. Now I have programmed it at one basic level, and all these variables are initialized in this way initially.

Am I adding a text file with all levels of different types and programming it to read from a text file? Do I add a level class with all this information from each level and create several level objects when it is initialized? I can create a level class, but initialize it by reading the levels from a text file?

I am sure that all methods will work, but is there a standard way to do this? I have never programmed anything like this before.

+5
source share
2 answers

In fact, there is no standard way to do what you want, it really depends on the complexity of the data that needs to be stored to complete each level initialization. Will this data change or is it static? Does it make sense to organize it and separate it from the logic of the code? These are questions that you must answer yourself, because this is your game, and we do not know all the details.

, , XML, TXT - . . (IMO) - Level, . XML/TXT/ . , , - . , , getter/setter .

, , , " , ". , .

, , , .

+4

, , , , Level, !

Edit

, . =] , , .

+2

All Articles