Not logged in, Join Here! or Log In Below:  
 
News Articles Search    
 


Submitted by Matt Zucker, posted on June 27, 2002




Image Description, by Matt Zucker



"Last stickman standing" is my entry for the 2002 5k Contest at http://www.the5k.org/ -- the 5k is an annual contest to pack a cool webpage into 5 kilobytes. This is a java applet game that I submitted for the "anything goes" category of the competition.

The idea is, there are these stickmen running around a little 3D room beating each other up. You place bets on which stickman will be the sole victor at the end of each round. From a technical standpoint, the game is pretty neat -- it contains the following features, all in only 4889 bytes:
  • parameterized skeletal stickman animation
  • smooth depth scaling for stickmen
  • custom-made user inerface written without java AWT
  • cheat mode! (peek at the java console for a betting tip)
  • How do you cram a functional java game into under 5 KB? The answer: dirty, dirty coding practices.

    For instance, instead of coding java methods for small snippets of repeated code, I used the C preprocessor, CPP, to create macros. It's easier to maintain the code than actually duplicating the code all across your source file, and it results in smaller code size than finalized methods.

    Another big size gain which is sort of dirty java practice is to put all of the code into one mammoth class. I started developing with 3 or 4 classes, but putting all the code into 1 source file halved the code size.

    Also, coding in loops is key (my code size barely changes when I add more stickmen because it processes them all in a loop).

    Conveniently, java classes may be stored in compressed archives, and your browser knows how to recognize them just fine. The compression also means that repeating elements of code or data is good, because it increases redundancy and is hence more compressible.

    Finally, I used jarg, the freeware java obfuscator/optimizer, in order to crunch down the archive size from 6585 bytes down to 4889.

    Please see the entry at http://www.the5k.org/description.asp/entry_id=717 -- and don't forget to check out some of the other brilliant entries.


    [prev]
    Image of the Day Gallery
    www.flipcode.com

    [next]

     
    Archive Notice: This content is archived, and commenting is no longer active. It is here for reference purposes. This content was added on an older version of flipcode, before the site closed in 2005.
     
     
    Hosting by Solid Eight Studios, maker of PhotoTangler Collage Maker.