File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programming Diversions and the fly likes The smallest tetris in Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Other » Programming Diversions
Bookmark "The smallest tetris in Java" Watch "The smallest tetris in Java" New topic

The smallest tetris in Java

Petr Blahos
Ranch Hand

Joined: Apr 28, 2004
Posts: 131
Hi all,

I have just finished my submission to Java 4K Game Programming Contest ( - a tetris. You can check it out here:

Anyway, it made me think what size would the smallest possible tetris in java be. If we define rules as follows:
* Size of class files + any possible data files count.
* If there are data files, they must be acquired using CLASS.class.getClassLoader().getResourceAsSream() - or similar, so that it would run both from a jar and from a directory.
* Neither colors nor sizes are important (though presumably it shouldn't be unplayable due to un-visibility).
* It should display score and level and a next item. It must be clear that the displayed Score and Level are score and level.
* The level (of difficulty) should increate with a certain number of removed lines.
* It should implement a keyboard control, up-key will rotate, left, right is obvious.
* Down-key will cause cause the block to either fall down immediatelly or to fall faster. It is kept on the discretion of the implementor, as long as it does something reasonable.
* It should implement a "game over". Then, the space-bar will start a new game. There is no need to let user know that the game ended, neither that they must press space.
* It should be written in Java (not Jython, java assembler, ...).

I have pushed it down to 3536B class file and 224B data file, compiled with jdk-1.4.2_03. What about you?

I don't want to distract you by my solution so I will post it in couple of days time. Just to give you time to think... ;-)

[ February 22, 2005: Message edited by: Petr Blahos ]

Get a better web browser:<br /><a href="" target="_blank" rel="nofollow"></a>
Peter van de Riet
Ranch Hand

Joined: Apr 09, 2004
Posts: 112

I think the subject of this thread is wrong, maybe "The smallest tetris in java" is better.
Earlier today I found another "smallest Tetris"

Each number system has exactly 10 different digits.
Petr Blahos
Ranch Hand

Joined: Apr 28, 2004
Posts: 131
Well, anyway, if anybody is interested, you can see the
smallest tetris I could write here:

I agree. Here's the link:
subject: The smallest tetris in Java
It's not a secret anymore!