This is my first entry into Java 4K. I only heard of the competition about a week before the closing date, so I had rather little time to plan something.
The game is pretty basic and crude: you jump until Jack dies (or your fingers die, whichever comes first, heh).
I’ve uploaded 2 versions.
The Webstart one cannot keep high scores, whereas the JAR one can.
The keys:
Left/Right to move
Up to jump
Escape to exit
P to pause
S to stop game and record high score if you got one (Only works in JAR version).
Technical:
Everything is procedural.
Currently the things are drawn in hardcoded drawXXX statements. Is it possible (or feasible) to have, say, a String array where each String is of the form “(type) x x x x x x x x” where (type) is a letter (or number) for Oval/Rectangle/Whatever and the x’s are coordinates. Then you’d have a single for-loop in the draw stage with a switch based on the first part of the String and then have the various drawXXX statements use the rest of the String as coordinates?
The Webstart file is 2,902 bytes, the JAR one 3,480 bytes. Now that’s quite a difference seeing that the JAR only has an extra Scores array and a small part for reading/writing the high score info. Do you think it’s worth it then to let the game keep high scores?
Both files are way under 4096 bytes but that’s because I didn’t really have much time to plan a good game. The source is plagued with a lot of duplicate if’s and stuff. So I should be able to decrease the size even more.
This is the way I get my files as small as possible:
- Compress with 7zip.
- Obfuscate with Progaurd. (Are there better ones? Can 2 obfuscators be run on 1 file make it even smaller?)
- Extract the obfuscated JAR and compress again using 7zip.
This basically changes my JAR size like this:
Compressed: 4,807 bytes
Obfuscated: 3,591 bytes
Re-Compressed: 3,480 bytes
Am I missing something by having to compress again, or is this the way ProGaurd works?
I realized now: after obfuscation the field names contain similar strings like java_whatever_whatever_ and that’s why re-compressing decreases file size more.
Known Bugs:
When the player moves off screen, the wrapping isn’t really correct. The part of the player going off the screen must appear on the other side but instead the entire player goes to the other side when it’s completely off the screen. This sometimes cause a glitch when you run over a hole that is also partly off the screen.
Sometimes when the player jumps in a strange way the level numbers gets messed up and that makes the game unplayable.
Things I’d like to add:
- More than 1 hole at later levels
- Monsters at later levels that make you fall
- Pick-ups that temporarily decrease hole speed
Remarks:
My logic tells me it’s unnecessary to have lives?
The game’s link: http://javaunlimited.net/games/launch.php?type=jnlp&id=165