Links, tips and goodies

If you just want a way to get a feeling for how big your program is, I recommend using JOGA. It won’t get quite as small as the output JAR from, say, moogie’s tool, but it will give you a good idea of how big it’ll be. Personally, I aim for a JOGA size a few hundred bytes over 4000 (perhaps 4300) - this’ll usually let me get it down to under 4096 with moogie’s tool.

If you’re having problems getting JOGA to work, try disabling the settings for optimizing slot width and slot order under “Optimizations” -> “Byte code optimizations”. These sometimes corrupts the output JAR. Also, I recommend doing initial compression (from .class to .zip/.jar) with window’s built-in compressed folder system, it’s usually better than for example winzip.

For anyone else developing under Linux and finding it hard to Google up a link to the port of kzip: http://www.jonof.id.au/index.php?p=kenutils

Added a new entry to the WiKi. I thought I would post it here because most people probably don’t check the WiKi regularly.

Reduce else clause usage where possible.

Going from this


if((e.getModifiersEx() & KeyEvent.SHIFT_DOWN_MASK) == KeyEvent.SHIFT_DOWN_MASK) {
    shiftmodifier = true;
}
else {
    shiftmodifier = false;
}

to this


shiftmodifier = false;
if((e.getModifiersEx() & KeyEvent.SHIFT_DOWN_MASK) == KeyEvent.SHIFT_DOWN_MASK) {
    shiftmodifier = true;
}

saved me 4 bytes in the final compressed archive.

I must have this wrong but can’t you do

shiftmodifier = ((e.getModifiersEx() & KeyEvent.SHIFT_DOWN_MASK) == KeyEvent.SHIFT_DOWN_MASK);

instead?

Oops. :-\

Yes of course. However in non boolean cases this will help. I will change the example to a non boolean one to avoid confusion.

You may also be better off doing

shiftmodifier = ((e.getModifiersEx() & KeyEvent.SHIFT_DOWN_MASK) != 0);

This is all really great, thanks a lot everyone for posting!

I will try to use the template & the tips provided here soon, when I try my first 4k game :slight_smile: