Hi all,
I recently (less than a week) released a new game. It's a simple game. Use
a paddle to keep the ball bouncing around and breaking bricks.
I was thinking about adding the option for the user to create his/her own
levels. Currently, my games levels are specified in a 2d int array, where 1
specifies a brick and 0 an empty space.
I created a simple activity with checkboxes to specify whether a brick is
present at that spot or not. I have two problems:
1) I need to figure out how to use the true false value of the checkbox
being checked to create an int array, with a checked check box resulting in
a 1, and an unchecked one resulting in a 0. An example of my level arrays:
this.level9 = new int[][] { { 0, 0, 0, 0, 0, 0, 0, 0 },
{ 1, 1, 1, 1, 1, 1, 1, 1 },
{ 0, 0, 1, 0, 0, 1, 0, 0 },
{ 0, 1, 0, 0, 0, 0, 1, 0 },
{ 1, 1, 1, 1, 1, 1, 1, 1 },
{ 0, 0, 1, 0, 0, 1, 0, 0 },
{ 0, 1, 0, 0, 0, 0, 1, 0 },
{ 1, 1, 1, 1, 1, 1, 1, 1 },
{ 0, 0, 0, 0, 0, 0, 0, 0 }, };
The first 8 values are always 0.
2) How do I store this array? I first though about using SharedPreferences,
but that doesn't allow arrays. I could use an SQLite DB, but I don't really
like databases, and would prefer not to. Finally, I could use a flat file
storage like saving a .txt file to the SD card, but I do not know how to
read the contents into an array.
Any idea on how to do something like this? The levels I ship with the game
are all defined in the class itself, so I don't need to store them
somewhere.
Thanks
--
Raghav Sood
http://www.androidactivist.org/ - Author
http://www.appaholics.in/ - Founder
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en