Hey Dosenbier,
Great Entry! Here's a few tips for making it smaller so you can cram more stuff:
1. Don't use a package name. In fact, you can save a few bytes by using a single character class name.
2. You can pack a manifest, but you can't use the JAR tool. Just add a file called META-INF/MANIFEST.MF and have exactly
three lines in it:
1
| Main-Class: MyMainClass |
Note that the last two lines are carriage returns. :-)
3. Make sure you're not using any methods unless they get called REALLY often. Inlining everything tends to save a lot of space.
4. Use a single character name for the GIF file. There's no need for the ".gif" extension, or the joust4K directory.
5. Use the command line version of 7-Zip or KZIP to shrink your JAR file even further. For example, I used the following command on your files:
1
| 7z a -mx=9 -tzip joust4k.jar joust4k/Joust4k.class joust4k/joust.gif META-INF/MANIFEST.MF |
The result was a 4011 byte file WITH the manifest I described above. Even InfoZip comes up with a 4061 byte file using:
1
| zip -9XJ joust4k.jar joust4k/Joust4k.class joust4k/joust.gif META-INF/MANIFEST.MF |
6. If you use a method call, make sure you use the same form of it everywhere. Redundancy improves compression!
Anyway, hope those tips help. Now if I can get a few gameplay requests in:
- How about some platforms like in the original Joust?
- Can you change the "Space" to "Enter" for starting the game? I keep missing whether I won or not, because I was trying to fly.
- How about a full screen version? You can resize the images on the fly using the version of drawImage() that takes width and height.
- Could you add levels? i.e. The first level has 1 bad guy, the second has two, the third has three, etc.
And in case I didn't say it before, great game! :-)