Source code?

Are there any 4k games out there that have their source-code available? I’d be interested in learning some more tricks.

Its 2 years old now, but the source for my 4KShooter is here :-

http://www.pkl.net/~rsc/4KShooter/A.java

Thanks.

http://games.cokeandcode.com/index.php?page=source

Kev

That’s a nice collection kevglass, I see you’re using a similar template for most of your games.
Isn’t there a overhead having those extra methods, logic() and draw() ?
I also notice that you don’t have mouse controls in any of your games, any reason?

I tend to focus on getting the game playable before worrying about size. I have in a couple of cases got to a point where I couldn’t get in the features I wanted and collapsing the logic() and draw() methods down made the difference (so I did it) - but I don’t see the point of collapsing them at the start when there might actually be no need at all :slight_smile:

Only reason theres no mouse is I haven’t needed it so far. Though I think tilt4k did use mouse?

Kev

If a private or final method is invoked from only one place, there is no reason it cannot be inlined. (though there is a small set of cases where such an optimisation would be counter productive)

However, I have yet to find an optimiser that performs this transformation :frowning:

Using BCEL it should be pretty easy to write an automatable & reusable bit of code to perform the change…

http://java.dnsalias.com/4k

Click on the “More Files” link for each game.

Miners4k now has the source code available.

http://www.mojang.com/notch/j4k2k6/miners4k/

sourcecode of Poker4K

Haven’t had time to put comments in, yet.

It has a rather high method-count, but it uses recursive calls for the AI… it was the only option.