Level Counter

Story: 60, Challenge: 0.

Friday, January 18, 2013

Level sets, level unlocks, and persistant data

Much has happened to the good old levels system. In the last post I've mentioned creating the first of (hopefully) many challenge levels. To allow for different kinds of levels a new system was put in place. The main menu now enables you to choose the type of level you want to play (currently only story (regular) and challenge levels are available). As well as do some other stuff (more on that later). Once you choose a level type, the old level select menu pops up. However it is now specific to the type chosen and shows only those levels.

The old level select menu has also been improved. It now locks levels that are unimplemented or not yet unlocked. A level is unlocked by beating the previous level. (Naturally level 1 of any type is never locked).
This is all well and good. But when the game was closed it would "forget" which levels were already unlocked and lock all but the first level again. in comes androids shared preferences, which essentially act like a simple data base, allowing for storing pairs of string keys with primitive (int, bool, string) values. So now I have a simple data base of which level was unlocked, which I read to create the level menu. Naturally this data base is updated every time a level is unlocked. The same infrastructure will be used in the future to maintain the scores achieved on each level.

This whole thing of course makes it somewhat difficult to test new levels, so an "unlock all" button was added to the main menu to simplify testing. And a "clear data" button was added for testing as well. It completely removes the database.

(Initially all levels are unlocked -> After solving three levels -> Cheat by clicking unlock all in the main menu -> All implemented levels unlocked).

 A few other things were done, a new story level was created bringing the total to story: 23 challenge: 1. The blog was slightly redesigned to be easier to read thanks to some constructive criticism I received recently. So the lesson here is, let me know what you think, it really helps.

No comments:

Post a Comment