Sokoban4k

My (first) entry will be a Sokoban clone implemented as an applet at http://thisistheurl.com/file/Sokoban4k/Sokoban4k.html . I like the game genre and thought that it could be fun.

Now it’s a webstart application: Play Sokoban4k

Blog entry (where you can get the source code): http://thisistheurl.com/2005/12/13/sokoban4k/

Some facts about the game:

  • Contains 78 95 levels.
  • Size of jar is 4087 4093 4031 bytes. Optimized using 7zip and ProGuard.
  • Game area is 672*480 704*509.
  • I tried to fit in some basic effects.
  • I went for the colorful look.
  • Level designs are created by David W. Skinner, who gave me permission to use them.
  • Only tested under Windows using JDK 1.5.

Check it out and give me your opinion! After that I’ll submit it to the contest, and perhaps create another one if I get enough time. Thanks for your time!

Best regards, Kent

78 levels? Wow :slight_smile:
A classic. Good work!

Oh, and first level’s much harder than lvl 2, by the way.

Flickers alot when using the appletviewer… other than that it looks and works fine.

My friend told me the game froze upon clearing lvl 39, and that he started in the wall on lvl 40.

I solved 39, it flashed, then froze:

I got some flickering too, like it’s tearing a little. Are you drawing straight to the Graphics or drawing to a back buffer first? Nice sokoban game though, good job!

nice game, i got one of these for my phone and it had me addicted for days, i have’n reached that far, but it looked good to me (no flickering nor tearing)

[quote]78 levels? Wow
[/quote]
Thanks! I stored the levels in a way I found to be some what clever. They are all in a long string, while it bloats the class file it’s still excellent to compress. My class file in uncompressed form is a whopping 10456 bytes, while the compressed jar is 4087 bytes [and it could probably be compressed a bit further using KZip]. :slight_smile:

[quote]Oh, and first level’s much harder than lvl 2, by the way.
[/quote]
Yes it’s hard to set the order correctly. From playing with friends I noticed that what was seen as easy for one person could be very hard for another, then on another level it was the other way around. I guess improvements still could be made in the level order, I’ll save it for last.

[quote]Flickers alot when using the appletviewer… other than that it looks and works fine.
[/quote]

[quote]I got some flickering too, like it’s tearing a little. Are you drawing straight to the Graphics or drawing to a back buffer first? Nice sokoban game though, good job!
[/quote]
[edit]: Got help with it from nonnus. No need to clutter the thread with the source code any more.

[quote]I solved 39, it flashed, then froze:
[/quote]

[quote]My friend told me the game froze upon clearing lvl 39, and that he started in the wall on lvl 40.
[/quote]
Ouch, bug! :slight_smile: Thanks for mentioning it. I have a feeling about what it is, I’ll solve it tonight.

What I do is overload paint() with the drawing code and then overload update() to call paint(). I never see any flickering this way.

[quote]Thanks! I stored the levels in a way I found to be some what clever. They are all in a long string, while it bloats the class file it’s still excellent to compress. My class file in uncompressed form is a whopping 10456 bytes
[/quote]
Nice, so you just pull off a char/byte at a time? I’ll have to experiment with that…

;D

[quote]I stored the levels in a way I found to be some what clever. They are all in a long string, while it bloats the class file it’s still excellent to compress.
[/quote]
cough Sounds familiar:wink: ;D

[quote]What I do is overload paint() with the drawing code and then overload update() to call paint(). I never see any flickering this way.
[/quote]
I changed my method of updating into yours, it seems like it doesn’t flicker any more. I haven’t seen any yet anyway. The applet link above points to the newly generated applet which has this fix in it. I hope some of you can try it out.

[quote]Nice, so you just pull off a char/byte at a time? I’ll have to experiment with that…
[/quote]
Well this is ripped from my code (but shortended, you get the idea though):
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####".split("NN");
So I have all my levels in levelArray easily accessible. As you see there are not many different letters in the string, which makes up for the ability to compress it well (together with the fact that some combinations, like #### occur frequently, but such combinations can be found in almost any non-random data).

[quote]cough Sounds familiar…
[/quote]
Oh gosh! :wink: ;D Actually it doesn’t seem very similar (I read about your method) at all. Your method seems far more elaborate than mine. I just store the tile data using a string (see above). No graphics are stored or anything complicated really. My first idea was to develop a vector format stored in a string, and use interpolation between keyframes to get the animation. But then I thought: “No! You should get som school work done as well you fool!”, and I might just do. :slight_smile:

I have a new applet now, see first post for link!

  • Changed double buffering method to nonnus suggestion.
  • Fixed my level loader a bit
  • Size went up to 4093 bytes.

excellent, it has me hooked for the next couple of hours at least :smiley:

[quote]excellent, it has me hooked for the next couple of hours at least Cheesy
[/quote]
Thank you! (And thanks to everyone else who have given me feedback as well!) It feels great that some of you liked it!

n00b question
I got to earn my title (if I haven’t already). My jar file is just the class-file compressed using 7-zip and renamed to Sokoban4k.jar . Is this wrong in any way? It seems to work nicely without the manifest file. And as it is an applet I couldn’t get it to work by double clicking on it anyway (but it might be my lack of knowledge) when using jar cf Sokoban4k.jar G.class to produce the jar-file.

[quote=“DonaldEKnuth,post:12,topic:25527”]
Applets don’t need manifests. In fact, you can rename it to “ZIP” and it will work just fine. JARs were an outgrowth of the use of ZIP files to store applets back in the Java 1.1 days.

So in short, you’re doing fine. Good work! :slight_smile:

Good, it’s time to enlist my entry as the bugs seem to have been solved. I also go the permisson of David W. Skinner to use part of his levelset Microban in the game. Thanks for your feedback.

I converted it to an application and distribute it through webstart now. First post updated!

I have now added the source code! Check it out if you like to, link is in the first post.

http://thisistheurl.com/file/Sokoban4k/Sokoban4k.gif
Play Sokoban4k

Blog entry (where you can get the source code): http://thisistheurl.com/2005/12/13/sokoban4k/

Now that the game has been stable for a while (no reported bugs and quite a lot of downloads) I’m asking:

  • Should I add more visual effects to the game? In which case I will have to lower the number of levels.
  • Are the graphics all right? I went for sun’s insted of boxes as is most common, should I change something? And if yes, what?
  • Does it work well on other operative systems than Windows? Under Linux? And MacOS?
  • What’s good with this game?
  • What’s bad with this game?
  • Did I do something “strange” in my source code which you want to point out?

All feedback will be greatly appreciated!