Wow! It looks really awesome if you ask me! The stars could go a little lower though so that we can see more of them, but it looks fine the way it is now as well.
Regarding how I could fit that many levels in the game:
I rely on the lzw-compression to do a good job, for compression to have a high efficiency the data should be represented with a small amount of symbols and patterns should occur frequently (preferably close to each other). To represent the levels in my game I only need a couple of symbols. Normally the “standard” for storing Sokoban game levels looks like this:
`######
#@
$*
.*
######`
With the symbols meaning:
wall
empty square
- A “box” on top of a box-goal square
$ A “box” on top of a normal square
@ the player
It’s easy to assume right now that a textfile with lots of levels next to eachother would compress fairly well. I wanted this to compress fairly well inside a class-file (which will be in a compressed Jar-file). First I introduced a new symbol, N, which means a new line. The map now looks like this:
`######N
#N
#@ #N
$* #N
.* #N
#N
######`
I now decided that I want to store all my levels in a single (very long) string, this will result in the characters lying next to eachother inside the classfile without any code in between them (thus the “preferably have patterns next to each other” will be fulfilled). At first this is how I store one level (the above one):
String level = “######N# #N# #@ #N# $* #N# .* #N# #N######”;
As I want to store all my levels in a large string until run-time I need to separate them. I decided that the sequence NN will be used to separate levels, as two new lines in a row never occurs and I don’t want to introduce a new symbol. This is how I store the first two levels.
String levels = “######N# #N# #@ #N# $* #N# .* #N# #N######NN####N# .#N# ###N#*@ #N# $ #N# ###N####”;
To handle the levels I decided to have them in an array, position 0 being the first level and so further. The actual line in my source code looks something like:
String[] levelArray = “######N# #N# #@ #N# $* #N# .* #N# #N######NN####N# .#N# ###N#*@ #N# $ #N# ###N####NNGG####N### ####N# $ #N# # #$ #N# . .#@ #N#########NN########N# #N# .**$@#N# #N##### #NGGGG####NNG#######NG# #NG# .$. #N## $@$ #N# .$. #N# #N########”.split(“NN”);
The only difference is that my line includes 95 levels and is several thousand characters long. My class file compresses very well, from over 10kb to <4kb. The complete source for my game is available last in my blog entry about the game: Click.