Hunters4k

http://www.mojang.com/j4k/hunters4k/
woot broken board

http://www.mojang.com/j4k/hunters4k/screenshot0.png

U hav managed to hax evry OS to disply 4K instead of 1Mb! Gd God dis is awsome! ;D

Jst kidin, DP

AwesomeWork;D

FSMThrewAInvalidDisplayModeException.Well,WindowedWorked:)

I have just enough space to say this: Dude, you suck. ;D

Great work. :slight_smile:

Awesome ai; creepy! Excellent!

Since the board is back to normal now…

Fullscreen mode didn’t work. It just gave me an InvalidDisplayMode exception.

The “crosshair” is interesting, but it’s quite weird to have the crosshair jitter around.

The shading of the spheres looks pretty good. How did you do that? :slight_smile:

[quote]Fullscreen mode didn’t work. It just gave me an InvalidDisplayMode exception.
[/quote]
Fullscreen works on my GeForce 2 GTS, but windowed mode doesn’t work on my Mac. It just shows a blank window. I didn’t try fullscreen.

[quote]The “crosshair” is interesting, but it’s quite weird to have the crosshair jitter around.
[/quote]
The jitter isn’t all that noticable in fullscreen. Windowed mode is the ugly one.

[quote]The shading of the spheres looks pretty good. How did you do that? :slight_smile:
[/quote]
He did procedural texturing. Basically, it’s a formula of some sort that produces the pixels you want. The most impressive of these is the Perlin noise formula. Ever see POVRay? That’s the Perlin algo.

Markus, you should really release the source code so that others can learn about procedural texturing.

Also, a radar would be really nice. :slight_smile:

That is very impressive!

Still quite alot of optimisations you can do to the source if you feel like adding sound to it ;D

Heres some suggestions :wink:

Change all your double & long constants to smaller types.
Some can goto byte/short/int the rest will be fine as floats.

A classic example of this is :-

enableEvents(someLong);

it generates smaller bytecode if you push a byte (or in your case a short) onto the stack, and then expand it to a long.

This would be the equivalent of :-

enableEvents((long)someByte);

In most cases, it will save you 7 bytes in the constants pool, but cost you 1 extra bytecode instruction - a total saving of 6 bytes.
In your case, your flags value is 511, so you will only save 5 bytes by doing this.

Also, for the instances where you have Constants that are multiples of one-another (for example -PI, PI and 2PI).
It occupies less space if you don’t expand the multiplication.

e.g.

20.23452f + 40.46904f

ldc 20.23452f  (2 or 3 bytes)
ldc 40.46904f  (2 or 3 bytes)
fadd

8 bytes in the constants pool,
min. 5 bytecodes (max. 7) to perform the op.

total 13-15.

20.23452f + 20.23452f * 2

ldc 20.23452f  (2 or 3 bytes)
dup
fconst_2
fmul
fadd

4 bytes in the constants pool,
min 6bytecodes (max. 7) to perform the op.

total 10-11. A possible saving of upto 50%! =)

Adjusting some constants to allow them to be represented in a smaller type will shrink your constants pool.

For example, if you can, change all constant value usage from 128(short) to 127(byte).

Adjusting similar constants so they are identical, to eliminate constants from the constants pool saves you 2 fold - smaller constants pool, and reduced usage of the larger ldc2 instruction.

You could get rid of the 6 static fields, and replace it with 1 Object array. It would add some array dereferencing, but would allow you to have the minimum of 1 member variable.

The compiler &| obfuscator is adding in some bolox code ->


if(g1 != g1)
    break;
    //  651 1193:aload           22
    //  652 1195:aload           22
    //  653 1197:if_acmpne       3356

Still unsure why this happens, but i’ve had it happen to me several times.

dispose()ing of the JFrame, rather than System.exit()ing,
would be cleaner (no low level Exceptions from Java2D), and may even give you a smaller constants pool!

You are using both BufferedImage & MemoryImageSource, eliminating the MemoryImageSource and doing it through the BufferedImage API may save some space.

Re-ordering some of your instructions (especially where you are repeatedly accessing the same Object reference), so you can take better advantage of the dup2 instuction to duplicate values (the object reference) on the stack 2 at a time.

Get rid of the Random class usage, this will save tonnes in your constants pool.
while poor programming practice, Math.random() will suffice.

In many places in the code, there are duplications of load instructions, when a dup instruction would generate smaller bytecode.

Here for example, you could save 2 bytes by swapping the second fload of each pair, with a dup.


double d1 = Math.sqrt(f13 * f13 + f15 * f15);
    // 1643 2841:fload           38
    // 1644 2843:fload           38
    // 1645 2845:fmul            
    // 1646 2846:fload           39
    // 1647 2848:fload           39
    // 1648 2850:fmul            
    // 1649 2851:fadd            
    // 1650 2852:f2d             
    // 1651 2853:invokestatic    #75  <Method double Math.sqrt(double)>

Note all these optimisations pay no attention to how the changes will effect the efficiency of the jars zlib compression.
It would be near impossible to try and taylor the layout of your code so it got the most out of the compression.
The best you can hope to do, is make the basic class file as small as possible.

Ouch! Just noticed there is some StringBuffer usage in there.
Getting rid of that will save you atleast 40bytes.

Fantastic. ;D

Brilliant! Superb! Git! :slight_smile:

Kev

=D

The “crosshair” is actually the mouse pointer. Changing it to Cursor.CROSSHAIR took up less space then making it invisible, plus it saved me the space it’d take to draw a crosshair manually. Woot, hacks kick ass.

I will open up the sourcecode for both this and dungeon4k Real Soon Now™.

Oh, and abuse… you have far too much free time. :wink:
If I get some, I’ll look into your suggestions. =)

Great game…

:-[ Well, I give up! DooM4K si doomed!

Rafael.-

wonderful! I wish I could play it in a larger screen though :slight_smile: Fullscreen didn’t work for me here (on a Linux box) either.

Absolutely amazing! 8)

Awesome!

I think you’re allowed to sign jar’s without it counting towards the 4k limit, as long as you can present the same game in a 4k unsigned jar… is this wrong? If it is, I have to remove all my webstarts :S

Now all you need to do is combine this game with one of the 4K RPG’s ;D

may I say: the WINNER! It really amazing game for only 4kb…

Very cool. When will the source be avaliable :slight_smile: ?