Jumping Jack 4K

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

No. It has to be manually approved before it will be shown. Don’t worry though, as long as it is in before the deadline it will be accepted.

Please, link to the game from this post (not directly, but via javaunlimited). :slight_smile:
Now, I’ve tried it, and found a bug. If you jump up through the first hole and hold down the up arrow, you go up all the way and then gain one level per jump. Reached level 15 in about as many seconds. :slight_smile:

The bug I got was later on when the holes move faster and the character goes over the side and falls. The fall animation is then drawn on the line above the one where the player was. The player then falls back down to the level he was at. The level counter then goes crazy and the player can jump through the lines.

However I think your bug is a timer related thing. My processKEyEvent sets the key to be false whenever the key is released. Though even a quick press sometimes generates more than one such method call. So I placed an extra check in the UP button so that you can only jump after 850ms have passes since the last jump. I removed that just now and saw that if the holes are generated above each other then the players goes through them all. The hole generation part uses Math.random() and not a seeded Random. Should that make a difference to the X placement of the holes? They usually appear in some sort of pattern with the Math one.

Also, I didn’t use FPS checking so if the computer gets slowed for some reason the whole game gets messed up.

Did you get that bug the whole time?

I’ve uploaded the source at http://www.javaunlimited.net/hosted/JJ4K/A.java if you’d like to determine how much of a masochist you are. :slight_smile: My editor uses 2 spaces per tab so the layout might look strange.