752 Lines, One Class: My First App

First year of university in Prishtina. Just learned Java. Got obsessed. Built a full Piano Tiles clone as a desktop app using Java Swing — two days and two nights, no sleep, no food.

The entire game lives in one class. 752 lines. I barely understood objects at the time, so everything — rendering, input, game logic, menus — got crammed into FinalPiano.java. Variable names are in Albanian: gjenero() (generate), leviz() (move), nr_sustave (number of keys).

It’s terrible code by any standard. But it works. And it’s the thing that made me fall in love with building software.

Run it

You need Java installed.

Run the JAR:

java -jar PianoTiles.jar

Download PianoTiles.jar

Or compile from source:

javac FinalPiano.java
java FinalPiano

Download FinalPiano.java

Click the red “Start” tile. Tap black tiles as they scroll. Miss one and it’s over.

Why share this

Every senior engineer has code like this buried somewhere. Most people delete it. I’m putting mine on the internet.

Today I write clean, well-structured code — OOP, SOLID, design patterns. But I got there because I started here: brute-forcing a game into existence with nothing but if statements and for loops.

Source (abbreviated)

public class FinalPiano extends JPanel{
	JFrame frame = new JFrame();
	private int pergjigjja=2;
	Mouseclass mouse = new Mouseclass();
	static FinalPiano p = new FinalPiano(400,600,4,0,
		600-600/4,600-2*(600/4),600-3*(600/4),600-600,-602/4);
	public static int milisekondat = 10;
	public boolean mause_clicked=false;
	private int nr_sustave;
	private int x;
	private int y,y1,y2,y3,y4;
	private int z,z1,z2,z3,z4;
	private int v,v1,v2,v3,v4;
	private boolean click=true,click1=true,click2=true,click3=true;
	private int score=00;
	private int random = gjenero(),random1=gjenero(),
		random2=gjenero(),random3=gjenero(),random4=gjenero();

	// ... 700+ more lines of pure determination
}

Download the full source — every Albanian variable name, every copy-pasted block, in its glory.